GnuCash  5.6-150-g038405b370+
Public Member Functions
GncSqlRecurrenceBackend Class Reference
Inheritance diagram for GncSqlRecurrenceBackend:
GncSqlObjectBackend

Public Member Functions

 GncSqlRecurrenceBackend ()
 Recurrences are neither loadable nor committable. More...
 
void load_all (GncSqlBackend *) override
 Load all objects of m_type in the database into memory. More...
 
void create_tables (GncSqlBackend *) override
 Conditionally create or update a database table from m_col_table. More...
 
bool commit (GncSqlBackend *, QofInstance *) override
 UPDATE/INSERT a single instance of m_type_name into the database. More...
 
- Public Member Functions inherited from GncSqlObjectBackend
 GncSqlObjectBackend (int version, const std::string &type, const std::string &table, const EntryVec &vec)
 
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...
 

Additional Inherited Members

- Protected Attributes inherited from GncSqlObjectBackend
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.
 

Detailed Description

Definition at line 38 of file gnc-recurrence-sql.h.

Constructor & Destructor Documentation

◆ GncSqlRecurrenceBackend()

GncSqlRecurrenceBackend::GncSqlRecurrenceBackend ( )

Recurrences are neither loadable nor committable.

Note that the default write() implementation is also a no-op.

Definition at line 116 of file gnc-recurrence-sql.cpp.

116  :
117  GncSqlObjectBackend(TABLE_VERSION, GNC_ID_ACCOUNT, TABLE_NAME, col_table) {}
Encapsulates per-class table schema with functions to load, create a table, commit a changed front-en...

Member Function Documentation

◆ commit()

bool GncSqlRecurrenceBackend::commit ( GncSqlBackend sql_be,
QofInstance inst 
)
inlineoverridevirtual

UPDATE/INSERT a single instance of m_type_name into the database.

Parameters
sql_beThe GncSqlBackend containing the database.
instThe QofInstance to be written out.

Reimplemented from GncSqlObjectBackend.

Definition at line 44 of file gnc-recurrence-sql.h.

44 { return false; }

◆ create_tables()

void GncSqlRecurrenceBackend::create_tables ( GncSqlBackend sql_be)
overridevirtual

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.

Parameters
sql_beThe GncSqlBackend containing the database connection.

Reimplemented from GncSqlObjectBackend.

Definition at line 397 of file gnc-recurrence-sql.cpp.

398 {
399  gint version;
400 
401  g_return_if_fail (sql_be != NULL);
402 
403  version = sql_be->get_table_version( TABLE_NAME);
404  if (version == 0)
405  {
406  (void)sql_be->create_table(TABLE_NAME, TABLE_VERSION, col_table);
407  }
408  else if (version < TABLE_VERSION)
409  {
410  /* Upgrade:
411  1->2: Add recurrence_weekend_adjust field (mandatory, non-null field)
412  */
413  if (version < m_version)
414  {
415  upgrade_recurrence_table_1_2 (sql_be);
416  }
417  sql_be->set_table_version (TABLE_NAME, TABLE_VERSION);
418  PINFO ("Recurrence table upgraded from version %d to version %d\n", version,
419  TABLE_VERSION);
420  }
421 }
bool create_table(const std::string &table_name, const EntryVec &col_table) const noexcept
Creates a table in the database.
bool set_table_version(const std::string &table_name, uint_t version) noexcept
Registers the version for a table.
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:256
uint_t get_table_version(const std::string &table_name) const noexcept
Returns the version number for a DB table.

◆ load_all()

void GncSqlRecurrenceBackend::load_all ( GncSqlBackend sql_be)
inlineoverridevirtual

Load all objects of m_type in the database into memory.

Parameters
sql_beThe GncSqlBackend containing the database connection.

Implements GncSqlObjectBackend.

Definition at line 42 of file gnc-recurrence-sql.h.

42 { return; }

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