00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013
00014 #include "TString.h"
00015 #include "Persistency/Per.h"
00016 #include "MessageService/MsgService.h"
00017
00018
00019
00020
00021
00022
00023
00024 static const VldContext kVldBegin =
00025 VldContext(Detector::kUnknown,SimFlag::kUnknown,
00026 VldTimeStamp::GetNBOT());
00027 static const VldContext kVldEnd =
00028 VldContext(Detector::kUnknown,SimFlag::kUnknown,
00029 VldTimeStamp::GetEOT());
00030
00031 CVSID("$Id: Per.cxx,v 1.21 2006/06/28 04:29:16 rhatcher Exp $");
00032
00033
00034
00035
00036 const char* Per::AsString(EAccessMode accessmode) {
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 switch ( accessmode ) {
00047 case kRead:
00048 return "READ";
00049 case kNew:
00050 return "NEW";
00051 case kRecreate:
00052 return "RECREATE";
00053 case kUpdate:
00054 return "UPDATE";
00055 default:
00056 MSG("Per",Msg::kWarning)
00057 << "Per::AsString called with unknown accessmode"
00058 << (int)accessmode << endl;
00059 return "UNKNOWN";
00060 }
00061
00062 }
00063
00064 const char* Per::AsString(EErrorCode errorcode) {
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 switch ( errorcode ) {
00075 case kErrSuccess:
00076 return "Success";
00077 case kErrFileExists:
00078 return "FileExists";
00079 case kErrFileNotFound:
00080 return "FileNotFound";
00081 case kErrFileNoSpace:
00082 return "FileNoSpace";
00083 case kErrFileConflict:
00084 return "FileConflict";
00085 case kErrFileError:
00086 return "FileError";
00087 case kErrTreeExists:
00088 return "TreeExists";
00089 case kErrTreeReadError:
00090 return "TreeReadError";
00091 case kErrInvalidAccessMode:
00092 return "InvalidAccessMode";
00093 default:
00094 MSG("Per",Msg::kWarning)
00095 << "Per::AsString called with unknown error code"
00096 << (int)errorcode << endl;
00097 return "Unknown";
00098 }
00099
00100 }
00101
00102 const char* Per::AsString(EStreamType streamtype) {
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 switch ( streamtype ) {
00113 case kDaqSnarl:
00114 return "DaqSnarl";
00115 case kDaqMonitor:
00116 return "DaqMonitor";
00117 case kLightInjection:
00118 return "LightInjection";
00119 case kDcsAlarm:
00120 return "DcsAlarm";
00121 case kDcsMonitor:
00122 return "DcsMonitor";
00123 case kBeamMon:
00124 return "BeamMon";
00125 case kCand:
00126 return "Cand";
00127 case kConfig:
00128 return "Config";
00129 default:
00130 MSG("Per",Msg::kWarning)
00131 << "Per::AsString called with unknown stream type"
00132 << (int)streamtype << endl;
00133 return "Unknown";
00134 }
00135
00136 }
00137
00138 const char* Per::AsString(ESequenceMode sequencemode) {
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 switch ( sequencemode ) {
00149 case kKey:
00150 return "Key";
00151 case kLowerBound:
00152 return "LowerBound";
00153 case kWindow:
00154 return "Window";
00155 case kSequential:
00156 return "Sequential";
00157 case kRandom:
00158 return "Random";
00159 default:
00160 MSG("Per",Msg::kWarning)
00161 << "Per::AsString called with unknown sequencemode"
00162 << (int)sequencemode << endl;
00163 return "Unknown";
00164 }
00165
00166 }
00167
00168 int Per::GetAccessMode(const char* accessmode) {
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 TString tmpstr(accessmode);
00179 tmpstr.ToLower();
00180 if ( strcmp(tmpstr.Data(),"read") == 0 ) return Per::kRead;
00181 else if ( strcmp(tmpstr.Data(),"new") == 0 ) return Per::kNew;
00182 else if ( strcmp(tmpstr.Data(),"recreate") == 0 ) return Per::kRecreate;
00183 else if ( strcmp(tmpstr.Data(),"update") == 0 ) return Per::kUpdate;
00184
00185 return -1;
00186
00187 }
00188
00189 int Per::GetSequenceMode(const char* sequencemode) {
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 TString tmpstr(sequencemode);
00200 tmpstr.ToLower();
00201 if ( strcmp(tmpstr.Data(),"key") == 0 ) return Per::kKey;
00202 else if ( strcmp(tmpstr.Data(),"lowerbound") == 0 ) return Per::kLowerBound;
00203
00204 return -1;
00205
00206 }
00207
00208 int Per::GetStreamType(const char* streamname) {
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 TString tmpstr(streamname);
00219 tmpstr.ToLower();
00220 if ( strcmp(tmpstr.Data(),"daqsnarl") == 0 ) return Per::kDaqSnarl;
00221 else if ( strcmp(tmpstr.Data(),"daqmonitor") == 0 ) return Per::kDaqMonitor;
00222 else if ( strcmp(tmpstr.Data(),"lightinjection") == 0 )
00223 return Per::kLightInjection;
00224 else if ( strcmp(tmpstr.Data(),"dcsalarm") == 0 ) return Per::kDcsAlarm;
00225 else if ( strcmp(tmpstr.Data(),"dcsmonitor") == 0 ) return Per::kDcsMonitor;
00226 else if ( strcmp(tmpstr.Data(),"beammon") == 0 )
00227 return Per::kBeamMon;
00228 else if ( strcmp(tmpstr.Data(),"cand") == 0 ) return Per::kCand;
00229 else if ( strcmp(tmpstr.Data(),"config") == 0 ) return Per::kConfig;
00230
00231 return -1;
00232
00233 }
00234
00235 Per::ESequenceMode Per::GetDefSequenceMode(const char* streamname) {
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246 int streamtype = Per::GetStreamType(streamname);
00247 switch ( streamtype ) {
00248 case kConfig:
00249 return Per::kLowerBound;
00250 default:
00251 return Per::kKey;
00252 }
00253
00254 }
00255
00256 const char* Per::GetAssociatedStreamList(const char* streamname) {
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 int streamtype = Per::GetStreamType(streamname);
00268 switch ( streamtype ) {
00269 case kCand:
00270 return "Config";
00271 default:
00272 return "";
00273 }
00274
00275 }
00276
00277 const VldContext& Per::GetVldBegin() { return kVldBegin; }
00278 const VldContext& Per::GetVldEnd() { return kVldEnd; }
00279 bool Per::IsBegin(const VldContext& vldc) { return (vldc == kVldBegin); }
00280 bool Per::IsEnd(const VldContext& vldc) { return (vldc == kVldEnd); }
00281