CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/CondCore/ORA/src/MappingRules.h

Go to the documentation of this file.
00001 #ifndef INCLUDE_ORA_MAPPINGRULES_H
00002 #define INCLUDE_ORA_MAPPINGRULES_H
00003 
00004 //
00005 #include <string>
00006 #include <locale>
00007 #include <algorithm>
00008 
00009 namespace Reflex{
00010   class Type;
00011 }
00012 
00013 namespace ora {
00014 
00015   class MappingRules {
00016     public:
00018       static const size_t ClassNameLengthForSchema  = 7;
00019       static const size_t MaxTableNameLength  = 20;
00020       static const size_t MaxColumnNameLength = 30;      
00021       static const size_t MaxColumnsPerTable = 100;
00022       static const size_t MaxColumnsForInlineCArray = 13;
00023       
00024     public:
00026       static std::string sequenceNameForContainerId();
00027       static std::string sequenceNameForContainer( const std::string& containerName );
00028       static std::string sequenceNameForDependentClass( const std::string& containerName, const std::string& className );
00029       static std::string sequenceNameForMapping();
00030 
00032       static std::string newMappingVersionForContainer( const std::string& containerName, int iteration );
00033       static std::string newMappingVersionForDependentClass( const std::string& containerName, const std::string& className, int iteration );
00034       
00036       static std::string mappingPropertyNameInDictionary();
00037       static bool isMappedToBlob(const std::string& mappingProperty);
00038       static std::string persistencyPropertyNameInDictionary();
00039       static bool isLooseOnReading(const std::string& persistencyProperty );
00040       static bool isLooseOnWriting(const std::string& persistencyProperty );
00041       static std::string classId( const std::string& className, const std::string& classVersion );      
00042       static std::string classVersionFromId( const std::string& classId );
00043       static std::string baseIdForClass( const std::string& className );
00044       static std::string baseClassVersion();
00045       static std::pair<bool,std::string> classNameFromBaseId( const std::string& classId );
00046       static std::string defaultClassVersion(const std::string& className);
00047       static std::string classVersionPropertyNameInDictionary();
00048 
00050       static std::string scopedVariableName( const std::string& variableName, const std::string& scope );
00051       static std::string variableNameForArrayIndex( const std::string& arrayVariable, unsigned int index );
00052       static std::string variableNameForArrayColumn( unsigned int arrayIndex );
00053       static std::string variableNameForArrayColumn( const Reflex::Type& array );      
00054       static std::string variableNameForContainerValue();
00055       static std::string variableNameForContainerKey();
00056       static std::string scopedVariableForSchemaObjects( const std::string& variableName, const std::string& scope );
00057 
00059       static std::string newNameForSchemaObject( const std::string& initialName, unsigned int index, size_t maxLength, char indexTrailer=0 );
00060       static std::string newNameForDepSchemaObject( const std::string& initialName, unsigned int index, size_t maxLength);
00061       static std::string newNameForArraySchemaObject( const std::string& initialName, unsigned int index, size_t maxLength);
00062 
00064       static std::string tableNameForItem( const std::string& itemName );
00065       static std::string columnNameForId();
00066       static std::string columnNameForRefColumn();
00067       static std::string columnNameForVariable( const std::string& variableName, const std::string& scope, bool forData=true );
00068       static std::string columnNameForOID( const std::string& variableName, const std::string& scope, unsigned int index );
00069       static std::string columnNameForRefMetadata( const std::string& variableName, const std::string& scope );
00070       static std::string columnNameForRefId( const std::string& variableName, const std::string& scope );
00071       static std::string columnNameForPosition();
00072       static std::string columnNameForNamedReference( const std::string& variableName, const std::string& scope );
00073       static std::string columnNameForBlobMetadata( const std::string& dataColumnName );
00074       static std::string fkNameForIdentity( const std::string& tableName, int index=0 );
00075 
00077       static std::string formatName( const std::string& variableName, size_t maxLength );
00078       
00079     private:
00080 
00081       struct ToUpper {
00082           ToUpper(const std::locale& l):loc(l) {}
00083           char operator() (char c) const  { return std::toupper(c,loc); }
00084           std::locale const& loc;
00085       };
00086       static std::string nameForSchema( const std::string& variableName );
00087       static std::string shortNameByUpperCase( const std::string& className, size_t maxLength );
00088       static std::string shortScopedName( const std::string& scopedClassName, size_t maxLength );
00089       static std::string nameFromTemplate( const std::string& templateClassName, size_t maxLength );
00090       
00091       static std::string newMappingVersion( const std::string& itemName, int iteration, char versionTrailer );
00092 
00093       
00098 
00100 
00106 
00113 
00120 
00122 
00127   };
00128 }
00129 
00130 #endif
00131