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() :
41 // default constructor
45 //_____________________________________________________________________________
46 AliCDBPath::AliCDBPath(const AliCDBPath& other):
56 //_____________________________________________________________________________
57 AliCDBPath::AliCDBPath(const char* level0, const char* level1,
71 if ((IsWord(fLevel0) || fLevel0 == "*")
72 && (IsWord(fLevel1) || fLevel1 == "*")
73 && (IsWord(fLevel2) || fLevel2 == "*")) {
78 AliError(Form("Invalid AliCDBPath <%s/%s/%s>!",
79 level0, level1, level2));
85 //_____________________________________________________________________________
86 AliCDBPath::AliCDBPath(const char* path):
95 //_____________________________________________________________________________
96 AliCDBPath::AliCDBPath(const TString& path):
103 //_____________________________________________________________________________
104 void AliCDBPath::InitPath() {
105 // sets fLevel0, fLevel1, fLevel2, validity flagss from fPath
107 TSubString strippedString = fPath.Strip(TString::kBoth);
108 TString aString(strippedString);
109 strippedString = aString.Strip(TString::kBoth, '/');
111 TObjArray* anArray = TString(strippedString).Tokenize("/");
112 Int_t paramCount = anArray->GetEntriesFast();
114 if (paramCount == 1) {
125 } else if (paramCount == 2) {
126 fLevel0 = ((TObjString*) anArray->At(0))->GetString();
127 TString aString = ((TObjString*) anArray->At(1))->GetString();
129 if (IsWord(fLevel0) && aString == "*") {
139 } else if (paramCount == 3) {
140 fLevel0 = ((TObjString*) anArray->At(0))->GetString();
141 fLevel1 = ((TObjString*) anArray->At(1))->GetString();
142 fLevel2 = ((TObjString*) anArray->At(2))->GetString();
144 if ((IsWord(fLevel0) || fLevel0 == "*")
145 && (IsWord(fLevel1) || fLevel1 == "*")
146 && (IsWord(fLevel2) || fLevel2 == "*")) {
159 AliInfo(Form("Invalid AliCDBPath <%s>!", fPath.Data()));
167 //_____________________________________________________________________________
168 AliCDBPath::~AliCDBPath() {
173 //_____________________________________________________________________________
174 Bool_t AliCDBPath::IsWord(const TString& str) {
175 // check if string is a word
177 TRegexp pattern("^[a-zA-Z0-9_.]+$");
179 return str.Contains(pattern);
182 //_____________________________________________________________________________
183 void AliCDBPath::Init() {
184 // set fIsWildcard flag
186 fIsWildcard = fPath.MaybeWildcard();
189 //_____________________________________________________________________________
190 Bool_t AliCDBPath::Level0Comprises(const TString& str) const {
191 // check if Level0 is wildcard or is equal to str
193 if (fLevel0 == "*") {
197 return fLevel0 == str;
200 //_____________________________________________________________________________
201 Bool_t AliCDBPath::Level1Comprises(const TString& str) const {
202 // check if Level1 is wildcard or is equal to str
204 if (fLevel1 == "*") {
208 return fLevel1 == str;
211 //_____________________________________________________________________________
212 Bool_t AliCDBPath::Level2Comprises(const TString& str) const {
213 // check if Level2 is wildcard or is equal to str
215 if (fLevel2 == "*") {
219 return fLevel2 == str;
222 //_____________________________________________________________________________
223 Bool_t AliCDBPath::Comprises(const AliCDBPath& other) const {
224 // check if path is wildcard and comprises other
226 return Level0Comprises(other.fLevel0)
227 && Level1Comprises(other.fLevel1)
228 && Level2Comprises(other.fLevel2);