![]() |
|
|
Bdb packages | Design docs | Source docs | Guidelines | Recent releases |
|
Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Compound Members File Members /BdbObjyMgmt/BdbObjyMgr.hh
Go to the documentation of this file.00001 #if !defined(BDBOBJYMGR_HH) 00002 #define BDBOBJYMGR_HH 00003 //-------------------------------------------------------------------------- 00004 // File and Version Information: 00005 // $Id: BdbObjyMgr.hh,v 1.5 2002/03/15 22:37:55 patton Exp $ 00006 // 00007 // Description: 00008 // Class BdbObjyMgr: 00009 // 00010 // Environment: 00011 // Software developed for the BaBar Detector at the SLAC B-Factory. 00012 // 00013 // Author List: 00014 // Simon Patton 00015 // 00016 // Copyright Information: 00017 // Copyright (C) 1999 LBNL 00018 // 00019 //------------------------------------------------------------------------ 00020 00021 //------------- 00022 // C Headers -- 00023 //------------- 00024 extern "C" { 00025 #include <pthread.h> 00026 } 00027 00028 //--------------- 00029 // C++ Headers -- 00030 //--------------- 00031 00032 //----------------- 00033 // BaBar Headers -- 00034 //----------------- 00035 #include "BaBar/BaBar.hh" 00036 00037 #include "BdbUtil/Bdb.hh" 00038 00039 //------------------------------- 00040 // Collaborating Class Headers -- 00041 //------------------------------- 00042 #include "BdbObjyMgmt/BdbObjyDomainStack.hh" 00043 00044 //------------------------------------ 00045 // Collaborating Class Declarations -- 00046 //------------------------------------ 00047 class BdbObjyTrans ; 00048 class BdbObjyDomain ; 00049 class BdbOptInhibitSystem ; 00050 class BdbInhibitSystem ; 00051 class BdbInhibitPolicy ; 00052 class BdbFederationPrimer ; 00053 00054 extern "C"{ 00055 void destroyBdbObjyMgrThreadData( void* aInstance ); 00056 } 00057 00058 //---------------------- 00059 // Base Class Headers -- 00060 //---------------------- 00061 00062 // --------------------- 00063 // -- Class Interface -- 00064 // --------------------- 00065 00066 /** 00067 * The BdbObjyMgr class is ... 00068 */ 00069 class BdbObjyMgr 00070 { 00071 // friend classes and functions 00072 friend class BdbSetDefaultBootName ; 00073 friend void destroyBdbObjyMgrThreadData( void* aInstance ); 00074 00075 public: 00076 00077 // Typedefs, consts, and enums 00078 00079 // Constructors and destructor 00080 00081 /** 00082 * Constructs an instanace of this class. 00083 * Note: the instance takes over ownership of the BdbInhibitSystem 00084 */ 00085 BdbObjyMgr( BdbInhibitSystem* inhibitSystem ) ; 00086 00087 /** 00088 * Constructs an instanace of this class. 00089 * Note: the instance takes over ownership of the BdbInhibitSystem 00090 */ 00091 BdbObjyMgr( BdbOptInhibitSystem* inhibitSystem ) ; 00092 00093 /** 00094 * Destroys this instance. 00095 */ 00096 virtual ~BdbObjyMgr() ; 00097 00098 // Selectors (const) 00099 00100 // 00101 // PThreads management 00102 // 00103 00104 /** 00105 * @return true if the pthreads is being used for multithreading 00106 */ 00107 d_Boolean isUsingPthreads() const ; 00108 00109 // 00110 // Objectivity initialization 00111 // 00112 00113 /** 00114 * @return the value to be used when initializing Objy 00115 */ 00116 d_ULong fileDescriptors() const ; 00117 00118 /** 00119 * @return the number of cache pages for main ooContext to 00120 * initially use 00121 */ 00122 d_ULong cacheInitPages() const ; 00123 00124 /** 00125 * @return the maximum number of cache pages for main ooContext 00126 * to use 00127 */ 00128 d_ULong cacheMaxPages() const ; 00129 00130 /** 00131 * @return the AMS usage for the job 00132 */ 00133 BdbAMSUsage amsUsage() const ; 00134 00135 /** 00136 * @return true if jobs is standalone 00137 */ 00138 d_Boolean isStandalone() const ; 00139 00140 /** 00141 * @return true if single federation is going to be used 00142 */ 00143 d_Boolean isSingleFed() const ; 00144 00145 /** 00146 * @return true if Objectivity has been initialized 00147 */ 00148 d_Boolean isInitialized() const ; 00149 00150 /** 00151 * @return true if this thread has been initialized for Objectivity 00152 */ 00153 d_Boolean threadIsInitialized() const ; 00154 00155 /** 00156 * Cleanup objectivity for this thread before it is terminated 00157 */ 00158 void finalizeThread() const ; 00159 00160 // 00161 // Objectivity management 00162 // 00163 00164 /** 00165 * @return the default boot file name. If none has been set the 00166 * the value of OO_FD_BOOT is returned. 00167 */ 00168 const char* defaultBootName() const ; 00169 00170 /** 00171 * @return the default transaction for the default federation 00172 */ 00173 BdbObjyTrans* defaultTransaction( const BdbObjyDomain* domain = 0 ) const ; 00174 00175 /** 00176 * @returns the activationStack for the current thread 00177 */ 00178 const BdbObjyDomainStack& activationStack() const ; 00179 00180 /** 00181 * creates and returns and new BdbObjyTrans object 00182 */ 00183 BdbObjyTrans* createTrans() const ; 00184 00185 /** 00186 * creates and returns and new BdbObjyTrans object whose setting 00187 * are based on those of the specified BdbObjyTrans 00188 */ 00189 BdbObjyTrans* createTrans( const BdbObjyTrans& trans ) const ; 00190 00191 /** 00192 * @return true if the vtable pointers are being checked 00193 */ 00194 d_Boolean checkVTablePointer() const ; 00195 00196 /** 00197 * @return true if a policy has been set for the inhibit system 00198 */ 00199 d_Boolean hasInhibitPolicy() const ; 00200 00201 // Modifiers 00202 00203 // 00204 // Objectivity initialization 00205 // 00206 00207 /** 00208 * Set up the number of file descriptors to be used by each 00209 * ooContext instance 00210 */ 00211 void setFileDescriptors( d_ULong nFiles ) ; 00212 00213 /** 00214 * Set up the number of cache pages for main ooContext to 00215 * initially use 00216 */ 00217 void setCacheInitPages( d_ULong nPages ) ; 00218 00219 /** 00220 * Set up the maximum number of cache pages for main ooContext 00221 * to use 00222 */ 00223 void setCacheMaxPages( d_ULong nPages ) ; 00224 00225 /** 00226 * Set the AMS usage for the job 00227 */ 00228 void setAMSUsage( BdbAMSUsage amsUsage ) ; 00229 00230 /** 00231 * Set the flag indicating whether the jobs is standalone 00232 */ 00233 void setStandalone() ; 00234 00235 /** 00236 * Set the flag indication when the job is running in single or 00237 * multiple federation mode. 00238 */ 00239 void setSingleFed() ; 00240 00241 /** 00242 * Set the instance of BdbNoOpenTrans which will be used just 00243 * when the default federation is accessed for the first time. 00244 * @return the old primer 00245 */ 00246 BdbFederationPrimer* setDefaultPrimer( BdbFederationPrimer* primer ) ; 00247 00248 // 00249 // Objectivity management 00250 // 00251 00252 /** 00253 * Set the default boot file name. If set to '0' the the 00254 * value of OO_FD_BOOT will be used. 00255 */ 00256 void setDefaultBootName( const char* bootname ) ; 00257 00258 /** 00259 * @returns the activationStack for the current thread 00260 */ 00261 BdbObjyDomainStack& activationStack() ; 00262 00263 /** 00264 * Set the flag indication whether to check the VTable pointer 00265 */ 00266 void setCheckVTablePointer( d_Boolean checkVptr ) ; 00267 00268 /** 00269 * Set the inhibit systems policy. 00270 */ 00271 void setInhibitPolicy( const BdbInhibitPolicy* policy ) ; 00272 00273 // Static Member Functions 00274 00275 protected: 00276 00277 // Selectors (const) 00278 00279 // Modifiers 00280 00281 private: 00282 00283 // Constructors 00284 /** stops default */ 00285 BdbObjyMgr() ; 00286 00287 /** stops default */ 00288 BdbObjyMgr( const BdbObjyMgr& aRhs ) ; 00289 00290 // Operators 00291 /** stops default */ 00292 const BdbObjyMgr& operator=( const BdbObjyMgr& aRhs ) ; 00293 00294 // Selectors (const) 00295 00296 /** 00297 * Initialize Objectivity if not already initialized 00298 */ 00299 void initialize() const ; 00300 00301 /** 00302 * Initialize this thread for Objectivity if not already initialized 00303 */ 00304 void initializeThread() const ; 00305 00306 /** 00307 * Lock mutex associated with this instance, exits if fails 00308 */ 00309 void mutex_lock() const; 00310 00311 /** 00312 * Unlock mutex associated with this instance, exits if fails 00313 */ 00314 void mutex_unlock() const; 00315 00316 // Modifiers 00317 00318 /** 00319 * initialize the class 00320 */ 00321 void initClass() ; 00322 00323 /** 00324 * sets the default transaction and executes the federation primer 00325 */ 00326 void setDefaultTransaction( BdbObjyTrans* aTrans ) ; 00327 00328 /** 00329 * Set parameters to values detect in environment variables 00330 */ 00331 void setParametersFromEnv() ; 00332 00333 // Static Member Functions 00334 00335 // Data Members 00336 00337 struct ThreadData { 00338 /** LIFO stack of domain activations */ 00339 BdbObjyDomainStack _activationStack ; 00340 /** pointer to transaction to access default federation instance */ 00341 BdbObjyTrans* _defaultTransaction ; 00342 /** the default bootfile name to use if none is specified */ 00343 char* _defaultBootName ; 00344 /** number of file descriptors used to initialize Objy */ 00345 d_ULong _fileDescriptors ; 00346 /** number of cache pages for main ooContext to initially use */ 00347 d_ULong _cacheInitPages ; 00348 /** maximum number of cache pages for main ooContext to use */ 00349 d_ULong _cacheMaxPages ; 00350 /** true if this thread has been initialized */ 00351 d_Boolean _isInitialized ; 00352 00353 /** ctor */ 00354 ThreadData(); 00355 /** dtor */ 00356 ~ThreadData(); 00357 }; 00358 00359 /** AMS usage for the job */ 00360 BdbAMSUsage _amsUsage ; 00361 /** @return true if jobs is standalone */ 00362 d_Boolean _isStandalone ; 00363 /** true if single federation is going to be used */ 00364 d_Boolean _isSingleFed ; 00365 /** true of ooInit has been called */ 00366 d_Boolean _isInitialized ; 00367 /** true if the vtable pointers are being checked */ 00368 d_Boolean _checkVTablePointer ; 00369 00370 /** pointer to the function used to prime a default federation */ 00371 BdbFederationPrimer* _defaultPrimer ; 00372 /** Inhibit System implementation to use of all transactions */ 00373 BdbInhibitSystem* _inhibitSystem ; 00374 /** Inhibit System implementation to use of all transactions */ 00375 BdbOptInhibitSystem* _optInhibitSystem ; 00376 00377 /** mutex to be used for this class */ 00378 pthread_mutex_t _mutex; 00379 /** the key to be used to access data when threads are in use */ 00380 pthread_key_t _threadDataKey; 00381 00382 /** data for this instance when threads are not in use */ 00383 ThreadData* _threadData; 00384 00385 /** 00386 * @return the data for this instance in the current thread 00387 */ 00388 const ThreadData& threadData() const; 00389 00390 /** 00391 * @return the data for this instance in the current thread 00392 */ 00393 ThreadData& threadData(); 00394 00395 // Static Data Members 00396 00397 /** true if the previous main transaction should be reused if possible */ 00398 static bool _usingPthreads; 00399 } ; 00400 00401 // inline function definitions 00402 00403 #endif // BDBOBJYMGR_HH
BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us
Page Owner: Jacek Becla
Last Update: October 04, 2002