GlobalObjects
|
This class is the interface to a GlobalObjects schema. It contains all class information to store objects of persistent classes in a database and to build objects from tables and tables from objects. More...
#include <GloSchemaInterface.h>
Classes | |
struct | TempGloClassInfoIndex |
Structure to collect indexes from the schema file until the end of reading. More... | |
Public Member Functions | |
SchemaInterface (const SchemaInterface &rT) | |
SchemaInterface (const std::string &rsSchemaFullName, bool bInDeveloperMode, bool bNew) | |
SchemaInterface (const std::string &rsSchemaFullName, bool bInDeveloperMode=false) | |
virtual | ~SchemaInterface () |
std::string | _DEBUG_ToString () |
void | changeAllClassReferences (const std::string &rsOldReferenceName, const std::string &rsNewReferenceName, std::map< unsigned long, ClassInfo *, std::less< unsigned long > > *pChangedClassesContainer) |
bool | classIdExisting (unsigned long ulClassID) const |
bool | classInfoFileNameExisting (const std::string &rsClassFileName) const |
bool | classInfoNameExisting (const std::string &rsClassName) const |
int | destroyClassInfo (unsigned long ulClassID) |
int | getAllAttributes (std::map< std::string, ClassInfoAttribute *, std::less< std::string > > &rRetValContainer) const |
int | getAllAttributes (std::set< ClassInfoAttribute * > &rRetValContainer, unsigned long ulClassID, bool bWithSuperClassAttributes=true) const |
int | getAllClassInfos (std::map< unsigned long, ClassInfo *, std::less< unsigned long > > &rClassInfoContainer, bool bCopy=true) const |
int | getAllSubClassInfos (std::map< unsigned long, ClassInfo *, std::less< unsigned long > > &rSubClassInfoContainer, unsigned long ulClassID, bool bCopy=true) const |
int | getAllSuperClassIDs (std::set< unsigned long > &rSuperClassIdSet, unsigned long ulClassID) const |
int | getAllSuperClassInfos (std::map< unsigned long, ClassInfo *, std::less< unsigned long > > &rSuperClassInfoContainer, unsigned long ulClassID, bool bCopy=true) const |
int | getAllTableNames (std::map< std::string, std::string, std::less< std::string > > &rTableNameContainer) const |
int | getAllTableNames (std::vector< std::string > &rTableNameContainer, unsigned long ulClassID) const |
ClassInfo * | getClassInfo (EnSeekMode eMode) |
ClassInfoAttribute * | getClassInfoAttributeByAttributeID (int &riErr, const AttributeID &rAttributeID) const |
ClassInfoAttribute * | getClassInfoAttributeByClassAndAttributeName (int &riErr, const std::string &rsClassName, const std::string &rsAttributeName) const |
ClassInfoAttribute * | getClassInfoAttributeByTableAndFieldName (int &riErr, const std::string &rsTableName, const std::string &rsFieldName) const |
ClassInfoAttribute * | getClassInfoAttributeByTableAndFieldName (int &riErr, unsigned long ulClassID, const std::string &rsTableName, const std::string &rsFieldName) const |
ClassInfo * | getClassInfoByID (unsigned long ulClassID) const |
ClassInfo * | getClassInfoByMainTable (const std::string &rsMainTableName) const |
ClassInfo * | getClassInfoByName (const std::string &rsClassName) const |
ClassInfoIndex * | getClassInfoIndexByClassAndIndexName (int &riErr, const std::string &rsClassName, const std::string &rsIndexName) const |
int | getClassTableWithPath (std::string &rstrRetVal, unsigned long ulClassID) const |
std::string | getDataPath () const |
std::string | getDataSubDir () const |
std::string | getDescription () const |
unsigned long | getNextClassID () |
std::size_t | getNumberOfClassInfos () const |
std::string | getSchemaFullName () const |
unsigned long | getSchemaID () const |
std::string | getSchemaName () const |
std::string | getSchemaPath () const |
int | getSubClassInfos (std::map< unsigned long, ClassInfo *, std::less< unsigned long > > &rSubClassInfoContainer, unsigned long ulClassID, bool bCopy=true) const |
int | getSuperClassInfos (std::map< unsigned long, ClassInfo *, std::less< unsigned long > > &rSuperClassInfoContainer, unsigned long ulClassID, bool bCopy=true) const |
unsigned long | getVersion () const |
int | insertClassInfo (ClassInfo *pNewClassInfo) |
bool | isSuperClassFrom (unsigned long ulClassIDSuperClass, unsigned long ulClassIDSubClass) const |
SchemaInterface & | operator= (const SchemaInterface &rT) |
void | setDataSubDir (const std::string &rsDataSubDir) |
void | setDescription (const std::string &rsDescription) |
void | setSchemaFullName (const std::string &rsSchemaFullName) |
void | setSchemaID (unsigned long ulID) |
void | setSubClassInfosInAllClassInfo () |
void | setVersion (unsigned long ulVersion) |
bool | tableNameExisting (const std::string &rsTableName) const |
int | writeSchema () |
Protected Member Functions | |
SchemaInterface () | |
SchemaInterface (const std::map< unsigned long, ClassInfo * > *pClassInfoMap) | |
SchemaInterface (const std::map< unsigned long, std::shared_ptr< glo::ClassInfo > > rClassInfoMap) | |
Private Member Functions | |
int | changeClassNameDotAttributNameInAttributeID (std::vector< TempGloClassInfoIndex > &rTempGloClassInfoIndexVector) |
void | copyClassInfoListFrom (const SchemaInterface &rT) |
void | deleteAllClassInfos () |
int | getSubClassInfos (std::map< unsigned long, ClassInfo *, std::less< unsigned long > > &rSubClassInfoContainer, unsigned long ulClassID, bool bCopy, bool bDeep) const |
int | getSuperClassInfos (std::map< unsigned long, ClassInfo *, std::less< unsigned long > > &rSuperClassInfoContainer, unsigned long ulClassID, bool bCopy, bool bDeep) const |
void | init () |
void | initNew () |
Private Attributes | |
bool | m_bInDeveloperMode |
std::map< unsigned long, ClassInfo *, std::less< unsigned long > > | m_ClassInfoMap |
std::map< unsignedlong, ClassInfo * >::iterator | m_ClassInfoMapIterator |
std::vector< unsigned long > | m_CurrentlyAssignedClassIDVector |
std::string | m_sDataSubDir |
std::string | m_sDescription |
std::string | m_sSchemaDataPath |
std::string | m_sSchemaFullName |
unsigned long | m_ulID |
unsigned long | m_ulVersion |
Friends | |
class | BaseMaker |
class | Record |
This class is the interface to a GlobalObjects schema. It contains all class information to store objects of persistent classes in a database and to build objects from tables and tables from objects.
This class can read and save schema files. Class information can be added, modified and removed.
|
protected |
The standard constructor is not available.
|
protected |
Constructor with parameter passing (used by Record).
[in] | pClassInfoMap | The class information. |
|
protected |
Constructor with parameter passing (used by Record).
[in] | rClassInfoMap | The class information. |
glo::SchemaInterface::SchemaInterface | ( | const std::string & | rsSchemaFullName, |
bool | bInDeveloperMode = false ) |
Constructor with parameter passing.
[in] | rsSchemaFullName | The complete file name (e.g. under the operating system Windows "C:/Path/MyGloBase.ini"). |
[in] | bInDeveloperMode | If true the SchemaInterface is in development mode. The developer comments with the classes and attributes from the schema are delivered and written. Otherwise not, in order not to inflate the data volume unnecessarily. |
eut::ErrorNException | An exception is thrown if an error occurs. |
glo::SchemaInterface::SchemaInterface | ( | const std::string & | rsSchemaFullName, |
bool | bInDeveloperMode, | ||
bool | bNew ) |
Constructor with parameter passing.
[in] | rsSchemaFullName | The complete file name (e.g. under the operating system Windows "C:/Path/MyGloBase.ini"). |
[in] | bInDeveloperMode | If true the SchemaInterface is in development mode. The developer comments with the classes and attributes from the schema are delivered and written. Otherwise not, in order not to inflate the data volume unnecessarily. |
[in] | bNew | If true, a new schema is created, SchemaInterface::initNew() is called, otherwise SchemaInterface::init(). |
eut::ErrorNException | An exception is thrown if an error occurs. |
glo::SchemaInterface::SchemaInterface | ( | const SchemaInterface & | rT | ) |
Copy constructor.
[in] | rT | The data is copied from this object. |
|
virtual |
Destructor, all class information is removed from memory.
std::string glo::SchemaInterface::_DEBUG_ToString | ( | ) |
void glo::SchemaInterface::changeAllClassReferences | ( | const std::string & | rsOldReferenceName, |
const std::string & | rsNewReferenceName, | ||
std::map< unsigned long, ClassInfo *, std::less< unsigned long > > * | pChangedClassesContainer ) |
References to classes with the passed class name rsOldReferenceName in all class information are changed to references to the class with the passed class name rsNewReferenceName.
Should be called if a class name changes.
[in] | rsOldReferenceName | The class name that should be replaced. |
[in] | rsNewReferenceName | The class name that should be used instead of the former. |
[in,out] | pChangedClassesContainer | If passed, all changed class information will be inserted there. |
|
private |
Swaps all class and attribute names in all TempGloClassInfoIndex::m_sIndexPath Class ID and attribute field position (equivalent to AttributeID).
[in,out] | rTempGloClassInfoIndexVector | The vector of objects of type TempGloClassInfoIndex in which the values in TempGloClassInfoIndex::m_sIndexPath are changed. |
bool glo::SchemaInterface::classIdExisting | ( | unsigned long | ulClassID | ) | const |
Checks if a class with passed class id already exists in the schema.
[in] | ulClassID | The class id. |
bool glo::SchemaInterface::classInfoFileNameExisting | ( | const std::string & | rsClassFileName | ) | const |
Checks if a class with passed filename already exists in the schema.
[in] | rsClassFileName | The class filename |
bool glo::SchemaInterface::classInfoNameExisting | ( | const std::string & | rsClassName | ) | const |
Checks if a class with passed name already exists in the schema.
[in] | rsClassName | The full class name (e.g. "mynamespace::MyClassName"). |
|
private |
All class information is removed from the list of class information of the schema and from the memory and instead those from the passed SchemaInterface are taken as copies.
|
private |
All class information is removed from the list of class information of the schema and from memory.
int glo::SchemaInterface::destroyClassInfo | ( | unsigned long | ulClassID | ) |
Removes and destroys the class information with passed class ID from m_ClassInfoMap. All "subclass" class information is also removed and destroyed.
[in] | ulClassID | The class ID of the class information to be removed. |
int glo::SchemaInterface::getAllAttributes | ( | std::map< std::string, ClassInfoAttribute *, std::less< std::string > > & | rRetValContainer | ) | const |
Returns all class information attributes of all class information.
[in,out] | rRetValContainer | The found class information attributes are inserted. In this method the container is not cleared before insertion. |
int glo::SchemaInterface::getAllAttributes | ( | std::set< ClassInfoAttribute * > & | rRetValContainer, |
unsigned long | ulClassID, | ||
bool | bWithSuperClassAttributes = true ) const |
Returns all class information attributes of a class information with passed class ID.
[in,out] | rRetValContainer | The found class information attributes are inserted. In this method the container is not cleared before insertion. |
[in] | ulClassID | Class ID of the class information whose class information attributes are expected. |
[in] | bWithSuperClassAttributes | If false, the attributes of the superclasses are not returned. |
int glo::SchemaInterface::getAllClassInfos | ( | std::map< unsigned long, ClassInfo *, std::less< unsigned long > > & | rClassInfoContainer, |
bool | bCopy = true ) const |
Returns all class information of the schema.
[in,out] | rClassInfoContainer | The class information of all classes of the schema. |
[in] | bCopy | Copies or originals:
|
int glo::SchemaInterface::getAllSubClassInfos | ( | std::map< unsigned long, ClassInfo *, std::less< unsigned long > > & | rSubClassInfoContainer, |
unsigned long | ulClassID, | ||
bool | bCopy = true ) const |
Returns the class information of all subclass(es) of the class whose class ID is passed.
[in,out] | rSubClassInfoContainer | The class information of all subclasses, if available. |
[in] | ulClassID | The class ID of the class whose class information of all subclasses is expected. |
[in] | bCopy | Copies or originals:
|
int glo::SchemaInterface::getAllSuperClassIDs | ( | std::set< unsigned long > & | rSuperClassIdSet, |
unsigned long | ulClassID ) const |
Returns the class IDs of all superclasses of the class whose ID is passed
[in,out] | rSuperClassIdSet | The class IDs of the superclasses, if available. |
[in] | ulClassID | The class ID of the class whose class IDs of the superclasses are to be returned. |
int glo::SchemaInterface::getAllSuperClassInfos | ( | std::map< unsigned long, ClassInfo *, std::less< unsigned long > > & | rSuperClassInfoContainer, |
unsigned long | ulClassID, | ||
bool | bCopy = true ) const |
Returns the class information of all superclass(es) of the class whose class ID is passed.
[in,out] | rSuperClassInfoContainer | The class information of all superclasses, if available. |
[in] | ulClassID | The class ID of the class whose class information of all superclasses is expected. |
[in] | bCopy | Copies or originals:
|
int glo::SchemaInterface::getAllTableNames | ( | std::map< std::string, std::string, std::less< std::string > > & | rTableNameContainer | ) | const |
Returns all table names of all class information.
[in,out] | rTableNameContainer | The found table names are inserted. In this method the container is not cleared before inserting. |
int glo::SchemaInterface::getAllTableNames | ( | std::vector< std::string > & | rTableNameContainer, |
unsigned long | ulClassID ) const |
Returns all table names from a class information with passed class ID.
[in,out] | rTableNameContainer | The found table names are inserted. In this method the container is not cleared before insertion. |
[in] | ulClassID | Class ID of the class information whose table names are expected. |
ClassInfo * glo::SchemaInterface::getClassInfo | ( | EnSeekMode | eMode | ) |
Returns a class information from m_ClassInfoMap related to eMode.
[in] | eMode | The seek mode. |
Parameter examples:
ClassInfoAttribute * glo::SchemaInterface::getClassInfoAttributeByAttributeID | ( | int & | riErr, |
const AttributeID & | rAttributeID ) const |
Returns a class information attribute with a passed AttributeID.
[in,out] | riErr | A value < 0 indicates an error. |
[in] | rAttributeID | The attributeID of the searched class information attribute. |
ClassInfoAttribute * glo::SchemaInterface::getClassInfoAttributeByClassAndAttributeName | ( | int & | riErr, |
const std::string & | rsClassName, | ||
const std::string & | rsAttributeName ) const |
Returns a class information attribute from a class information with the passed class and attribute names.
[in,out] | riErr | A value < 0 indicates an error. |
[in] | rsClassName | The full class name of the searched class information attribute (e.g. "mynamespace::MyClassName").. |
[in] | rsAttributeName | The attribute name of the searched class information attribute. |
ClassInfoAttribute * glo::SchemaInterface::getClassInfoAttributeByTableAndFieldName | ( | int & | riErr, |
const std::string & | rsTableName, | ||
const std::string & | rsFieldName ) const |
Returns a class information attribute from a class information with the passed table and field names.
[in,out] | riErr | A value < 0 indicates an error. |
[in] | rsTableName | The table name of the searched class information attribute. |
[in] | rsFieldName | The table field name of the searched class information attribute. |
ClassInfoAttribute * glo::SchemaInterface::getClassInfoAttributeByTableAndFieldName | ( | int & | riErr, |
unsigned long | ulClassID, | ||
const std::string & | rsTableName, | ||
const std::string & | rsFieldName ) const |
Returns a class information attribute from a class information with passed class ID and passed table and field names.
[in,out] | riErr | A value < 0 indicates an error. |
[in] | ulClassID | Class ID of the class information whose class information attribute is to be searched. |
[in] | rsTableName | The table name of the searched class information attribute. |
[in] | rsFieldName | The table field name of the searched class information attribute. |
ClassInfo * glo::SchemaInterface::getClassInfoByID | ( | unsigned long | ulClassID | ) | const |
Returns the class information from m_ClassInfoMap with passed class ID if available.
[in] | ulClassID | The class ID. |
ClassInfo * glo::SchemaInterface::getClassInfoByMainTable | ( | const std::string & | rsMainTableName | ) | const |
Returns the class information from m_ClassInfoMap whose data is stored in the table with the passed name.
[in] | rsMainTableName | The table name. |
ClassInfo * glo::SchemaInterface::getClassInfoByName | ( | const std::string & | rsClassName | ) | const |
Returns the class information from m_ClassInfoMap with the passed name if available.
[in] | rsClassName | The full class name (e.g. "mynamespace::MyClassName"). |
ClassInfoIndex * glo::SchemaInterface::getClassInfoIndexByClassAndIndexName | ( | int & | riErr, |
const std::string & | rsClassName, | ||
const std::string & | rsIndexName ) const |
Returns a class information index of a class information with the passed class and index names.
[in,out] | riErr | A value < 0 indicates an error. |
[in] | rsClassName | The full class name of the searched class information index (e.g. "mynamespace::MyClassName"). |
[in] | rsIndexName | The index name of the searched class information index. |
int glo::SchemaInterface::getClassTableWithPath | ( | std::string & | rstrRetVal, |
unsigned long | ulClassID ) const |
Returns the table filename with full path of a class information with passed class ID.
[in,out] | rstrRetVal | The table filename with complete path (e.g. under the operating system "C:/Path/Data/MyClassTable"). |
[in] | ulClassID | Class ID of the class information whose table filename is expected. |
std::string glo::SchemaInterface::getDataPath | ( | ) | const |
Returns the full directory name where the data can be found. The data is always located in a subdirectory of the directory where the schema file is located.
std::string glo::SchemaInterface::getDataSubDir | ( | ) | const |
Returns the directory name where the data can be found. The data is always located in a subdirectory of the directory where the schema file is located.
std::string glo::SchemaInterface::getDescription | ( | ) | const |
Returns the database description.
unsigned long glo::SchemaInterface::getNextClassID | ( | ) |
Returns the next free unique class ID.
std::size_t glo::SchemaInterface::getNumberOfClassInfos | ( | ) | const |
Returns the number of class information.
std::string glo::SchemaInterface::getSchemaFullName | ( | ) | const |
Returns the complete file name.
unsigned long glo::SchemaInterface::getSchemaID | ( | ) | const |
Returns the schema ID.
std::string glo::SchemaInterface::getSchemaName | ( | ) | const |
Returns the schema resp. database name.
std::string glo::SchemaInterface::getSchemaPath | ( | ) | const |
Returns the file path where the schema file can be found.
|
private |
Returns the class information of the subclass(es) of the class whose class ID is passed.
[in,out] | rSubClassInfoContainer | The class information of the subclass(es), if available. |
[in] | ulClassID | The class ID of the class whose class information of the subclasses is expected. |
[in] | bCopy | Copies or originals:
|
[in] | bDeep | If true, not only the direct subclasses are inserted but also their subclasses. |
int glo::SchemaInterface::getSubClassInfos | ( | std::map< unsigned long, ClassInfo *, std::less< unsigned long > > & | rSubClassInfoContainer, |
unsigned long | ulClassID, | ||
bool | bCopy = true ) const |
Returns the class information of the direct subclass(es) of the class whose class ID is passed.
[in,out] | rSubClassInfoContainer | The class information of the direct subclass(es), if available. |
[in] | ulClassID | The class ID of the class whose class information of the direct subclasses is expected. |
[in] | bCopy | Copies or originals:
|
|
private |
Returns the class information of the superclass(es) of the class whose class ID is passed.
[in,out] | rSuperClassInfoContainer | The class information of the superclass(es), if available. In this method the container is not emptied before insertion. |
[in] | ulClassID | The class ID of the class whose class information of the superclasses is expected. |
[in] | bCopy | Copies or originals:
|
[in] | bDeep | If true, not only the direct superclasses are inserted but also their superclasses. |
int glo::SchemaInterface::getSuperClassInfos | ( | std::map< unsigned long, ClassInfo *, std::less< unsigned long > > & | rSuperClassInfoContainer, |
unsigned long | ulClassID, | ||
bool | bCopy = true ) const |
Returns the class information of the direct superclass(es) of the class whose class ID is passed.
[in,out] | rSuperClassInfoContainer | The class information of the direct superclass(es), if available. |
[in] | ulClassID | The class ID of the class whose class information of the direct superclasses is expected. |
[in] | bCopy | Copies or originals:
|
unsigned long glo::SchemaInterface::getVersion | ( | ) | const |
Returns the version number.
|
private |
The schema interface is initialized. The schema file is opened and all class information with its class information attributes is read, called by the constructor.
eut::ErrorNException | In case of an error an exception is thrown. |
|
private |
It is only checked whether the file from "m_sSchemaFullName" does not already exist, is called by the constructor.
eut::ErrorNException | If the schema file already exists an exception is thrown. |
int glo::SchemaInterface::insertClassInfo | ( | ClassInfo * | pNewClassInfo | ) |
Inserts passed class information into m_ClassInfoMap if no class information with the same class ID exists yet.
[in] | pNewClassInfo | The class information to be inserted. |
bool glo::SchemaInterface::isSuperClassFrom | ( | unsigned long | ulClassIDSuperClass, |
unsigned long | ulClassIDSubClass ) const |
Checks whether a class is a superclass of another class.
[in] | ulClassIDSuperClass | The class ID of the superclass to be checked. |
[in] | ulClassIDSubClass | The class ID of the subclass to be checked. |
SchemaInterface & glo::SchemaInterface::operator= | ( | const SchemaInterface & | rT | ) |
Assignment operator.
[in] | rT | The data is transferred from this object. |
void glo::SchemaInterface::setDataSubDir | ( | const std::string & | rsDataSubDir | ) |
Sets the directory name where the data can be found. The data is always located in a subdirectory of the directory where the schema file is located.
[in] | rsDataSubDir | The directory name like "Data". |
void glo::SchemaInterface::setDescription | ( | const std::string & | rsDescription | ) |
Sets the database description.
[in] | rsDescription | The description. |
void glo::SchemaInterface::setSchemaFullName | ( | const std::string & | rsSchemaFullName | ) |
Sets the complete file name.
[in] | rsSchemaFullName | Complete file name (e.g. under the operating system Windows "C:/Path/MyGloBase.ini"). |
void glo::SchemaInterface::setSchemaID | ( | unsigned long | ulID | ) |
Sets the schema ID.
[in] | ulID | The schema ID. |
void glo::SchemaInterface::setSubClassInfosInAllClassInfo | ( | ) |
The subclasses are inserted in all class information.
void glo::SchemaInterface::setVersion | ( | unsigned long | ulVersion | ) |
Sets the version number.
[in] | ulVersion | The version number. |
bool glo::SchemaInterface::tableNameExisting | ( | const std::string & | rsTableName | ) | const |
Checks if a table name for a class information in the schema is already assigned.
[in] | rsTableName | The table name to be checked. |
int glo::SchemaInterface::writeSchema | ( | ) |
Writes the schema file (m_sSchemaFullName). Its tries to overwrite a possibly already existing file.
|
friend |
|
friend |
|
private |
If true the GloSchema interface is in development mode. The developer comments with the classes and attributes from the schema are delivered and written. Otherwise not, in order not to inflate the data volume.
|
private |
The collection of class information of the respective schema.
|
private |
An internal iterator on the collection of class information of the respective schema.
|
private |
Only temporarily to hold assigned ClassIDs whose classes may not yet be in the schema.
|
private |
The object data is always located in this subdirectory of the directory in which the schema file is located.
|
private |
Description of the database.
|
private |
The path to the schema file (e.g. under the operating system Windows "C:/Path/MyDataBase/")
|
private |
The complete file name of the schema file (e.g. under the operating system Windows "C:/Path/MyGloBase.ini")
|
private |
The ID of the database.
|
private |
The versin of the schema; unequal IDs of client and server can lead to unexpected behavior!