#include <VICUS_Database.h>
template<typename T>
class VICUS::Database< T >
Wrapper class for different databases. Template argument classes must provide a public bool member m_builtIn, and the functions readXML(const TiXmlElement * element) and writeXML(TiXmlElement * parent) const.
Usage:
m. .... set parameters
unsigned ínt newId = materials.
add(m);
Definition VICUS_Database.h:57
unsigned int add(T &newData, unsigned int suggestedId=0)
Definition VICUS_Database.h:139
Definition VICUS_Material.h:44
◆ Database()
◆ add()
template<typename T >
unsigned int VICUS::Database< T >::add |
( |
T & |
newData, |
|
|
unsigned int |
suggestedId = 0 |
|
) |
| |
|
inline |
Adds a new item to the database.
- Parameters
-
newData | New object to be added. |
suggestedId | ID of object to insert (possibly when adding this data object from a project file), or 0, if object was newly created and needs a new ID anyway. |
- Note
- New items are never built-in and will be local DB elements, automatically.
◆ begin() [1/2]
Returns begin for iterator-type access to data store.
◆ begin() [2/2]
template<typename T >
std::map< unsignedint, T >::const_iterator VICUS::Database< T >::begin |
( |
| ) |
const |
|
inline |
Returns begin for iterator-type read-only access to data store.
◆ clearChildren()
Local utility function which clears parents and children references using const cast
◆ empty()
Returns true if database is empty.
◆ end() [1/2]
Returns end for iterator-type access to data store.
◆ end() [2/2]
template<typename T >
std::map< unsignedint, T >::const_iterator VICUS::Database< T >::end |
( |
| ) |
const |
|
inline |
Returns end for iterator-type read-only access to data store.
◆ findEqual()
Tries to find an element in the DB that matches content-wise the provided element (i.e. ignores ID during comparison, calls T::equal()).
- Returns
- Returns nullptr if no such element exists, otherwise a pointer to the respective existing element.
◆ import()
Imports elements from other DB that do not yet exist in current DB. The imported DB is expected to holds only IDs that are not yet present in the current DB. For each element with duplicate ID a warning message is issued in IBK_message().
◆ operator[]() [1/2]
Returns database element by ID, or nullptr if no element exists with this ID.
◆ operator[]() [2/2]
Returns const database element by ID, or nullptr if no element exists with this ID.
◆ readXML()
template<typename T >
void VICUS::Database< T >::readXML |
( |
const IBK::Path & |
fname, |
|
|
const std::string & |
topLevelTag, |
|
|
const std::string & |
childTagName, |
|
|
bool |
builtIn = false |
|
) |
| |
|
inline |
Reads database from xml file. Usage:
db.readXML("db_materials.xml", "Materials", "Material", true);
- Warning
- Throws an IBK::Exception if reading fails.
◆ remove()
Removes a database element identified by its ID
- Warning
- Throws an IBK::Exception if no element with given ID exists.
◆ removeLocalElements()
Removes all user elements which are defined as local
◆ removeNotReferencedLocalElements()
Removes all local, not-referenced elements
◆ removeUserElements()
Removes all user-defined elements (element not marked as built-in)
◆ setData()
Initializes database with data from a vector. Throws an exception if duplicate IDs are found.
◆ size()
Returns number of DB elements.
◆ writeXML()
template<typename T >
void VICUS::Database< T >::writeXML |
( |
const IBK::Path & |
fname, |
|
|
const std::string & |
topLevelTag |
|
) |
| const |
|
inline |
Writes database to XML file. Usage:
db.writeXML("db_materials.xml", "Materials");
◆ m_modified
Modified marker, should be changed to true, whenever a database object was modified. Will be automatically set to true in functions add() and remove().
The documentation for this class was generated from the following file: