HighLAND
VersionManager.hxx
1 #ifndef VERSIONMANAGER_HXX_SEEN
2 #define VERSIONMANAGER_HXX_SEEN
3 //#include "Versioning.hxx"
4 #include "HLClonesArray.hxx"
5 #include "BasicTypes.hxx"
6 
7 //-------------------------------------------------------------------
8 
9 /// Maximum number of packages that can be added
10 const UInt_t NMAXPACKAGES=20;
11 
12 typedef Int_t ProdId_h;
13 
14 const ProdId_h UNKNOWN_PRODUCTION = -1;
15 
16 class PackageVersion: public TObject{
17 public:
18 
20 
21  // constructor provided name and version
22  PackageVersion(const std::string& name, const std::string& version);
23 
24  /// Everyone should have a destructor.
25  virtual ~PackageVersion() {}
26 
27  /// Return the name of this package. This overrides the TObject::GetName() interface.
28  virtual const char* GetName() const {return _name.c_str();}
29 
30  /// Return the name of this package.
31  const std::string& Name() const {return _name;}
32 
33  /// Set the name of this package.
34  void SetName(const std::string& name) {_name = name;}
35 
36  /// Return the version of this package.
37  const std::string& Version() const {return _version;}
38 
39  /// Set the version of this package.
40  void SetVersion(const std::string& version) {_version = version;}
41 
42  ClassDef(PackageVersion, 1);
43 
44 protected:
45 
46  /// The name of this package.
47  std::string _name;
48 
49  /// The name of this package.
50  std::string _version;
51 };
52 
53 
54 class Versioning: public HLClonesArray{
55 
56 public:
57 
58  virtual ~Versioning(){}
59 
60  /// return the singleton
61  static Versioning& Get(void);
62 
63  /// Check compatibility between input file software version and file used to compile nd280AnalysisTools
64  bool CheckVersionCompatibility(const std::string& versionInput,ProdId_h prodND280);
65 
66  /// Add a production
67  void AddProduction(ProdId_h prodId, const std::string& prodName, const std::string& prodLowVersion, const std::string& prodHighVersion);
68 
69  /// Get the enum of the production corresponding to a given sofware version
70  ProdId_h GetProduction(const std::string softVersion);
71 
72  /// Get the name of the production corresponding to a given sofware version
73  std::string GetProductionName(const std::string softVersion);
74 
75  /// Add a package
76  void AddPackage(const std::string& name, const std::string& version);
77 
78  /// Read package names and versions use to produce this file
79  void ReadVersions(const std::string& file);
80 
81  /// dump package names and versions
82  void DumpVersions();
83 
84  private:
85 
86  /// The singleton instance.
87  static Versioning* _versioning;
88 
89  /// Private constructor as this is a singleton.
90  Versioning();
91 
92  /// Unimplemented copy constructor as this is a singleton.
93  Versioning(Versioning const&);
94 
95  /// Unimplemented assignment operator as this is a singleton.
96  void operator=(Versioning const&);
97 
98  /// Get the software version range for a given production name
99  bool GetSoftwareVersionRangeForProduction(ProdId_h prodId, std::string& lowVersion, std::string& highVersion);
100 
101  /// Convert the production enum into an string
102  std::string ConvertProduction(ProdId_h prod);
103 
104  /// Check wether a software version is prior to another
105  bool CheckBeforeVersion(const std::string& version, const std::string& version0);
106 
107  /// Parse the version, revision and patch numbers
108  void ParseSoftwareVersion(const std::string& version, int& v, int& r, int& p);
109 
110  /// vector of sofware version ranges corresponding to each production
111  std::vector<std::string> _prodLowVersion;
112  std::vector<std::string> _prodHighVersion;
113 
114  /// vector of production enums
115  std::vector<ProdId_h> _prodId;
116 
117  /// vector of production names
118  std::vector<std::string> _prodName;
119 
120  /// vector of versions of different packages
121  std::vector<PackageVersion*> _packages;
122 };
123 
124 
125 namespace ND{
126  Versioning& versioning();
127 }
128 
129 #endif
void SetVersion(const std::string &version)
Set the version of this package.
const std::string & Version() const
Return the version of this package.
std::string _version
The name of this package.
void SetName(const std::string &name)
Set the name of this package.
virtual ~PackageVersion()
Everyone should have a destructor.
virtual const char * GetName() const
Return the name of this package. This overrides the TObject::GetName() interface. ...
std::string _name
The name of this package.
const std::string & Name() const
Return the name of this package.