#ifndef TOARuntimeParameters_hxx_seen #define TOARuntimeParameters_hxx_seen #include "TString.h" #include #include #include #include #include #include "IUnitsTableParser.hxx" #include "ICOMETLog.hxx" #include namespace COMET { // General DummyDatabase exceptions OA_EXCEPTION(EOARuntimeParameters,COMET::EoaCore); // Exception for missing database parameter OA_EXCEPTION(ENonexistantDatabaseParameter,EOARuntimeParameters); // Exception for reading parameter file OA_EXCEPTION(EBadParameterFile,EOARuntimeParameters); class IOARuntimeParameters; }; /// This class is meant to provide access to a set of parameters /// that are defined in a set of text files; in particular, the text files /// are used to store 'software runtime parameters' in calibration and /// reconstruction algorithms. class COMET::IOARuntimeParameters { public: ~IOARuntimeParameters(); /// Get a reference to the singleton instance of dummy /// database information. If this is first attempt at reference /// then singleton is instantiated and parameters are /// read from text files. static COMET::IOARuntimeParameters& Get(void) { if (!fTOARuntimeParameters) fTOARuntimeParameters = new IOARuntimeParameters(); return *fTOARuntimeParameters; } /// Check if Parameter is stored in database bool HasParameter(std::string); /// Get parameter. Value is returned as integer. int GetParameterI(std::string); /// Get parameter. Value is returned as double. double GetParameterD(std::string); /// Get parameter. Value is returned as string. std::string GetParameterS(std::string); void ClearMapOfTOARuntimeParameters(); COMET::IUnitsTableParser* GetUnitsTableParser(){ return fUnitsTableParser; } /// This command allows the user to set parameters from the /// command line; the command is different from the standard /// file reading, in that the parameters that are set are 'fixed'. /// Ie, they are immutable and cannot be changed, even if they /// exist in some other parameters file that is read in later. void ReadParamOverrideFile(TString filename); private: IOARuntimeParameters(); // Add a non-functional private copy constructor. IOARuntimeParameters(const IOARuntimeParameters &){ COMETLog("IOARuntimeParameters copy constructor is private. Shouldn't be called!!!"); } /// Reads parameters from input files. /// Function can be used to read in extra parameter files. void ReadInputFile(TString filename, TString dirName="", bool tryFile = false, bool fixParameters = false); /// Prints list of saved parameters void PrintListOfParameters(); /// Helper method to attempt to read parameters file based on parameters name. /// The return value indicates whether we can now find this parameter after /// trying to open this file (return 1 means parameter found). int TryLoadingParametersFile(std::string parameterName); /// map containing list of parameters and their values. std::map > mapOfTOARuntimeParameters; typedef std::map >::iterator mapIterator; /// A set of all the 'fixed'. 'Fixed' parameters cannot be changed, even if they reappear /// in a different parameters file. This is used for the parameter override files. std::set fixedParameters; COMET::IUnitsTableParser *fUnitsTableParser; /// The static pointer to the singleton instance. static IOARuntimeParameters* fTOARuntimeParameters; }; #endif