///////////////////////////////////////////////////////////////////////
//
// Collection of meta information about this processing.
//
// This singleton class stores the meta information. The meta
// information describes the state of RAT i.e. the rat version and the
// database settings.
//
// Producers should (if the information exists) pass the existing meta
// information to this class before any run intialises. This class on
// initialisation will create the meta information for the processing.
//
// Processings are distinguished by a pass number, with the initial
// creation being pass 0. This number then increments with each
// re-processing.
//
// Author: Phil G Jones
//
// REVISION HISTORY:
// 2014-04-18 : P G Jones - New file.
// 2016-07-20 : M. Mottram: add ROOT IO constructor for ROOT6 compatibility.
//
///////////////////////////////////////////////////////////////////////
#ifndef __RAT_MetaInformation_hh__
#define __RAT_MetaInformation_hh__
#include
class TRootIOCtor;
namespace RAT
{
class MetaHelper;
class MetaInformation
{
public:
// Singleton class instance
//
// Returns a pointer to the MetaInformation
inline static MetaInformation* Get();
// Initialise the Meta Information
//
// This should be called whenever a simulation starts or a file is reprocessed
// It will create Meta Information for the current rat instance
void Initialise();
// Initialise the Meta Information from an existing file
//
// This will create a new pass for the current rat instance
//
// meta: information to initialise from
void Initialise( DS::Meta* const meta );
// Finalise the Meta Information after the job is completed
// called by IO processors to add information about #events stored etc.
//
// helper: a container class holding some meta information to write
void Finalise(const MetaHelper& helper);
// Add a database override command to the meta information
//
// tableField: descriptor
// value is the value to override
void AddOverrideCommand( const std::string& tableField, const std::string& value );
// Add a database load command to the meta information
//
// Note that this could be a directory
//
// path is the path to load
void AddLoadCommand( const std::string& path );
// Get the meta information in DS format
//
// Returns a reference to the Meta information
const DS::Meta& GetDSMeta() const { return fMeta; }
// Get the current pass number
//
// Each processing of a file is a new pass
//
// Returns a the current pass number
size_t GetCurrentPass() const { return fMeta.GetCurrentPass(); }
// For ROOT6 build
MetaInformation(TRootIOCtor*) {};
protected:
void LoadDirectory( const std::string& directory );
void LoadFile( const std::string& file );
DS::Meta fMeta; // The actual meta information
// Prevent usage of methods below
MetaInformation() {};
};
inline MetaInformation*
MetaInformation::Get()
{
static MetaInformation metaInformation;
return &metaInformation;
}
} //::RAT
#endif