Main MRPT website > C++ reference for MRPT 1.4.0
List of all members | Public Member Functions | Private Types | Private Attributes
mrpt::utils::CSimpleDatabase Class Reference

Detailed Description

This class impements a very simple database system.

A database is a collection of tables, each one being a CSimpleDatabaseTable object. Tables are a rectangular arrrangement of cells, organized as records of fields. There are XML export/import methods in saveAsXML, loadFromXML.

Note
This class is NOT safe for read/write access from different threads. If needed, use critical sections.
See also
CSimpleDatabaseTable

Definition at line 122 of file CSimpleDatabase.h.

#include <mrpt/utils/CSimpleDatabase.h>

Inheritance diagram for mrpt::utils::CSimpleDatabase:
Inheritance graph

Public Member Functions

 CSimpleDatabase ()
 Default constructor.
 
virtual ~CSimpleDatabase ()
 Destructor.
 
void clear ()
 Clears the DB.
 
CSimpleDatabaseTablePtr createTable (const std::string &name)
 Creates a new table in the DB, initially empty.
 
CSimpleDatabaseTablePtr getTable (const std::string &tableName)
 Returns the table with the indicated name.
 
void dropTable (const std::string &tableName)
 Deletes the given table.
 
void renameTable (const std::string &tableName, const std::string &newTableName)
 Changes the name of a given table.
 
CSimpleDatabaseTablePtr getTable (size_t tableIndex)
 Returns the table by index.
 
size_t tablesCount () const
 Returns the tables count in the DB.
 
std::string tablesName (size_t tableIndex) const
 Returns the tables names in the DB.
 
bool saveAsXML (const std::string &fileName) const
 Saves this database as a XML file.
 
bool loadFromXML (const std::string &fileName)
 Loads the content of this database from a a XML file.
 

Protected Member Functions

CSerializable virtual methods
void writeToStream (mrpt::utils::CStream &out, int *getVersion) const MRPT_OVERRIDE
 
void readFromStream (mrpt::utils::CStream &in, int version) MRPT_OVERRIDE
 

Private Types

typedef std::map< std::string, CSimpleDatabaseTablePtrTTableList
 The tables of the DB indexed by their names:
 
typedef std::map< std::string, CSimpleDatabaseTablePtr >::iterator iterator
 
typedef std::map< std::string, CSimpleDatabaseTablePtr >::const_iterator const_iterator
 

Private Attributes

TTableList m_tables
 

RTTI stuff <br>

typedef CSimpleDatabasePtr SmartPtr
 
static mrpt::utils::CLASSINIT _init_CSimpleDatabase
 
static mrpt::utils::TRuntimeClassId classCSimpleDatabase
 
static const mrpt::utils::TRuntimeClassIdclassinfo
 
static const mrpt::utils::TRuntimeClassId_GetBaseClass ()
 
virtual const mrpt::utils::TRuntimeClassIdGetRuntimeClass () const MRPT_OVERRIDE
 
virtual mrpt::utils::CObjectduplicate () const MRPT_OVERRIDE
 
static mrpt::utils::CObjectCreateObject ()
 
static CSimpleDatabasePtr Create ()
 

Member Typedef Documentation

◆ const_iterator

Definition at line 193 of file CSimpleDatabase.h.

◆ iterator

Definition at line 192 of file CSimpleDatabase.h.

◆ SmartPtr

A typedef for the associated smart pointer

Definition at line 125 of file CSimpleDatabase.h.

◆ TTableList

typedef std::map<std::string, CSimpleDatabaseTablePtr> mrpt::utils::CSimpleDatabase::TTableList
private

The tables of the DB indexed by their names:

Definition at line 191 of file CSimpleDatabase.h.

Constructor & Destructor Documentation

◆ CSimpleDatabase()

mrpt::utils::CSimpleDatabase::CSimpleDatabase ( )

Default constructor.

◆ ~CSimpleDatabase()

virtual mrpt::utils::CSimpleDatabase::~CSimpleDatabase ( )
virtual

Destructor.

Member Function Documentation

◆ _GetBaseClass()

static const mrpt::utils::TRuntimeClassId * mrpt::utils::CSimpleDatabase::_GetBaseClass ( )
staticprotected

◆ clear()

void mrpt::utils::CSimpleDatabase::clear ( )

Clears the DB.

◆ Create()

static CSimpleDatabasePtr mrpt::utils::CSimpleDatabase::Create ( )
static

◆ CreateObject()

static mrpt::utils::CObject * mrpt::utils::CSimpleDatabase::CreateObject ( )
static

◆ createTable()

CSimpleDatabaseTablePtr mrpt::utils::CSimpleDatabase::createTable ( const std::string &  name)

Creates a new table in the DB, initially empty.

References mrpt::utils::CSimpleDatabaseTablePtr.

◆ dropTable()

void mrpt::utils::CSimpleDatabase::dropTable ( const std::string &  tableName)

Deletes the given table.

Exceptions
std::exceptionOn table not found.

◆ duplicate()

virtual mrpt::utils::CObject * mrpt::utils::CSimpleDatabase::duplicate ( ) const
virtual

◆ GetRuntimeClass()

virtual const mrpt::utils::TRuntimeClassId * mrpt::utils::CSimpleDatabase::GetRuntimeClass ( ) const
virtual

◆ getTable() [1/2]

CSimpleDatabaseTablePtr mrpt::utils::CSimpleDatabase::getTable ( const std::string &  tableName)

Returns the table with the indicated name.

Exceptions
std::exceptionOn table not found.

References mrpt::utils::CSimpleDatabaseTablePtr.

◆ getTable() [2/2]

CSimpleDatabaseTablePtr mrpt::utils::CSimpleDatabase::getTable ( size_t  tableIndex)

Returns the table by index.

Exceptions
std::exceptionOn index out of bounds

References mrpt::utils::CSimpleDatabaseTablePtr.

◆ loadFromXML()

bool mrpt::utils::CSimpleDatabase::loadFromXML ( const std::string &  fileName)

Loads the content of this database from a a XML file.

Returns
false on any error, true if successful.
See also
saveAsXML

◆ readFromStream()

void mrpt::utils::CSimpleDatabase::readFromStream ( mrpt::utils::CStream in,
int  version 
)
protected

◆ renameTable()

void mrpt::utils::CSimpleDatabase::renameTable ( const std::string &  tableName,
const std::string &  newTableName 
)

Changes the name of a given table.

Exceptions
std::exceptionOn table not found or new name already existed.

◆ saveAsXML()

bool mrpt::utils::CSimpleDatabase::saveAsXML ( const std::string &  fileName) const

Saves this database as a XML file.

Returns
false on any error, true if successful.
See also
loadFromXML

◆ tablesCount()

size_t mrpt::utils::CSimpleDatabase::tablesCount ( ) const

Returns the tables count in the DB.

◆ tablesName()

std::string mrpt::utils::CSimpleDatabase::tablesName ( size_t  tableIndex) const

Returns the tables names in the DB.

Exceptions
std::exceptionOn index out of bounds

◆ writeToStream()

void mrpt::utils::CSimpleDatabase::writeToStream ( mrpt::utils::CStream out,
int *  getVersion 
) const
protected

Member Data Documentation

◆ _init_CSimpleDatabase

mrpt::utils::CLASSINIT mrpt::utils::CSimpleDatabase::_init_CSimpleDatabase
staticprotected

Definition at line 125 of file CSimpleDatabase.h.

◆ classCSimpleDatabase

mrpt::utils::TRuntimeClassId mrpt::utils::CSimpleDatabase::classCSimpleDatabase
static

Definition at line 125 of file CSimpleDatabase.h.

◆ classinfo

const mrpt::utils::TRuntimeClassId* mrpt::utils::CSimpleDatabase::classinfo
static

Definition at line 125 of file CSimpleDatabase.h.

◆ m_tables

TTableList mrpt::utils::CSimpleDatabase::m_tables
private

Definition at line 195 of file CSimpleDatabase.h.




Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Wed Mar 22 04:35:51 UTC 2023