Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

CdbRooInit.hh

Go to the documentation of this file.
00001 #ifndef CDBROOINIT_HH
00002 #define CDBROOINIT_HH
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: CdbRooInit.hh,v 1.1 2005/02/09 17:14:36 gapon Exp $
00007 //
00008 // Description:
00009 //      Class CdbRooInit.  Initialize Cdb.
00010 //
00011 // Environment:
00012 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00013 //
00014 // Author List:
00015 //     David Brown, Igor Gaponenko 4/26/02
00016 //
00017 // Copyright Information:
00018 //      Copyright (C) 2002              Lawrence Berkeley Laboratory
00019 //
00020 //------------------------------------------------------------------------
00021 
00022 //----------------------
00023 // Base Class Headers --
00024 //----------------------
00025 #include "Framework/AppModule.hh"
00026 #include "Framework/AbsParmString.hh"
00027 #include "Framework/AbsParmDouble.hh"
00028 #include "AbsParm/AbsParmNamedValue.hh"
00029 
00030 //-----------------
00031 // Other headers --
00032 //-----------------
00033 #include "BdbTime/BdbTime.hh"
00034 
00035 class CdbTransaction;
00036 
00037 class CdbRooInit : public AppModule {
00038 
00039 private:
00040 
00041   // the selection of CDB implementations
00042   enum Implementation { AUTODETECTION = 0,
00043                         READONLY };
00044 
00045   /// Main transaction policy
00046   /**
00047    *  RESTARTED_LONG_MAIN_TRANSACTION : same as LONG_MAIN_TRANSACTION but restarted every 'N' seconds, where
00048    *                                    is defined by the value of the "MainTransactionRestartInterval".
00049    *                                    The default value of thsi parameter is implementation specific. See
00050    *                                    the body of the class for details.
00051    *            LONG_MAIN_TRANSACTION : begin transaction at ::beginJob(), commit it at ::endJob()
00052    *           SHORT_MAIN_TRANSACTION : begin transaction at ::beginJob(), commit it at the second invocation of ::event()
00053    *              NO_MAIN_TRANSACTION : do no start main transaction at all.
00054    */
00055   enum MainTransactionPolicy { RESTARTED_LONG_MAIN_TRANSACTION = 0,
00056                                          LONG_MAIN_TRANSACTION,
00057                                         SHORT_MAIN_TRANSACTION,
00058                                            NO_MAIN_TRANSACTION };
00059 
00060 public:
00061 
00062   // Constructors
00063   CdbRooInit( const char* const theName        = "CdbRooInit",
00064               const char* const theDescription = "Initialize Conditions database access" );
00065 
00066   // Destructor
00067   virtual ~CdbRooInit( );
00068 
00069   // Operations
00070   virtual AppResult beginJob( AbsEvent* anEvent );
00071   virtual AppResult    event( AbsEvent* anEvent );
00072   virtual AppResult   endJob( AbsEvent* anEvent );
00073 
00074 private:
00075 
00076   void  startTransaction( );
00077   void commitTransaction( );
00078 
00079 private:
00080 
00081   // Parameters of the module
00082 
00083   AbsParmNamedValue<Implementation>        _implementation;
00084   AbsParmString                            _view;
00085   AbsParmString                            _truncateTime;
00086   AbsParmNamedValue<MainTransactionPolicy> _mainTransactionPolicy;
00087   AbsParmDouble                            _mainTransactionRestartInterval;
00088 
00089   // The context of the module
00090 
00091   unsigned int _numEvents;  // number of times the ::event() method got called
00092 
00093   BdbTime _previousTimestamp;  // the last time the ::event() method was invoked.
00094 
00095   // Parameter:
00096   //
00097   //   "AllowedOrigins"
00098   //
00099   // Description:
00100   //
00101   //   This parameter can be used to prevent an application from running against
00102   //   any type of CDB installations (so called "origins") not mentioned in this
00103   //   parameter.
00104   //
00105   // Syntax:
00106   //
00107   //   A comma separated list of allowed origins is expected here. A variable number
00108   //   of origins is allowed. Duplications of origins is also allowed, this however
00109   //   will be treated as one entry of that origin. Any kinds of
00110   //   spaces/tabs/newlines are not allowed in the string.
00111   //
00112   //   The general syntax is:
00113   //
00114   //     * | <name1>[,<name2>[...]]
00115   //
00116   //   Where:
00117   //
00118   //     <name1>, <name2> are the names of the origins. Use the corresponding CDB
00119   //                      management tools to get a list of known ones.
00120   //
00121   //   Note, that the '*' character used above is the legal value of the parameter
00122   //   recognized by the module.
00123   //
00124   // Examples:
00125   //
00126   //   *
00127   //   NAME
00128   //   NAME1,NAME2
00129   //
00130   // Default value:
00131   //
00132   //   The default value for the parameter is "*" meaning that there is no restrictions
00133   //   on where to run this module.
00134   //
00135 
00136   AbsParmString _allowedOrigins;
00137 
00138   // The transaction context:
00139   //
00140   //   A non-zero value of this pointer means that this module is attempting
00141   //   to manage the main transaction.
00142 
00143   CdbTransaction* _myTransactionPtr;
00144 };
00145 
00146 #endif

Generated on Mon Dec 5 18:22:09 2005 for CDB by doxygen1.3-rc3