/* * dbSubsystem.hh * * Class to deal with the detector hierarchy in SQLite and MySQL DB for Hall D. * Created on: July 23, 2014 * Author: Hovanes Egiyan */ #ifndef _DBSUBSYSTEM_HH_ #define _DBSUBSYSTEM_HH_ #include #include #include #include #include #include #include using namespace std; #include "dbCrate.hh" #include "dbObject.hh" class dbSubsystem : public dbObject { private: // dbSubsystem( const dbSubsystem& subsystem ) {return;} dbSubsystem operator=( dbSubsystem& subsystem ){return *this;} protected: int id ; // id in the detector hierarchy DB int parent_id ; // paprent_id in the detector hierarchy tree string name ; // name in the detector hierarchy tree string type ; // type in the detector hierarchy tree int chanid ; // chanid in the detector hierarchy tree string mtime ; // mtime (modification time) in the detector hierarchy tree vector children ; // A list with the children of this object taken from the detector hierarchy DB dbSubsystem* parentSys ; // Reference to the parent object of the same class as self static QString sqlFindSubsysColumns; // String to find the columns for a subsystem with a known unique id static QString sqlFindChildren ; // String to find the children of the subsystem static QString sqlFindCrates ; // String to find the crate for a given channel static QString sqlFindChannels ; // String to find some usefull parameters for a channel void defineChannelParameters(); public: dbSubsystem( string uri, int subsystemID = 0, dbSubsystem* parent = 0 ); // dbSubsystem( int subsystemID = 0, string uri ); virtual ~dbSubsystem(); // virtual map > findCrates(); // Find crates for this subsystem virtual map > findChannels(); // Get all the channels for this subsystem virtual vector getChannelVector(); // Get all the channels for this subsystem vector getCrateVector(); // Get all crates for this subsystem virtual string printToStream( ostream& stream ); // Print to output stream virtual vector findChildren(); // Find children subsystems of this subsystem object virtual string getFullPath( string separator = "->" ); // return the full path to this object virtual string getRootName(); // return the name of the top level subsystem virtual inline int getID() { return id; } virtual inline int getParentID() {return parent_id;} virtual inline string getName() {return name;} virtual inline string getType() {return type;} virtual inline int getChanID() {return chanid;} virtual inline string getModTime() {return mtime;} virtual inline vector getChildrenVector() { return children; } virtual inline dbSubsystem* getParentPointer() { return parentSys; } }; // A class for exceptions inherited from string struct NoCrateException : public std::exception { std::string s; NoCrateException(std::string ss) : s(ss) {} ~NoCrateException() throw () {} // Updated const char* what() const throw() { return s.c_str(); } }; #endif /* _DBSUBSYSTEM_HH_ */