/* * DAssignment.h * * Created on: Sep 15, 2010 * Author: romanov */ #ifndef _DAssignment_ #define _DAssignment_ #include "Model/DStoredObject.h" #include "Model/DConstantsTypeTable.h" #include "Model/DObjectsOwner.h" #include #include using namespace std; namespace ccdb { class DEventRange; class DVariation; class DRunRange; class DAssignment: public DObjectsOwner, public DStoredObject { public: DAssignment(DObjectsOwner * owner=NULL, DDataProvider *provider=NULL); virtual ~DAssignment(); /** @brief creates mapped data by columns * * @param mappedData * @param columns * @return const vector > */ static bool MapData(vector > & mappedData, const vector& data, const vector& columns); /** @brief creates mapped data by columns * * @param mappedData - result * @param data - data to be mapped * @param columnsNum - * @return bool */ static bool MapData( vector > & mappedData, const vector& data, int columnsNum ); /** @brief makes array of tokens from blob * @param string blob * @return const vector& */ static void SplitData(vector& outArray,string blob); /** * @brief makes a string blob from tokens * @param const vector & values * @return std::string */ static string VectorToBlob(const vector& values); /** @brief Encodes blob separator * * if str contains '|' it will be replaced by '&pipe;' * @param string str * @return std::string */ static string EncodeBlobSeparator(string str); /** @brief Decodes blob separator * * if str contains '&pipe;' it will be replaced by '|' * * @param string str * @return std::string */ static string DecodeBlobSeparator(string str); unsigned int GetVariationId() const; /// database ID of variation void SetVariationId(unsigned int val); /// database ID of variation unsigned int GetRunRangeId() const; /// database ID of run range void SetRunRangeId(unsigned int val); /// database ID of run range unsigned int GetDataVaultId() const; /// database ID of data blob void SetDataVaultId(unsigned int val); /// database ID of data blob unsigned int GetEventRangeId() const; /// event range ID void SetEventRangeId(unsigned int val); /// event range ID int GetRequestedRun() const; /// Run than was requested for user void SetRequestedRun(int val); /// Run than was requested for user DRunRange * GetRunRange() const; /// Run range object, is NULL if not set void SetRunRange(DRunRange * val); /// Run range object, is NULL if not set DEventRange * GetEventRange() const; /// Event range object, is NULL if not set void SetEventRange(DEventRange * val); /// Event range object, is NULL if not set DVariation * GetVariation() const; /// Variation object, is NULL if not set void SetVariation(DVariation * val); /// Variation object, is NULL if not set int GetId() const { return mId; /// id in database } void SetId(int val) { mId = val; /// id in database } time_t GetCreatedTime() const { return mCreatedTime; ///Time of creation } void SetCreatedTime(time_t val) { mCreatedTime = val; ///Time of creation } time_t GetModifiedTime() const { return mModifiedTime; ///Time of last modification } void SetModifiedTime(time_t val) { mModifiedTime = val; ///Time of last modification } string GetRawData() const { return mRawData; ///Raw data blob } void SetRawData(std::string val) { mRawData = val; ///Raw data blob } vector > GetMappedData(); ///Mapped data void GetMappedData(vector > & mappedData); ///Mapped data vector GetVectorData(); ///Vector data void GetVectorData(vector & vectorData); ///Mapped data std::string GetComment() const { return mComment; ///Comment of assignment } void SetComment(std::string val) { mComment = val; ///Comment of assignment } void SetTypeTable(DConstantsTypeTable* typeTable) { this->mTypeTable = typeTable; } DConstantsTypeTable* GetTypeTable() { return mTypeTable; } private: vector > mRows; // cache for blob data by rows vector mValues; // cache for blob data by array of tokens string mRawData; // data blob int mId; // id in database int mDataBlobId; // blob id in database unsigned int mVariationId; // database ID of variation unsigned int mRunRangeId; // database ID of run range unsigned int mDataVaultId; // database ID of data blob unsigned int mEventRangeId; // event range ID int mRequestedRun; // Run than was requested for user DRunRange *mRunRange; // Run range object, is NULL if not set DEventRange *mEventRange; // Event range object, is NULL if not set DVariation *mVariation; // Variation object, is NULL if not set DConstantsTypeTable * mTypeTable; // Constants table time_t mCreatedTime; // time of creation time_t mModifiedTime; // time of last modification string mComment; // Comment of assignment DAssignment(const DAssignment& rhs); DAssignment& operator=(const DAssignment& rhs); }; } #endif /* _DAssignment_ */