]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliCDBId.cxx
new test preprocessor
[u/mrichter/AliRoot.git] / STEER / AliCDBId.cxx
CommitLineData
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
27ClassImp(AliCDBId)
28
29//_____________________________________________________________________________
30AliCDBId::AliCDBId():
31fPath(),
32fRunRange(-1,-1),
33fVersion(-1),
34fSubVersion(-1),
35fLastStorage("new")
36{
37// constructor
38
39}
40
41//_____________________________________________________________________________
42AliCDBId::AliCDBId(const AliCDBId& other):
43TObject(),
44fPath(other.fPath),
45fRunRange(other.fRunRange),
46fVersion(other.fVersion),
47fSubVersion(other.fSubVersion),
48fLastStorage(other.fLastStorage)
49{
50// constructor
51
52}
53
54//_____________________________________________________________________________
55AliCDBId::AliCDBId(const AliCDBPath& path, Int_t firstRun, Int_t lastRun,
56 Int_t version, Int_t subVersion):
57fPath(path),
58fRunRange(firstRun, lastRun),
59fVersion(version),
60fSubVersion(subVersion),
61fLastStorage("new")
62{
63// constructor
64
65}
66
67//_____________________________________________________________________________
68AliCDBId::AliCDBId(const AliCDBPath& path, const AliCDBRunRange& runRange,
69 Int_t version, Int_t subVersion):
70fPath(path),
71fRunRange(runRange),
72fVersion(version),
73fSubVersion(subVersion),
74fLastStorage("new")
75{
76// constructor
77
78}
79
80//_____________________________________________________________________________
81AliCDBId::~AliCDBId() {
82//destructor
83
84}
85
86//_____________________________________________________________________________
87Bool_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//___________________________________________________________________________
99Bool_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//_____________________________________________________________________________
115TString 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//_____________________________________________________________________________
127void AliCDBId::Print(Option_t* /*option*/) const {
128// Prints ToString()
129
130 cout << ToString().Data() << endl;
131
132}