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

VldContext.cxx

Go to the documentation of this file.
00001 
00002 // $Id: VldContext.cxx,v 1.19 2005/08/26 17:25:58 rhatcher Exp $
00003 //
00004 // VldContext
00005 //
00006 // VldContext is tag for identifying the required "context" when
00007 // interfacing with the DBI
00008 //
00009 // Author:  R. Hatcher 2000.05.03
00010 //
00012 
00013 #include "Validity/VldContext.h"
00014 
00015 #include "MessageService/MsgService.h"
00016 //CVSID("$Id: VldContext.cxx,v 1.19 2005/08/26 17:25:58 rhatcher Exp $");
00017 
00018 ClassImp(VldContext)
00019 
00020 //_____________________________________________________________________________
00021 std::ostream& operator<<(std::ostream& os, const VldContext& vldc) 
00022 {
00023    if (os.good()) {
00024       if (os.tie()) os.tie()->flush(); // instead of opfx
00025       os << vldc.AsString();
00026    }
00027    // instead of os.osfx()
00028    if (os.flags() & std::ios::unitbuf) os.flush();
00029    return os;
00030 }
00031 
00032 //_____________________________________________________________________________
00033 VldContext::VldContext(const Detector::Detector_t &detector,
00034                        const SimFlag::SimFlag_t mcFlag,
00035                        const VldTimeStamp &tstamp)
00036    : fDetector(detector), fSimFlag(mcFlag), fTimeStamp(tstamp)
00037 {
00038    // normal constructor
00039 }
00040 
00041 //_____________________________________________________________________________
00042 const char* VldContext::AsString(Option_t *option) const
00043 {
00044    // Return a formatted string of the contents of this object
00045    // User should copy result because it points to a 
00046    // statically allocated string.
00047 
00048    static char newstring[80] = " ";
00049 
00050    switch (option[0]) {
00051    case 'c':
00052    case 'C':
00053      sprintf(newstring,"{%c%c %s}",
00054              Detector::AsString(GetDetector())[0],
00055              SimFlag::AsString(GetSimFlag())[0],
00056              fTimeStamp.AsString("c"));
00057      break;
00058    default:
00059      sprintf(newstring,"{%6.6s|%6.6s|%s}",
00060              Detector::AsString(GetDetector()),
00061              SimFlag::AsString(GetSimFlag()),
00062              fTimeStamp.AsString("c"));
00063    }
00064 
00065    return newstring;
00066 }
00067 
00068 //_____________________________________________________________________________
00069 void VldContext::Print(Option_t *option) const
00070 {
00071    // Print this object
00072 
00073    printf("%s\n",AsString(option));
00074 
00075 }
00076 
00077 //_____________________________________________________________________________
00078 Bool_t VldContext::IsNull() const
00079 {
00080    // Return true if this was initialized by default ctor
00081    // we can only test detector type and simflag
00082    return fDetector==Detector::kUnknown && fSimFlag == SimFlag::kUnknown;
00083 
00084 }
00085 
00086 //_____________________________________________________________________________
00087 

Generated on Sat Nov 21 22:48:05 2009 for loon by  doxygen 1.3.9.1