EMdF database

Overview

The EMdF database classes are structured in the following hierarchy:

  • EMdFDB
    • PgEMdFDB
    • MySQLEMdFDB

Boolean return value

For the functions which return a boolean, the return value generally means the following:

  • true: No error.
  • false: An error occurred. Use the error interface to get to know what the error was. The values of any reference parameters which should have returned something are undefined.

The only exceptions to this rule are the transaction interface methods and the ConnectionOk() method.

C++ interface

emdfdb.h


#include <emdros/emdfdb.h>

class CEMdFDBException {};
class CEMdFDBDBError : public CEMdFDBException {};

class EMdFDB {
public:
  //
  // Construction and destruction
  EMdFDB();
  virtual ~EMdFDB();        

  // Get backend-name
  static std::string BackendName(void);

  //
  // Database manipulation
  virtual bool UseDatabase(const std::string{PREAMP} db_name);
  virtual bool DatabaseExists(const std::string{PREAMP} db_name, bool{PREAMP} result);

  // Segment manipulation
  virtual bool ThereAreSegments(/* out */ bool{PREAMP} Result);
  virtual bool SegmentExists(const std::string{PREAMP} segment_name, 
                             /* out */ bool{PREAMP} Result,
			     /* out */ monad_m{PREAMP} first,
			     /* out */ monad_m{PREAMP} last);

  // min_m and max_m
  bool Get_min_m(monad_m{PREAMP} /* out */ min_m);
  bool Get_max_m(monad_m{PREAMP} /* out */ max_m);
  bool Get_all_m_1(CSet_of_monad_ms{PREAMP} /* out */ all_m_1);

  // Indices
  bool CreateIndicesOnDatabase(const std::string{PREAMP} database_name);
  bool DropIndicesOnDatabase(const std::string{PREAMP} database_name);
  bool CreateIndicesOnObjectType(const std::string{PREAMP} object_type_name);
  bool DropIndicesOnObjectType(const std::string{PREAMP} object_type_name);
  bool CreateIndicesOnObjectType(const std::string{PREAMP} database_name, const std::string{PREAMP} object_type_name);
  bool DropIndicesOnObjectType(const std::string{PREAMP} database_name, const std::string{PREAMP} object_type_name);
    

  // DB maintenance
  virtual bool Vacuum(bool bAnalyze);

  // Transactions
  virtual bool BeginTransaction(void);
  virtual bool CommitTransaction(void);
  virtual bool AbortTransaction(void);

  //
  // Error messages
  virtual std::string ErrorMessage(void);
  virtual bool ConnectionOk(void);
  void clear_local_error(void);
  std::string get_local_error(void);

};

PgEMdFDB


#include <emdros/pgemdfdb.h>

class PgEMdFDB : public EMdFDB {
public:
  PgEMdFDB(std::string host,         // Hostname to connect to 
                                     // (e.g., "localhost"),
           std::string user,         // PostgreSQL user (e.g., "emdf")
           std::string passwd,       // PostgreSQL password (e.g., "changeme"),
           std::string database_name // Initial database to connect to 
                                     // (e.g., "emdf").
          );
  virtual ~PgEMdFDB();
};


MySQLEMdFDB


#include <emdros/mysqlemdfdb.h>

class MySQLEMdFDB : public EMdFDB {
public:
  MySQLEMdFDB(std::string host,         // Hostname to connect to 
                                        // (e.g., "localhost"),
              std::string user,         // MySQL user (e.g., "emdf")
              std::string passwd,       // MySQL password (e.g., "changeme"),
              std::string database_name // Initial database to connect to 
                                        // (e.g., "emdf").
             );
  virtual ~MySQLEMdFDB();
};



Previous:CEMdFOutput
Up:Part II: APIs
Next:Transactions