Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Per.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // Per
00004 //
00005 // Package: Per (Persistency).
00006 //
00007 // S. Kasahara 11/00
00008 //
00009 // Purpose: Define data types and provide general purpose utility routines 
00010 //          to the persistency package.
00011 //
00013 
00014 #include "TString.h"
00015 #include "Persistency/Per.h"
00016 #include "MessageService/MsgService.h"
00017 
00018 // Static (file-level) constant not directly visible to the outside
00019 // ****************************************************************
00020 
00021 // kVldBegin has negative time stamp because I've seen erroneous negative
00022 // time stamps in the data.  kVldEnd will need to be updated should the
00023 // experiment last much longer than expected.
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 // Definition of methods (alphabetical order)
00034 // ******************************************
00035 
00036 const char* Per::AsString(EAccessMode accessmode) {
00037   //  Purpose:  Convert enumerated accessmode to an access string.
00038   //
00039   //  Argument: accessmode: enumerated EAccessMode described in Per.h.
00040   //
00041   //  Return:  access string. If accessmode is unknown, returns "UNKNOWN".
00042   //
00043   //  Contact:   S. Kasahara
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   }//end of switch
00061 
00062 }
00063 
00064 const char* Per::AsString(EErrorCode errorcode) {
00065   //  Purpose:  Convert enumerated error code to an error string.
00066   //
00067   //  Argument: errorcode   enumerated EErrorCode described in Per.h.
00068   //
00069   //  Return:  error string. If error is unknown, returns "Unknown".
00070   //
00071   //  Contact:   S. Kasahara
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   }//end of switch
00099 
00100 }
00101 
00102 const char* Per::AsString(EStreamType streamtype) {
00103   //  Purpose:  Convert enumerated stream type to a stream string.
00104   //
00105   //  Argument: streamtype   enumerated EStreamType described in Per.h.
00106   //
00107   //  Return:  stream string. If stream is unknown, returns "Unknown".
00108   //
00109   //  Contact:   S. Kasahara
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   }//end of switch
00135 
00136 }
00137 
00138 const char* Per::AsString(ESequenceMode sequencemode) {
00139   //  Purpose:  Convert enumerated sequencemode to a sequencemode string.
00140   //
00141   //  Argument: sequencemode: enumerated ESequenceMode described in Per.h.
00142   //
00143   //  Return:  sequencemode string. If unknown, returns "Unknown".
00144   //
00145   //  Contact:   S. Kasahara
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   }//end of switch
00165 
00166 }
00167 
00168 int Per::GetAccessMode(const char* accessmode) {
00169   // Purpose: Convert text string accessmode to an enumerated code.
00170   // 
00171   // Argument: accessmode string
00172   //
00173   // Return: returns -1 if no match
00174   //
00175   // Contact: S. Kasahara
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   // Purpose: Convert text string sequencemode to an enumerated code.
00191   // 
00192   // Argument: sequencemode string
00193   //
00194   // Return: returns -1 if no match
00195   //
00196   // Contact: S. Kasahara
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   // Purpose: Convert text string streamname to an enumerated code.
00210   // 
00211   // Argument: streamname string
00212   //
00213   // Return: returns -1 if no match
00214   //
00215   // Contact: S. Kasahara
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   //  Purpose:  Return default sequencemode for specified stream.
00237   //
00238   //  Argument: streamname (e.g. "Cand")
00239   //
00240   //  Return:  default sequence mode for this stream.  If stream
00241   //           is unknown, default of Per::kKey is returned.
00242   //
00243   //  Contact:   S. Kasahara
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   } // end of switch
00253   
00254 }
00255 
00256 const char* Per::GetAssociatedStreamList(const char* streamname) {
00257   //  Purpose:  Return streams associated (coupled) with specified stream.
00258   //
00259   //  Argument: streamname (e.g. "DaqSnarl")
00260   //
00261   //  Return:  default associated streamlist for this stream.  If stream
00262   //           is unknown, default of "" is returned.
00263   //
00264   //  Contact:   S. Kasahara
00265   //
00266 
00267   int streamtype = Per::GetStreamType(streamname);
00268   switch ( streamtype ) {
00269     case kCand:
00270       return "Config";
00271     default:
00272       return "";
00273   } // end of switch
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 

Generated on Mon Feb 15 11:07:18 2010 for loon by  doxygen 1.3.9.1