//-*- mode:c++ -*- // // $Id: BrCalibration.h,v 1.8 2002/06/23 17:06:44 videbaek Exp $ // $Author: videbaek $ // $Date: 2002/06/23 17:06:44 $ // $Copyright: (c) 2001 BRAHMS Collaboration // //_____________________________________________________________________ // // BrCalibration Declarations // // #ifndef BRAT_BrCalibration #define BRAT_BrCalibration #ifndef ROOT_TNamed #include "TNamed.h" #endif #include #include #include //____________________________________________________________________ // // BrCalibrationData // class BrCalibrationData : public TObject { public: BrCalibrationData(); virtual ~BrCalibrationData(); virtual void Commit(BrCalibrationsDb* fCalibDb, Int_t, Int_t); virtual void Update(BrCalibrationsDb*, Int_t, Int_t, Int_t rev = 0); virtual void Create(BrCalibrationsDb*, Int_t, Int_t, Int_t rev = 0); virtual void Print(Option_t* option="b") const; //*MENU* Char_t fParameterName[32]; BrDbParameter *fParameter; BrDbRevision *fRevision; BrDbRevisionType *fRevisionType; Int_t fAccessMode; // 0==init, 1==read, 2==write 3==Load Int_t fDataSize; // Number of elements in data ClassDef(BrCalibrationData,1) // Data for a BrCalibration } ; //____________________________________________________________________ // // BrCalibration // class BrCalibration : public TNamed { public: enum EAccessMode { kRead=1, kWrite=2, kTransitional=3 }; BrCalibration(); BrCalibration(Char_t *name,Char_t *title); virtual ~BrCalibration(); virtual void AddParameterData(Char_t* , BrCalibrationData*); virtual void Close(Option_t* option=""); virtual void Init(); virtual void SetDatabase(BrCalibrationsDb*); virtual void Update(Int_t, Int_t); virtual void Commit(Int_t, Int_t); // virtual void Use(Char_t* Tablename); virtual void Use(const TString& parName, EAccessMode mode=kRead, UInt_t nElements=0); virtual void SetComment(const char*, const char*); virtual void SetDebugLevel(Int_t lvl) { fDebugLevel = lvl; } virtual void SetVerbose(Int_t lvl) { fVerboseLevel = lvl; } virtual Int_t DebugLevel() const { return fDebugLevel; } virtual Int_t Verbose() const { return fVerboseLevel; } virtual Int_t GetAccessMode(const Char_t* par) const; virtual void Print(Option_t* option="b") const; //*MENU* virtual Bool_t RevisionExists(const Char_t* parameterName) const; static Bool_t StillValid(Int_t start, Int_t stop, Int_t ValidStart, Int_t ValidEnd); virtual const Char_t * GetRevisionValidStart(const Char_t* parameterName) const ; virtual const Char_t * GetRevisionValidEnd(const Char_t* parameterName) const ; virtual const Char_t * GetRevisionDate(const Char_t* parameterName) const ; virtual Int_t GetRevisionValidStartUnix(const Char_t* parameterName) const ; virtual Int_t GetRevisionValidEndUnix(const Char_t* parameterName) const ; virtual Int_t GetRevisionDateUnix(const Char_t* parameterName) const ; protected: const Char_t *FormatDate(const Int_t time) const; BrDbDetector* fDetector; //!Detector Int_t fDetectorId; // Db table unique ID BrMainDb* fMainDb; //!Database Pointer BrCalibrationsDb* fCalibDb; //! TObjArray fParameterDataList; //! List of ParameterData defined for this element. Bool_t fInitialized; // Int_t fDebugLevel; //! Debug Level Int_t fVerboseLevel; //! Verbose Level public: ClassDef(BrCalibration, 3) // BRAHMS detector parameter class } ; #endif // // $Log: BrCalibration.h,v $ // Revision 1.8 2002/06/23 17:06:44 videbaek // Add methods to get the RevisionDate out from a calibration with a public method. // See eg.g use in TodDbBrowser in do_app/db // // Revision 1.7 2002/03/21 23:41:34 cholm // Added code in Update and Commit, so that as soon as the connection to the // DB server isn't needed anymore from this Update/Commit step, we // disconnect our clients. This is done, so we may keep as many free // slots on the server as possible. MySQL, in it's current setup has a // limit of 1000 simultaneous connections, and so disconnecting from the // server may allow more jobs to run. This `Disconnect ASAP' policy is // conditional on the preprocessor flag BRAT_USE_DISCONNECT, defined in // `db/abc/BrDb.h'. // // Revision 1.6 2002/03/01 14:31:32 cholm // Fixed FVs const problem // // Revision 1.5 2002/02/26 21:35:27 videbaek // Added method to get the time i.e. formatted of a revison back. // This is used in the DbBrowser utility programs. // There is a const warning (which I did not figure out yet) // // Revision 1.4 2002/02/14 21:47:56 videbaek // Add methods to GetValid Revision date which can be used to indicate what // revision ws actullay used, not just that a version was found. // // Revision 1.3 2001/12/07 21:17:29 videbaek // Removed the methos UseForWrite and UseForRead. // Some cleanup in comments, and few other not needed statements. // // Revision 1.2 2001/11/26 18:37:40 videbaek // Updated code for revised Revision tables. Added some base method to BrCalibration // that can be used for the accessCheck. // // Revision 1.1 2001/10/08 10:40:20 cholm // * Renamed BrParameterElement[Manager] to BrCalibration[Manager] // * Impacts some modules, and maybe user code too. // * Made the access class BrCalibrationsDb 'polymorphic' // * All database table representations have class version > 0 (persistent) // // Revision 1.5 2001/09/23 01:49:58 videbaek // Modified the ParameterElement to deal in method suggested by Christian // Use(name, method, noelements). // This was implemented and checked on 9/22/01 and seems ok. The // previous methods UserForWrite and UseForLoad were kept. // // Revision 1.4 2001/09/12 15:09:04 cholm // Removed ListParameters in favour of Print // // Revision 1.3 2001/07/30 12:32:29 cholm // Added Print methods // // Revision 1.2 2001/07/01 12:01:30 cholm // Added method // virtual Bool_t RevisionExists(const Char_t* parameterName) const; // See also source file log message. // // Revision 1.1.1.1 2001/06/21 14:55:17 hagel // Initial revision of brat2 // // Revision 1.8 2001/06/18 10:31:15 cholm // Changed the connection scheme to the databases. No more explicit passwords, // and better handling for diconnecting from the databases. Password is stored // internally, so that one may connect and disconnect with out the need to read // password from file or user input over and over again. Preferably, the // password should be stored in some kind of same memory or encrypted. However, // for the time being I'm ok with this, since attaching a debugger is probably // only allowed for the owning user, so no-one can peek at the memory. // // Revision 1.7 2001/06/05 18:39:34 cholm // Removed BrDbInc.h an all references to it // // Revision 1.6 2000/07/20 18:13:40 videbaek // Added SetComment(char*, char*) to parameterElement class // // Revision 1.5 2000/06/08 10:47:34 cholm // BrCalibration objects can be written to disk (ROOT file) // // Revision 1.4 2000/06/03 18:12:49 videbaek // Many update to the ParamemertElement and related classes for the calibration access. // // Revision 1.3 2000/05/25 16:31:01 videbaek // store latest updatex to ParameterElement classes // // Revision 1.2 2000/05/17 10:43:12 cholm // Test for reading Calibrations DB added // // Revision 1.1 2000/05/16 16:16:24 videbaek // Added the database utility classes for dealing with calibrations. // These are ParameterElement and ParamterElementManager. Each of these two // classes has intrinsic utility classes. //