TVldContext.cxx

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

Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1