24 #ifndef __GNC_SQL_OBJECT_BACKEND_HPP__ 25 #define __GNC_SQL_OBJECT_BACKEND_HPP__ 35 using GncSqlColumnTableEntryPtr = std::shared_ptr<GncSqlColumnTableEntry>;
36 using EntryVec = std::vector<GncSqlColumnTableEntryPtr>;
38 #define GNC_SQL_BACKEND "gnc:sql:1" 52 const std::string&
table,
const EntryVec& vec) :
53 m_table_name{
table}, m_version{version}, m_type_name{
type},
90 const char*
type () const noexcept {
return m_type_name.c_str(); }
96 return version == m_version;
107 const std::string m_table_name;
109 const std::string m_type_name;
113 using GncSqlObjectBackendPtr = std::shared_ptr<GncSqlObjectBackend>;
115 using OBEEntry = std::tuple<std::string, GncSqlObjectBackendPtr>;
116 using OBEVec = std::vector<OBEEntry>;
128 be{sql_be}, is_ok{o}, obe{e} {}
130 if (is_ok) is_ok = obe->
commit (be, inst);
138 #endif //__GNC_SQL_OBJECT_BACKEND_HPP__ const EntryVec & m_col_table
The front-end QofIdType.
virtual bool write(GncSqlBackend *sql_be)
Write all objects of m_type_name to the database.
virtual void load_all(GncSqlBackend *sql_be)=0
Load all objects of m_type in the database into memory.
const bool is_version(int version) const noexcept
Compare a version with the compiled version (m_version).
const char * type() const noexcept
Return the m_type_name for the class.
Encapsulates per-class table schema with functions to load, create a table, commit a changed front-en...
virtual bool commit(GncSqlBackend *sql_be, QofInstance *inst)
UPDATE/INSERT a single instance of m_type_name into the database.
Data-passing struct for callbacks to qof_object_foreach() used in GncSqlObjectBackend::write().
virtual void create_tables(GncSqlBackend *sql_be)
Conditionally create or update a database table from m_col_table.
Contains all of the information required to copy information between an object and the database for a...
Main SQL backend structure.
bool instance_in_db(const GncSqlBackend *sql_be, QofInstance *inst) const noexcept
Check the presence of an object in the backend's database.