/* * TableHeader.h * * Created on: Sep 15, 2010 * Author: romanov */ #ifndef TABLEHEADER_H_ #define TABLEHEADER_H_ #include #include "DDirectory.h" #include "DStoredObject.h" #include "DConstantsTypeColumn.h" #include "DObjectsOwner.h" #include "DConstantsTypeColumn.h" using namespace std; namespace ccdb { //class DConstantsTypeColumn; class DConstantsTypeTable: public DObjectsOwner, public DStoredObject { friend class DDataProvider; public: DConstantsTypeTable(DObjectsOwner * owner=NULL, DDataProvider *provider=NULL); virtual ~DConstantsTypeTable(); void SetDirectory(DDirectory *directory); /// Parent directory reference DDirectory * GetDirectory() const; /// Parent directory reference void SetDirectoryId(int directoryId);/// Parent directory id int GetDirectoryId() const; /// Parent directory id void SetFullPath(string fFullPath); /// full path string GetFullPath() const; /// full path void SetId(dbkey_t id); /// database Id int GetId() const; /// database Id void SetName(const string& name); /// name string GetName() const; /// name std::string GetComment() const; ///set comment void SetComment(const string& val); ///get comment time_t GetCreatedTime() const; /// Time when was created void SetCreatedTime(time_t val); /// Time when was created time_t GetModifiedTime() const; /// Time when last updated void SetModifiedTime(time_t val); /// Time when last updated int GetNRows() const; ///Number of rows void SetNRows(int val); ///Number of rows /** @brief GetNColumns * The function check if the table contains columns objects (mColumns.count() >0) and return * the number of stored columns objects. * If the table was loaded form DB AND(!) columns objects == 0, it return GetNColumnsFromDB * * This behavior made in assumption that there are only two cases possible: * 1) The table is loaded from DB (may be without columns) * 2) The table is created to add to DB. * because no updates with adding a column is possible. * @return int */ int GetNColumns() const; int GetNColumnsFromDB() const; /// Value of nColumns of constantType table in DB void SetNColumnsFromDB(int val); /// Value of nColumns of constantType table in DB /** @brief Gets vector containing all columns * * @return const vector& */ const vector& GetColumns() const; /** @brief Adds Column to array * * @param DConstantsTypeColumn * col * @param int order * @return void */ void AddColumn(DConstantsTypeColumn *col, int order); /** @brief Adds Column to array and sets order to it as in array * * @warning it DOES change column mOrder member * * @param DConstantsTypeColumn * col * @param int order * @return void */ void AddColumn(DConstantsTypeColumn *col); /** * @brief Adds Column to array and sets order to it as in array * @param name * @param type */ void AddColumn(const string& name, DConstantsTypeColumn::DColumnTypes type=DConstantsTypeColumn::cDoubleColumn); /** @brief RemoveColumn with order * * @param int order * @return void */ DConstantsTypeColumn * RemoveColumn(int order); /** @brief clear columns * * @return void */ void ClearColumns(); vector GetColumnNames() const; vector GetColumnTypeStrings() const; private: string mName; //Name of the table of constants string mFullPath; //Full path of the constant DDirectory *mDirectory; //Link to the directory that holds this constant int mDirectoryId; //Parent directory ID in the DB dbkey_t mId; //db id string mComment; //comment time_t mCreatedTime; //creation time time_t mUpdateTime; //update time string mDescription; //description int mNRows; // Number of rows int mNColumnsFromDB;// Value of nColumns of constantType table in DB vector mColumns; //Columns object DConstantsTypeTable(const DConstantsTypeTable& rhs); DConstantsTypeTable& operator=(const DConstantsTypeTable& rhs); }; } //namespace ccdb #endif /* TABLEHEADER_H_ */