]>
Commit | Line | Data |
---|---|---|
9e1ceb13 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ///////////////////////////////////////////////////////////////////// | |
17 | // // | |
18 | // class AliCDBId // | |
19 | // Identity of an object stored into a database: // | |
20 | // path, run validity range, version, subVersion // | |
21 | // // | |
22 | ///////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include "AliCDBId.h" | |
b21e3194 | 25 | #include <Riostream.h> |
9e1ceb13 | 26 | |
27 | ClassImp(AliCDBId) | |
28 | ||
29 | //_____________________________________________________________________________ | |
30 | AliCDBId::AliCDBId(): | |
31 | fPath(), | |
32 | fRunRange(-1,-1), | |
33 | fVersion(-1), | |
34 | fSubVersion(-1), | |
35 | fLastStorage("new") | |
36 | { | |
37 | // constructor | |
38 | ||
39 | } | |
40 | ||
41 | //_____________________________________________________________________________ | |
42 | AliCDBId::AliCDBId(const AliCDBId& other): | |
43 | TObject(), | |
44 | fPath(other.fPath), | |
45 | fRunRange(other.fRunRange), | |
46 | fVersion(other.fVersion), | |
47 | fSubVersion(other.fSubVersion), | |
48 | fLastStorage(other.fLastStorage) | |
49 | { | |
50 | // constructor | |
51 | ||
52 | } | |
53 | ||
54 | //_____________________________________________________________________________ | |
55 | AliCDBId::AliCDBId(const AliCDBPath& path, Int_t firstRun, Int_t lastRun, | |
56 | Int_t version, Int_t subVersion): | |
57 | fPath(path), | |
58 | fRunRange(firstRun, lastRun), | |
59 | fVersion(version), | |
60 | fSubVersion(subVersion), | |
61 | fLastStorage("new") | |
62 | { | |
63 | // constructor | |
64 | ||
65 | } | |
66 | ||
67 | //_____________________________________________________________________________ | |
68 | AliCDBId::AliCDBId(const AliCDBPath& path, const AliCDBRunRange& runRange, | |
69 | Int_t version, Int_t subVersion): | |
70 | fPath(path), | |
71 | fRunRange(runRange), | |
72 | fVersion(version), | |
73 | fSubVersion(subVersion), | |
74 | fLastStorage("new") | |
75 | { | |
76 | // constructor | |
77 | ||
78 | } | |
79 | ||
80 | //_____________________________________________________________________________ | |
81 | AliCDBId::~AliCDBId() { | |
82 | //destructor | |
83 | ||
84 | } | |
85 | ||
86 | //_____________________________________________________________________________ | |
87 | Bool_t AliCDBId::IsValid() const { | |
88 | // validity check | |
8e245d15 | 89 | |
9e1ceb13 | 90 | if (!(fPath.IsValid() && fRunRange.IsValid())) { |
91 | return kFALSE; | |
92 | } | |
93 | ||
94 | // FALSE if doesn't have version but has subVersion | |
95 | return !(!HasVersion() && HasSubVersion()); | |
96 | } | |
97 | ||
8e245d15 | 98 | //___________________________________________________________________________ |
99 | Bool_t AliCDBId::IsEqual(const TObject* obj) const { | |
100 | // check if this id is equal to other id (compares path, run range, versions) | |
101 | ||
102 | if (this == obj) { | |
103 | return kTRUE; | |
104 | } | |
105 | ||
106 | if (AliCDBId::Class() != obj->IsA()) { | |
107 | return kFALSE; | |
108 | } | |
109 | AliCDBId* other = (AliCDBId*) obj; | |
110 | return fPath.GetPath() == other->GetPath() && fRunRange.IsEqual(&other->GetAliCDBRunRange()) && | |
111 | fVersion == other->GetVersion() && fSubVersion == other->GetSubVersion(); | |
112 | } | |
113 | ||
9e1ceb13 | 114 | //_____________________________________________________________________________ |
115 | TString AliCDBId::ToString() const { | |
116 | // returns a string of Id data | |
117 | ||
c3a7b59a | 118 | TString result = Form("path: \"%s\"; run range: [%d,%d]", |
119 | GetPath().Data(), GetFirstRun(), GetLastRun()); | |
120 | ||
121 | if(GetVersion() >= 0) result += Form("; version: v%d", GetVersion()); | |
122 | if(GetSubVersion() >= 0) result += Form("_s%d", GetSubVersion()); | |
123 | return result; | |
9e1ceb13 | 124 | } |
b21e3194 | 125 | |
126 | //_____________________________________________________________________________ | |
127 | void AliCDBId::Print(Option_t* /*option*/) const { | |
128 | // Prints ToString() | |
129 | ||
130 | cout << ToString().Data() << endl; | |
131 | ||
132 | } |