$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_TableBase_h_ 00002 #define _ots_TableBase_h_ 00003 00004 #include <list> 00005 #include <map> 00006 #include <string> 00007 00008 #include "otsdaq-core/TableCore/TableVersion.h" 00009 #include "otsdaq-core/TableCore/TableView.h" 00010 00011 namespace ots 00012 { 00013 class ConfigurationManager; 00014 00015 // e.g. configManager->__SELF_NODE__; //to get node referring to this table 00016 #define __SELF_NODE__ getNode(getTableName()) 00017 00018 class TableBase 00019 { 00020 public: 00021 const unsigned int MAX_VIEWS_IN_CACHE; // Each inheriting table class could have 00022 // varying amounts of cache 00023 00024 TableBase(); 00025 TableBase(std::string tableName, std::string* accumulatedExceptions = 0); 00026 00027 virtual ~TableBase(void); 00028 00029 // Methods 00030 virtual void init(ConfigurationManager* configManager); 00031 00032 void destroy(void) { ; } 00033 void reset(bool keepTemporaryVersions = false); 00034 void deactivate(void); 00035 bool isActive(void); 00036 00037 void print(std::ostream& out = std::cout) const; // always prints active view 00038 00039 std::string getTypeId(void); 00040 00041 void setupMockupView(TableVersion version); 00042 void changeVersionAndActivateView(TableVersion temporaryVersion, 00043 TableVersion version); 00044 bool isStored(const TableVersion& version) const; 00045 bool eraseView(TableVersion version); 00046 void trimCache(unsigned int trimSize = -1); 00047 void trimTemporary(TableVersion targetVersion = TableVersion()); 00048 TableVersion checkForDuplicate(TableVersion needleVersion, 00049 TableVersion ignoreVersion = TableVersion()) const; 00050 00051 // Getters 00052 const std::string& getTableName(void) const; 00053 const std::string& getTableDescription(void) const; 00054 std::set<TableVersion> getStoredVersions(void) const; 00055 00056 const TableView& getView(void) const; 00057 TableView* getViewP(void); 00058 TableView* getMockupViewP(void); 00059 const TableVersion& getViewVersion(void) const; // always the active one 00060 00061 TableView* getTemporaryView(TableVersion temporaryVersion); 00062 TableVersion getNextTemporaryVersion() const; 00063 TableVersion getNextVersion() const; 00064 00065 // Setters 00066 void setTableName(const std::string& tableName); 00067 void setTableDescription(const std::string& tableDescription); 00068 bool setActiveView(TableVersion version); 00069 TableVersion copyView(const TableView& sourceView, 00070 TableVersion destinationVersion, 00071 const std::string& author); 00072 TableVersion mergeViews( 00073 const TableView& sourceViewA, 00074 const TableView& sourceViewB, 00075 TableVersion destinationVersion, 00076 const std::string& author, 00077 const std::string& mergeApproach /*Rename,Replace,Skip*/, 00078 std::map<std::pair<std::string /*original table*/, std::string /*original uidB*/>, 00079 std::string /*converted uidB*/>& uidConversionMap, 00080 std::map<std::pair<std::string /*original table*/, 00081 std::pair<std::string /*group linkid*/, 00082 std::string /*original gidB*/> >, 00083 std::string /*converted gidB*/>& groupidConversionMap, 00084 bool fillRecordConversionMaps, 00085 bool applyRecordConversionMaps, 00086 bool generateUniqueDataColumns = false); 00087 00088 TableVersion createTemporaryView( 00089 TableVersion sourceViewVersion = TableVersion(), 00090 TableVersion destTemporaryViewVersion = 00091 TableVersion::getNextTemporaryVersion()); // source of -1, from MockUp, else 00092 // from valid view version 00093 00094 static std::string convertToCaps(std::string& str, bool isConfigName = false); 00095 00096 bool latestAndMockupColumnNumberMismatch(void) const; 00097 00098 unsigned int getNumberOfStoredViews(void) const; 00099 00100 protected: 00101 std::string tableName_; 00102 std::string tableDescription_; 00103 00104 TableView* activeTableView_; 00105 TableView mockupTableView_; 00106 00107 // Version and data associated to make it work like a cache. 00108 // It will be very likely just 1 version 00109 // NOTE: must be very careful to setVersion of view after manipulating (e.g. copy from 00110 // different version view) 00111 std::map<TableVersion, TableView> tableViews_; 00112 }; 00113 } // namespace ots 00114 00115 #endif