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() :
46 // default constructor
50 //_____________________________________________________________________________
51 AliCDBPath::AliCDBPath(const AliCDBPath& other):
57 fIsValid(other.fIsValid),
58 fIsWildcard(other.fIsWildcard)
66 //_____________________________________________________________________________
67 AliCDBPath::AliCDBPath(const char* level0, const char* level1,
85 if ((IsWord(fLevel0) || fLevel0 == "*")
86 && (IsWord(fLevel1) || fLevel1 == "*")
87 && (IsWord(fLevel2) || fLevel2 == "*")) {
92 AliError(Form("Invalid AliCDBPath <%s/%s/%s>!",
93 level0, level1, level2));
99 //_____________________________________________________________________________
100 AliCDBPath::AliCDBPath(const char* path):
115 //_____________________________________________________________________________
116 AliCDBPath::AliCDBPath(const TString& path):
129 //_____________________________________________________________________________
130 void AliCDBPath::InitPath() {
131 // sets fLevel0, fLevel1, fLevel2, validity flagss from fPath
133 TSubString strippedString = fPath.Strip(TString::kBoth);
134 TString aString(strippedString);
135 strippedString = aString.Strip(TString::kBoth, '/');
137 TObjArray* anArray = TString(strippedString).Tokenize("/");
138 Int_t paramCount = anArray->GetEntriesFast();
140 if (paramCount == 1) {
151 } else if (paramCount == 2) {
152 fLevel0 = ((TObjString*) anArray->At(0))->GetString();
153 TString bString = ((TObjString*) anArray->At(1))->GetString();
155 if (IsWord(fLevel0) && bString == "*") {
165 } else if (paramCount == 3) {
166 fLevel0 = ((TObjString*) anArray->At(0))->GetString();
167 fLevel1 = ((TObjString*) anArray->At(1))->GetString();
168 fLevel2 = ((TObjString*) anArray->At(2))->GetString();
170 if ((IsWord(fLevel0) || fLevel0 == "*")
171 && (IsWord(fLevel1) || fLevel1 == "*")
172 && (IsWord(fLevel2) || fLevel2 == "*")) {
185 AliInfo(Form("Invalid AliCDBPath <%s>!", fPath.Data()));
187 fPath = Form("%s/%s/%s", fLevel0.Data(), fLevel1.Data(), fLevel2.Data());
195 //_____________________________________________________________________________
196 AliCDBPath::~AliCDBPath() {
201 //_____________________________________________________________________________
202 Bool_t AliCDBPath::IsWord(const TString& str) {
203 // check if string is a word
205 TRegexp pattern("^[a-zA-Z0-9_.]+$");
207 return str.Contains(pattern);
210 //_____________________________________________________________________________
211 void AliCDBPath::Init() {
212 // set fIsWildcard flag
214 fIsWildcard = fPath.MaybeWildcard();
217 //_____________________________________________________________________________
218 Bool_t AliCDBPath::Level0Comprises(const TString& str) const {
219 // check if Level0 is wildcard or is equal to str
221 if (fLevel0 == "*") {
225 return fLevel0 == str;
228 //_____________________________________________________________________________
229 Bool_t AliCDBPath::Level1Comprises(const TString& str) const {
230 // check if Level1 is wildcard or is equal to str
232 if (fLevel1 == "*") {
236 return fLevel1 == str;
239 //_____________________________________________________________________________
240 Bool_t AliCDBPath::Level2Comprises(const TString& str) const {
241 // check if Level2 is wildcard or is equal to str
243 if (fLevel2 == "*") {
247 return fLevel2 == str;
250 //_____________________________________________________________________________
251 Bool_t AliCDBPath::Comprises(const AliCDBPath& other) const {
252 // check if path is wildcard and comprises other
254 return Level0Comprises(other.fLevel0)
255 && Level1Comprises(other.fLevel1)
256 && Level2Comprises(other.fLevel2);