Overture  Version 25
Public Types | Public Member Functions | List of all members
DBase::DataBase Class Reference

the actual database class, uses a stl map for actual data storage/retrieval More...

#include <DBase.hh>

Public Types

typedef void(* EntryProcessingFunction )(std::string, Entry &)
 typedef for function to apply to all elements
 
typedef dbtype::iterator iterator
 
typedef dbtype::const_iterator const_iterator
 

Public Member Functions

 DataBase ()
 create an empty database
 
 DataBase (const DataBase &d)
 copy a database
 
virtual ~DataBase ()
 destroy a database and its information
 
virtual void clear ()
 destroy a databae and its information
 
template<typename T >
T & put (std::string name, const T &entry, void(*entry_destructor)(T &)=0)
 put an item into the database, return a reference to the data
 
template<typename T >
T & put (std::string name, void(*entry_destructor)(T &)=0)
 This version of put does not initialize the entry.
 
template<typename T >
T & get (std::string name)
 get a reference to something in the database
 
template<typename T >
const T & get (std::string name) const
 get a const reference to something in the database
 
const KK::sptr< EntrygetEntry (std::string name) const
 
void remove (std::string name)
 remove an item from the database
 
void toggleTrait (std::string name, int t)
 toggle a trait for a particular entry, default state is off
 
bool traitActive (std::string name, int t)
 return true if the trait t is active for entry name
 
bool has_key (std::string name) const
 return true if the database has an entry with this name
 
size_t size () const
 return the number of entries in the database
 
void processEntries (EntryProcessingFunction func)
 process all entries with the function func
 
template<class F >
void processEntries (F &func)
 process all entries with a function class
 
template<class F >
void processEntries (const F &func)
 process all entries with a function class
 
void merge (DataBase &db_in) throw (DBErr)
 merge the contents of a database into this one; if there is a name conflict throw an error
 
void link (DataBase &from, std::string from_nm, std::string to_nm)
 link an entry of one database to an entry in the current database with a new name.
 
void link (DBase::EntryP &from, std::string to_nm)
 link an entry pointer to an entry in the current database with a new name.
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 

Detailed Description

the actual database class, uses a stl map for actual data storage/retrieval

Member Typedef Documentation

typedef dbtype::const_iterator DBase::DataBase::const_iterator
typedef void(* DBase::DataBase::EntryProcessingFunction)(std::string, Entry &)

typedef for function to apply to all elements

typedef dbtype::iterator DBase::DataBase::iterator

Constructor & Destructor Documentation

DBase::DataBase::DataBase ( )
inline

create an empty database

DBase::DataBase::DataBase ( const DataBase d)
inline

copy a database

Parameters
ddatabase to be copied
virtual DBase::DataBase::~DataBase ( )
inlinevirtual

destroy a database and its information

References clear().

Member Function Documentation

iterator DBase::DataBase::begin ( )
inline
const_iterator DBase::DataBase::begin ( ) const
inline
virtual void DBase::DataBase::clear ( )
inlinevirtual

destroy a databae and its information

Referenced by ~DataBase().

iterator DBase::DataBase::end ( )
inline
const_iterator DBase::DataBase::end ( ) const
inline
template<typename T >
T& DBase::DataBase::get ( std::string  name)
inline
template<typename T >
const T& DBase::DataBase::get ( std::string  name) const
inline

get a const reference to something in the database

References KK::sptr_dynamic_cast().

const KK::sptr< Entry > DBase::DataBase::getEntry ( std::string  name) const
inline
bool DBase::DataBase::has_key ( std::string  name) const
inline
void DBase::DataBase::link ( DataBase from,
std::string  from_nm,
std::string  to_nm 
)
inline

link an entry of one database to an entry in the current database with a new name.

link allows the manual merge of two databases when there are possible name conflicts. The user can provide a new name to use in the current instance.

References has_key().

void DBase::DataBase::link ( DBase::EntryP from,
std::string  to_nm 
)
inline

link an entry pointer to an entry in the current database with a new name.

link allows the manual merge of two databases when there are possible name conflicts. The user can provide a new name to use in the current instance.

References has_key().

void DBase::DataBase::merge ( DataBase db_in) throw (DBErr)
inline

merge the contents of a database into this one; if there is a name conflict throw an error

References has_key().

void DBase::DataBase::processEntries ( EntryProcessingFunction  func)
inline

process all entries with the function func

template<class F >
void DBase::DataBase::processEntries ( F func)
inline

process all entries with a function class

template<class F >
void DBase::DataBase::processEntries ( const F func)
inline

process all entries with a function class

template<typename T >
T& DBase::DataBase::put ( std::string  name,
const T &  entry,
void(*)(T &)  entry_destructor = 0 
)
inline

put an item into the database, return a reference to the data

Parameters
namethe name of the entry in the database
entrya COPY of this data will be stored in the database
entry_destructoran optional callback to destroy the data

An entry containing a COPY of the data is placed into the database. If entry is not provided, a new instance of the specified type is created using the type's default constructor. An optional destructor callback for entry can be provided by passing a pointer to a function returning void and taking one argument of type reference to T.

The method returns a reference to the data stored in the database.

sample usage: DBase::DataBase db; int &i = db.put("i",10); // create an int entry named "i" with value 10 int &j = db.put<int>("j"); // create an uninitialized int at entry "j" // below, place a pointer to a Foo object and provide a destructor db.put("a foo object ptr", aFooObjectPtr, fooOpjectDestructor);

References KK::sptr_dynamic_cast().

Referenced by BodyForce::BodyForce(), BodyForceRegionParameters::BodyForceRegionParameters(), BodyForce::get(), ShowFilePlotter::plot(), and BodyForce::plotForcingRegions().

template<typename T >
T& DBase::DataBase::put ( std::string  name,
void(*)(T &)  entry_destructor = 0 
)
inline

This version of put does not initialize the entry.

References KK::sptr_dynamic_cast().

void DBase::DataBase::remove ( std::string  name)
inline

remove an item from the database

size_t DBase::DataBase::size ( ) const
inline

return the number of entries in the database

void DBase::DataBase::toggleTrait ( std::string  name,
int  t 
)
inline

toggle a trait for a particular entry, default state is off

bool DBase::DataBase::traitActive ( std::string  name,
int  t 
)
inline

return true if the trait t is active for entry name


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