Skip to content
David Sarrut edited this page Jul 23, 2015 · 2 revisions

namespace

query

When query a database, could use the words get, select, query or find. We decided to keep query because odb use it. We use find when it is a table specific query (FindPatient).

classes organisation

  • (prevent Record to be created outside a pointer)

Base class syd::Database

All database type in inherit from this class (in particular syd::StandardDatabase). This is an abstract class. Any class inheriting from syd::Database must implement CreateTables, with a calls to AddTable<MyRecord>, this will define the tables.

Common functions to all databases:

  • Dump
  • New
  • Insert
  • Set
  • Find -fixme

base class Table

Inherit from TableBase. Automated class for a new Record type. Created by AddTable

  • class syd::Record base class for all table

Record type

Inherit from syd::Record, automatically get an id. Need to define:

    friend class odb::access;
    typedef std::shared_ptr<TABLE_NAME> pointer;
    typedef std::vector<pointer> vector;

    virtual std::string GetTableName() const { return #TABLE_NAME; }
    static std::string GetStaticTableName() { return #TABLE_NAME; }

    static pointer New() { return pointer(new TABLE_NAME); }

    virtual std::string ToString() const;

    virtual bool IsEqual(const pointer p) const;
    virtual void CopyFrom(const pointer p);
    virtual void Sort(vector & v, const std::string & order);

    virtual void Set(const syd::Database * db, const std::vector<std::string> & args);
    virtual void InitPrintTable(const syd::Database * db, syd::PrintTable & ta, const std::string & format) const;
    virtual void DumpInTable(const syd::Database * db, syd::PrintTable & ta, const std::string & format) const;

misc

Clone this wiki locally