$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_ConfigurationManagerRW_h_ 00002 #define _ots_ConfigurationManagerRW_h_ 00003 00004 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h" 00005 00006 namespace ots 00007 { 00008 struct TableInfo 00009 { 00010 TableInfo() 00011 : // constructor 00012 tablePtr_(0) 00013 { 00014 } 00015 00016 std::set<TableVersion> versions_; 00017 TableBase* tablePtr_; 00018 }; 00019 00020 struct GroupInfo 00021 { 00022 std::set<TableGroupKey> keys_; 00023 std::string latestKeyGroupAuthor_, latestKeyGroupComment_, 00024 latestKeyGroupCreationTime_, latestKeyGroupTypeString_; 00025 std::map<std::string /*name*/, TableVersion /*version*/> latestKeyMemberMap_; 00026 00027 TableGroupKey getLatestKey() { return *(keys_.rbegin()); } 00028 }; 00029 00030 #define Q(X) #X 00031 #define QUOTE(X) Q(X) 00032 #define __GETCFG_RW__(X) getConfigurationRW<X>(QUOTE(X)) 00033 00034 //============================================================================== 00035 // ConfigurationManagerRW 00036 // This is the ConfigurationManger with write access 00037 // This class inherits all public function from ConfigurationManager 00038 // and is a "Friend" class of ConfigurationManager so has access to private members. 00039 class ConfigurationManagerRW : public ConfigurationManager 00040 { 00041 public: 00042 ConfigurationManagerRW(std::string username); 00043 00044 //============================================================================== 00045 // Getters 00046 const std::string& getUsername(void) const { return username_; } 00047 ConfigurationInterface* getConfigurationInterface(void) const 00048 { 00049 return theInterface_; 00050 } 00051 00052 const std::map<std::string, TableInfo>& getAllTableInfo( 00053 bool refresh = false, 00054 std::string* accumulatedErrors = 0, 00055 const std::string& errorFilterName = ""); 00056 std::map<std::string /*tableName*/, 00057 std::map<std::string /*aliasName*/, TableVersion /*version*/> > 00058 getVersionAliases(void) const; 00059 00060 template<class T> 00061 T* getConfigurationRW(std::string name) 00062 { 00063 return (T*)getTableByName(name); 00064 } 00065 TableBase* getVersionedTableByName(const std::string& tableName, 00066 TableVersion version, 00067 bool looseColumnMatching = false); 00068 TableBase* getTableByName(const std::string& tableName); 00069 TableGroupKey findTableGroup( 00070 const std::string& groupName, 00071 const std::map<std::string, TableVersion>& groupMembers, 00072 const std::map<std::string /*name*/, std::string /*alias*/>& groupAliases = 00073 std::map<std::string /*name*/, std::string /*alias*/>()); 00074 TableBase* getMetadataTable(void) 00075 { 00076 return &groupMetadataTable_; /* created for use in otsdaq_flatten_system_aliases, 00077 e.g. */ 00078 } 00079 00080 //============================================================================== 00081 // modifiers of generic TableBase 00082 00083 TableVersion saveNewTable( 00084 const std::string& tableName, 00085 TableVersion temporaryVersion = TableVersion(), 00086 bool makeTemporary = false); //, bool saveToScratchVersion = false); 00087 TableVersion copyViewToCurrentColumns(const std::string& tableName, 00088 TableVersion sourceVersion); 00089 void eraseTemporaryVersion(const std::string& tableName, 00090 TableVersion targetVersion = TableVersion()); 00091 void clearCachedVersions(const std::string& tableName); 00092 void clearAllCachedVersions(); 00093 00094 //============================================================================== 00095 // modifiers of table groups 00096 00097 void activateTableGroup(const std::string& configGroupName, 00098 TableGroupKey configGroupKey, 00099 std::string* accumulatedTreeErrors = 0); 00100 00101 TableVersion createTemporaryBackboneView( 00102 TableVersion sourceViewVersion = 00103 TableVersion()); //-1, from MockUp, else from valid backbone view version 00104 TableVersion saveNewBackbone(TableVersion temporaryVersion = TableVersion()); 00105 00106 //============================================================================== 00107 // modifiers of a table group based on alias, e.g. "Physics" 00108 TableGroupKey saveNewTableGroup( 00109 const std::string& groupName, 00110 std::map<std::string, TableVersion>& groupMembers, 00111 const std::string& groupComment = TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT, 00112 std::map<std::string /*table*/, std::string /*alias*/>* groupAliases = 0); 00113 00114 //============================================================================== 00115 // public group cache handling 00116 const GroupInfo& getGroupInfo(const std::string& groupName); 00117 const std::map<std::string, GroupInfo>& getAllGroupInfo() { return allGroupInfo_; } 00118 00119 void testXDAQContext(); // for debugging 00120 00121 private: 00122 //============================================================================== 00123 // group cache handling 00124 void cacheGroupKey(const std::string& groupName, TableGroupKey key); 00125 00126 //============================================================================== 00127 // private members 00128 std::map<std::string, TableInfo> allTableInfo_; 00129 std::map<std::string, GroupInfo> allGroupInfo_; 00130 }; 00131 00133 struct TableEditStruct 00134 { 00135 // everything needed for editing a table 00136 TableBase* table_; 00137 TableView* tableView_; 00138 TableVersion temporaryVersion_, originalVersion_; 00139 bool createdTemporaryVersion_; // indicates if temp version was created here 00140 bool modified_; // indicates if temp version was modified 00141 std::string tableName_; 00143 TableEditStruct() 00144 { 00145 __SS__ << "impossible!" << std::endl; 00146 __SS_THROW__; 00147 } 00148 TableEditStruct(const std::string& tableName, ConfigurationManagerRW* cfgMgr) 00149 : createdTemporaryVersion_(false), modified_(false), tableName_(tableName) 00150 { 00151 __COUT__ << "Creating Table-Edit Struct for " << tableName_ << std::endl; 00152 table_ = cfgMgr->getTableByName(tableName_); 00153 00154 if(!(originalVersion_ = table_->getView().getVersion()).isTemporaryVersion()) 00155 { 00156 __COUT__ << "Start version " << originalVersion_ << std::endl; 00157 // create temporary version for editing 00158 temporaryVersion_ = table_->createTemporaryView(originalVersion_); 00159 cfgMgr->saveNewTable( 00160 tableName_, 00161 temporaryVersion_, 00162 true); // proper bookkeeping for temporary version with the new version 00163 00164 __COUT__ << "Created temporary version " << temporaryVersion_ << std::endl; 00165 createdTemporaryVersion_ = true; 00166 } 00167 else // else table is already temporary version 00168 __COUT__ << "Using temporary version " << temporaryVersion_ << std::endl; 00169 00170 tableView_ = table_->getViewP(); 00171 } 00172 }; // end TableEditStruct declaration 00173 00174 } // namespace ots 00175 00176 #endif