1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /////////////////////////////////////////////////////////////////////
18 // class AliCDBPath //
19 // Path string identifying the object: //
20 // "level0/level1/level2" //
21 // (was: "Detector/DBType/DetSpecType") //
22 // (example: "ZDC/Calib/Pedestals") //
24 /////////////////////////////////////////////////////////////////////
26 #include "AliCDBPath.h"
28 #include <TObjArray.h>
29 #include <TObjString.h>
36 //_____________________________________________________________________________
37 AliCDBPath::AliCDBPath() {
38 // default constructor
42 //_____________________________________________________________________________
43 AliCDBPath::AliCDBPath(const AliCDBPath& other):
53 //_____________________________________________________________________________
54 AliCDBPath::AliCDBPath(const char* level0, const char* level1,
68 if ((IsWord(fLevel0) || fLevel0 == "*")
69 && (IsWord(fLevel1) || fLevel1 == "*")
70 && (IsWord(fLevel2) || fLevel2 == "*")) {
75 AliError(Form("Invalid AliCDBPath <%s/%s/%s>!",
76 level0, level1, level2));
82 //_____________________________________________________________________________
83 AliCDBPath::AliCDBPath(const char* path):
92 //_____________________________________________________________________________
93 AliCDBPath::AliCDBPath(const TString& path):
100 //_____________________________________________________________________________
101 void AliCDBPath::InitPath() {
102 // sets fLevel0, fLevel1, fLevel2, validity flagss from fPath
104 TSubString strippedString = fPath.Strip(TString::kBoth);
105 TString aString(strippedString);
106 strippedString = aString.Strip(TString::kBoth, '/');
108 TObjArray* anArray = TString(strippedString).Tokenize("/");
109 Int_t paramCount = anArray->GetEntriesFast();
111 if (paramCount == 1) {
122 } else if (paramCount == 2) {
123 fLevel0 = ((TObjString*) anArray->At(0))->GetString();
124 TString aString = ((TObjString*) anArray->At(1))->GetString();
126 if (IsWord(fLevel0) && aString == "*") {
136 } else if (paramCount == 3) {
137 fLevel0 = ((TObjString*) anArray->At(0))->GetString();
138 fLevel1 = ((TObjString*) anArray->At(1))->GetString();
139 fLevel2 = ((TObjString*) anArray->At(2))->GetString();
141 if ((IsWord(fLevel0) || fLevel0 == "*")
142 && (IsWord(fLevel1) || fLevel1 == "*")
143 && (IsWord(fLevel2) || fLevel2 == "*")) {
156 AliInfo(Form("Invalid AliCDBPath <%s>!", fPath.Data()));
164 //_____________________________________________________________________________
165 AliCDBPath::~AliCDBPath() {
170 //_____________________________________________________________________________
171 Bool_t AliCDBPath::IsWord(const TString& str) {
172 // check if string is a word
174 TRegexp pattern("^[a-zA-Z0-9_]+$");
176 return str.Contains(pattern);
179 //_____________________________________________________________________________
180 void AliCDBPath::Init() {
181 // set fIsWildcard flag
183 fIsWildcard = fPath.MaybeWildcard();
186 //_____________________________________________________________________________
187 Bool_t AliCDBPath::Level0Comprises(const TString& str) const {
188 // check if Level0 is wildcard or is equal to str
190 if (fLevel0 == "*") {
194 return fLevel0 == str;
197 //_____________________________________________________________________________
198 Bool_t AliCDBPath::Level1Comprises(const TString& str) const {
199 // check if Level1 is wildcard or is equal to str
201 if (fLevel1 == "*") {
205 return fLevel1 == str;
208 //_____________________________________________________________________________
209 Bool_t AliCDBPath::Level2Comprises(const TString& str) const {
210 // check if Level2 is wildcard or is equal to str
212 if (fLevel2 == "*") {
216 return fLevel2 == str;
219 //_____________________________________________________________________________
220 Bool_t AliCDBPath::Comprises(const AliCDBPath& other) const {
221 // check if path is wildcard and comprises other
223 return Level0Comprises(other.fLevel0)
224 && Level1Comprises(other.fLevel1)
225 && Level2Comprises(other.fLevel2);