Public Member Functions | Public Attributes | List of all members
database_interface::DatabaseTestObject Class Reference

The C++ version of an object stored in a database. More...

#include <database_test_object.h>

Inheritance diagram for database_interface::DatabaseTestObject:
Inheritance graph
[legend]

Public Member Functions

 DatabaseTestObject ()
 Constructs the fields, then calls initFields() followed by initPermissions() More...
 
 DatabaseTestObject (const DatabaseTestObject *other)
 Copy-constructs the fields based on the copied instance fields, then calls initFields() More...
 
void initFields ()
 Places all the fields in the fields_ vector and sets foreign keys and sequences. More...
 
void initPermissions ()
 Initializes permissions for the fields. More...
 
- Public Member Functions inherited from database_interface::DBClass
 DBClass ()
 
DBFieldBasegetField (size_t i)
 
const DBFieldBasegetField (size_t i) const
 
DBFieldBasegetField (std::string name)
 
const DBFieldBasegetField (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. More...
 
bool getForeignKey (std::string table, DBFieldBase *&key)
 
size_t getNumFields () const
 
DBFieldBasegetPrimaryKeyField ()
 
const DBFieldBasegetPrimaryKeyField () const
 
void setAllFieldsReadFromDatabase (bool sync)
 
void setAllFieldsWriteToDatabase (bool sync)
 

Public Attributes

DBField< std::vector< char > > binary_field_
 
DBField< double > double_field_
 
DBField< int > foreign_field_
 
DBField< int > pk_field_
 
DBField< std::string > string_field_
 
DBField< std::vector
< std::string > > 
tags_field_
 

Additional Inherited Members

- Protected Attributes inherited from database_interface::DBClass
std::vector< DBFieldBase * > fields_
 The addresses of all the other fields. More...
 
std::map< std::string,
DBFieldBase * > 
foreign_keys_
 List of foreign keys in OTHER tables that reference our PRIMARY KEY. More...
 
DBFieldBaseprimary_key_field_
 The address of the field that acts as a primary key. More...
 

Detailed Description

The C++ version of an object stored in a database.

Note that:

Definition at line 48 of file database_test_object.h.

Constructor & Destructor Documentation

database_interface::DatabaseTestObject::DatabaseTestObject ( )
inline

Constructs the fields, then calls initFields() followed by initPermissions()

Note that:

  • all fields are intialized with the type, owner (this), column name and table name

Definition at line 110 of file database_test_object.h.

database_interface::DatabaseTestObject::DatabaseTestObject ( const DatabaseTestObject other)
inline

Copy-constructs the fields based on the copied instance fields, then calls initFields()

The data itself in the fields, as well as the permissions, gets copied in the field copy construction.

Definition at line 127 of file database_test_object.h.

Member Function Documentation

void database_interface::DatabaseTestObject::initFields ( )
inline

Places all the fields in the fields_ vector and sets foreign keys and sequences.

Note that:

  • the address of the id_ field is noted as primary key
  • the addresses of all the other fields are stored in fields_
  • all the needed foreign keys are inserted for referencing fields that live in different table than out primary key
  • the sequence name used by our primary key field is noted

Definition at line 70 of file database_test_object.h.

void database_interface::DatabaseTestObject::initPermissions ( )
inline

Initializes permissions for the fields.

Note that:

  • default behavior is set for which fields are to be read from / written to the database. That this can always be changed later for any particular instance of this class, if you want to save or load any particular fields.

Definition at line 94 of file database_test_object.h.

Member Data Documentation

DBField< std::vector<char> > database_interface::DatabaseTestObject::binary_field_

Definition at line 58 of file database_test_object.h.

DBField<double> database_interface::DatabaseTestObject::double_field_

Definition at line 54 of file database_test_object.h.

DBField<int> database_interface::DatabaseTestObject::foreign_field_

Definition at line 60 of file database_test_object.h.

DBField<int> database_interface::DatabaseTestObject::pk_field_

Definition at line 52 of file database_test_object.h.

DBField<std::string> database_interface::DatabaseTestObject::string_field_

Definition at line 55 of file database_test_object.h.

DBField< std::vector<std::string> > database_interface::DatabaseTestObject::tags_field_

Definition at line 56 of file database_test_object.h.


The documentation for this class was generated from the following file:


database_interface
Author(s): Matei Ciocarlie and Lorenz Mosenlechner
autogenerated on Mon Mar 2 2015 01:31:34