$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_TableVersion_h_ 00002 #define _ots_TableVersion_h_ 00003 00004 #include <ostream> 00005 00006 namespace ots 00007 { 00008 // TableVersion is the type used for version associated with a configuration table 00009 //(whereas TableGroupKey is the type used for versions association with global 00010 // configurations) 00011 // 00012 // Designed so that version type could be changed easily, e.g. to string 00013 class TableVersion 00014 { 00015 public: 00016 static const unsigned int INVALID; 00017 static const unsigned int DEFAULT; 00018 static const unsigned int SCRATCH; 00019 00020 explicit TableVersion(unsigned int version = INVALID); 00021 explicit TableVersion(char* const& versionStr); 00022 explicit TableVersion(const std::string& versionStr); 00023 virtual ~TableVersion(void); 00024 00025 unsigned int version(void) const; 00026 bool isTemporaryVersion(void) const; 00027 bool isScratchVersion(void) const; 00028 bool isMockupVersion(void) const; 00029 bool isInvalid(void) const; 00030 std::string toString(void) const; 00031 00032 // Operators 00033 TableVersion& operator=(const unsigned int version); 00034 bool operator==(unsigned int version) const; 00035 bool operator==(const TableVersion& version) const; 00036 bool operator!=(unsigned int version) const; 00037 bool operator!=(const TableVersion& version) const; 00038 bool operator<(const TableVersion& version) const; 00039 bool operator>(const TableVersion& version) const; 00040 bool operator<=(const TableVersion& version) const { return !operator>(version); } 00041 bool operator>=(const TableVersion& version) const { return !operator<(version); } 00042 00043 friend std::ostream& operator<<(std::ostream& out, const TableVersion& version) 00044 { 00045 if(version.isScratchVersion()) 00046 out << "ScratchVersion"; 00047 else if(version.isMockupVersion()) 00048 out << "Mock-up"; 00049 else if(version.isInvalid()) 00050 out << "InvalidVersion"; 00051 else 00052 out << version.toString(); 00053 return out; 00054 } 00055 00056 static TableVersion getNextVersion(const TableVersion& version = TableVersion()); 00057 static TableVersion getNextTemporaryVersion( 00058 const TableVersion& version = TableVersion()); 00059 00060 private: 00061 enum 00062 { 00063 NUM_OF_TEMP_VERSIONS = 10000 00064 }; 00065 00066 unsigned int version_; 00067 std::string versionString_; 00068 }; 00069 } // namespace ots 00070 #endif