The base class for all C++ classes that can be stored in the database. More...
|DBFieldBase *||getField (size_t i)|
|const DBFieldBase *||getField (size_t i) const|
|DBFieldBase *||getField (std::string name)|
|const DBFieldBase *||getField (std::string name) const|
|bool||getForeignKey (std::string table, const DBFieldBase *&key) const|
|Returns the name of the foreign key column in a given table that references our primary key. |
|bool||getForeignKey (std::string table, DBFieldBase *&key)|
|size_t||getNumFields () const|
|DBFieldBase *||getPrimaryKeyField ()|
|const DBFieldBase *||getPrimaryKeyField () const|
|void||setAllFieldsReadFromDatabase (bool sync)|
|void||setAllFieldsWriteToDatabase (bool sync)|
|std::vector< DBFieldBase * >||fields_|
|The addresses of all the other fields. |
|std::map< std::string, |
DBFieldBase * >
|List of foreign keys in OTHER tables that reference our PRIMARY KEY. |
|The address of the field that acts as a primary key. |
|DBClass &||operator= (const DBClass &rhs)|
|Makes the class non-assignable. |
The base class for all C++ classes that can be stored in the database.
A DBClass is a collection of fields.
One of the fields is marked as a primary key, which is the only unique identifier for this class. The primary key field is expected to reference the primary key column in the main table where this class is stored in the database.
All the other fields are expected to be stored either in the same table as the primary key, or in other tables that reference our primary key in a foreign key column.
To use this class, any data members that you want to save / load from database must be declared as DBFields. Then, IN THE CONSTRUCTOR, you must tell this interface which of them is the primary key, and store the rest in the fields_ vector. After this, all database functionality will be automagically done for you.
Also in the contructor you can set which fields are read from / written to the database by default, and which should be only when you specifically ask for them
For an example, see the DatabaseOriginalModel implementation.
|const DBFieldBase *&||key|
|size_t database_interface::DBClass::getNumFields||(||)|| const