GnuCash
5.6-150-g038405b370+
|
Encapsulates per-class table schema with functions to load, create a table, commit a changed front-end object (note that database transaction semantics are not yet implemented; edit/commit applies to the front-end object!) and write all front-end objects of the type to the database. More...
#include <gnc-sql-object-backend.hpp>
Public Member Functions | |
GncSqlObjectBackend (int version, const std::string &type, const std::string &table, const EntryVec &vec) | |
virtual void | load_all (GncSqlBackend *sql_be)=0 |
Load all objects of m_type in the database into memory. More... | |
virtual void | create_tables (GncSqlBackend *sql_be) |
Conditionally create or update a database table from m_col_table. More... | |
virtual bool | commit (GncSqlBackend *sql_be, QofInstance *inst) |
UPDATE/INSERT a single instance of m_type_name into the database. More... | |
virtual bool | write (GncSqlBackend *sql_be) |
Write all objects of m_type_name to the database. More... | |
const char * | type () const noexcept |
Return the m_type_name for the class. More... | |
const bool | is_version (int version) const noexcept |
Compare a version with the compiled version (m_version). More... | |
bool | instance_in_db (const GncSqlBackend *sql_be, QofInstance *inst) const noexcept |
Check the presence of an object in the backend's database. More... | |
Protected Attributes | |
const std::string | m_table_name |
const int | m_version |
const std::string | m_type_name |
const EntryVec & | m_col_table |
The front-end QofIdType. | |
Encapsulates per-class table schema with functions to load, create a table, commit a changed front-end object (note that database transaction semantics are not yet implemented; edit/commit applies to the front-end object!) and write all front-end objects of the type to the database.
Additional functions for creating and running queries existed but were unused and untested. They've been temporarily removed until the front end is ready to use them.
Definition at line 48 of file gnc-sql-object-backend.hpp.
|
virtual |
UPDATE/INSERT a single instance of m_type_name into the database.
sql_be | The GncSqlBackend containing the database. |
inst | The QofInstance to be written out. |
Reimplemented in GncSqlSplitBackend, GncSqlSlotsBackend, GncSqlRecurrenceBackend, GncSqlCommodityBackend, GncSqlTransBackend, GncSqlEmployeeBackend, GncSqlInvoiceBackend, GncSqlTaxTableBackend, GncSqlBudgetBackend, GncSqlPriceBackend, GncSqlSchedXactionBackend, GncSqlVendorBackend, and GncSqlAccountBackend.
Definition at line 33 of file gnc-sql-object-backend.cpp.
|
virtual |
Conditionally create or update a database table from m_col_table.
The condition is the version returned by querying the database's version table: If it's 0 then the table wasn't found and will be created; All tables areat least version 1. If the database's version is less than the compiled version then the table schema is upgraded but the data isn't, that's the engine's responsibility when the object is loaded. If the version is greater than the compiled version then nothing is touched.
sql_be | The GncSqlBackend containing the database connection. |
Reimplemented in GncSqlSplitBackend, GncSqlSlotsBackend, GncSqlRecurrenceBackend, GncSqlTransBackend, GncSqlBillTermBackend, GncSqlCustomerBackend, GncSqlEmployeeBackend, GncSqlEntryBackend, GncSqlInvoiceBackend, GncSqlTaxTableBackend, GncSqlBudgetBackend, GncSqlLotsBackend, and GncSqlPriceBackend.
Definition at line 74 of file gnc-sql-object-backend.cpp.
|
noexcept |
Check the presence of an object in the backend's database.
sql_be | Backend owning the database |
inst | QofInstance to be checked. |
Definition at line 89 of file gnc-sql-object-backend.cpp.
|
inlinenoexcept |
Compare a version with the compiled version (m_version).
Definition at line 95 of file gnc-sql-object-backend.hpp.
|
pure virtual |
Load all objects of m_type in the database into memory.
sql_be | The GncSqlBackend containing the database connection. |
Implemented in GncSqlSplitBackend, GncSqlSlotsBackend, GncSqlRecurrenceBackend, GncSqlCommodityBackend, GncSqlTransBackend, GncSqlBillTermBackend, GncSqlCustomerBackend, GncSqlEmployeeBackend, GncSqlEntryBackend, GncSqlInvoiceBackend, GncSqlJobBackend, GncSqlOrderBackend, GncSqlSchedXactionBackend, GncSqlTaxTableBackend, GncSqlVendorBackend, GncSqlAccountBackend, GncSqlBookBackend, GncSqlBudgetBackend, GncSqlLotsBackend, and GncSqlPriceBackend.
|
inlinenoexcept |
Return the m_type_name for the class.
This value is created at compilation time and is called QofIdType or QofIdTypeConst in other parts of GnuCash. Most values are defined in src/engine/gnc-engine.h.
Definition at line 90 of file gnc-sql-object-backend.hpp.
|
inlinevirtual |
Write all objects of m_type_name to the database.
sql_be | The GncSqlBackend containing the database. |
Reimplemented in GncSqlEmployeeBackend, GncSqlInvoiceBackend, GncSqlTaxTableBackend, GncSqlBillTermBackend, GncSqlBudgetBackend, GncSqlCustomerBackend, GncSqlEntryBackend, GncSqlPriceBackend, GncSqlVendorBackend, GncSqlJobBackend, GncSqlLotsBackend, and GncSqlOrderBackend.
Definition at line 83 of file gnc-sql-object-backend.hpp.