#ifndef _DBOBJECT_H #define _DBOBJECT_H class TIPsDatabase; class InternetResource; #include "extensions.h" #include #include using namespace std; //allows syncing of sub-classes with the database //each sub-class has a sister SPROC which makes the entries //e.g. Product entities use the addEntity_Product() SPROC class DBObject { protected: static TIPsDatabase *m_db; const InternetResource *m_ir; //the objects know where they came from (for independent serialisation the domain id and stuff is needed) unsigned int m_id; //if the object has been synchronised with the DB //true if generated from the DB at load e.g. loadExternalEntities() //false if generated from an external source e.g. from an ObjectParser {} bool m_inDB; DBObject(TIPsDatabase *_db, const InternetResource *_ir): m_inDB(false), m_ir(_ir), m_id(0) {m_db = _db;} DBObject(TIPsDatabase *_db, const unsigned int _id): m_inDB(true), m_ir(0), m_id(_id) {m_db = _db;} public: //accessors unsigned int id() const {return m_id;} unsigned int id(const unsigned int _id) {m_inDB = true; return m_id = _id;} virtual void addToDB() {} }; #endif