GlobalObjects
Loading...
Searching...
No Matches
glo::ObjectMaker Class Reference

This class can instantiate a persistent object from a record or fill a persistent object and vice versa. More...

#include <GloObjectMaker.h>

Public Member Functions

 ObjectMaker (const std::string &rstrSchemaNameWithPath, ObjCreator &rCreator)
 
virtual ~ObjectMaker ()
 
int fillPersObject (Persistent &rObject, Record &rRecord, Base *pBase) const
 
int fillRecord (Record &rRecord, Persistent &rObject, bool bWithRefRecords=false) const
 
unsigned long getClassID (BaseAllSet *pAllSet) const
 
const SchemaInterfacegetSchema ()
 
bool isKnownClassID (unsigned long ulClassID) const
 
int makeNewPersObject (Persistent *&prNewObject, Record &rRecord, Base *pBase) const
 
int makeNewRecord (Record *&prNewRecord, Persistent &rObject) const
 
int makeNewRecord (Record *&prNewRecord, unsigned long ulClassID) const
 

Private Member Functions

 ObjectMaker ()
 
 ObjectMaker (const ObjectMaker &)
 
ObjectMakeroperator= (const ObjectMaker &)
 

Private Attributes

ObjCreatorm_pObjCreator
 
SchemaInterfacem_pSchema
 

Detailed Description

This class can instantiate a persistent object from a record or fill a persistent object and vice versa.

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ ObjectMaker() [1/3]

glo::ObjectMaker::ObjectMaker ( )
private

The standard constructor is not available.

◆ ObjectMaker() [2/3]

glo::ObjectMaker::ObjectMaker ( const std::string & rstrSchemaNameWithPath,
ObjCreator & rCreator )

Constructor with parameter passing.

Parameters
[in]rstrSchemaNameWithPathFile name of the schema with path; e.g. "C:/Path/MyGloBase.ini".
[in]rCreatorThe derived ObjCreator, this is copied.
Exceptions
eut::ErrorNExceptionIn case of an error an exception will be thrown (e.g. if the schema file does not exist or cannot be opened).
Attention
If the schema file with the given name exists, a SchemaInterface is instantiated.

◆ ~ObjectMaker()

virtual glo::ObjectMaker::~ObjectMaker ( )
virtual

Destructor, m_pSchema and m_pObjCreator are removed from memory.

◆ ObjectMaker() [3/3]

glo::ObjectMaker::ObjectMaker ( const ObjectMaker & )
private

The copy constructor is not available.

Member Function Documentation

◆ fillPersObject()

int glo::ObjectMaker::fillPersObject ( Persistent & rObject,
Record & rRecord,
Base * pBase ) const

Fills the passed persistent object with the data of the passed record from the passed database.

Parameters
[in,out]rObjectThe persistent object to be filled with data.
[in]rRecordThe record with the data from the database.
[in]pBaseThe database in which the persistent object is stored. Is needed to reload possibly further, necessary data.
Returns
A return value < 0 indicates an error.
Note
For Glo developers: Is implemented in GloRecordAttributeFunctions.cpp, so that extensions of data set attributes can be made there collectively.

◆ fillRecord()

int glo::ObjectMaker::fillRecord ( Record & rRecord,
Persistent & rObject,
bool bWithRefRecords = false ) const

Fills the passed record with the data of the passed persistent object.

Parameters
[in,out]rRecordThe record to be filled with data.
[in]rObjectThe persistent object with its data.
[in]bWithRefRecordsIf true, for attributes of type PoRefRecordAttribute, StdShrdPoRefRecordAttribute, PoRefListRecordAttribute and PoRefSetRecordAttribute, if they referenced to valid objects, the respective record will be generated.
This can be switched on or off, because the records of the referenced objects, if they are to be stored along, for example, are already generated via PrivateBase::getDependDataRecords (...).
Default is 'false'.
Returns
A return value < 0 indicates an error.

◆ getClassID()

unsigned long glo::ObjectMaker::getClassID ( BaseAllSet * pAllSet) const

Returns the class ID of the passed AllSet.

Returns
If known to AllSet then the corresponding class ID.
Exceptions
eut::ErrorNExceptionIf the type of AllSet is not known, an exception is thrown with the error ERR_UNKNOWN_OBJECT_TYPE.

◆ getSchema()

const SchemaInterface * glo::ObjectMaker::getSchema ( )

Returns its SchemaInterface.

Returns
The returned object lives only as long as this object and must not be removed from memory by the calling instance.

◆ isKnownClassID()

bool glo::ObjectMaker::isKnownClassID ( unsigned long ulClassID) const

Asks the m_pObjCreator if the passed class ID is valid for it.

Parameters
[in]ulClassIDThe class ID to check.
Returns
If true, the ObjectCreator can instantiate an object of the persistent class with the given class ID.

◆ makeNewPersObject()

int glo::ObjectMaker::makeNewPersObject ( Persistent *& prNewObject,
Record & rRecord,
Base * pBase ) const

Returns a new persistent object with the data of the passed record from the passed database.

Parameters
[in,out]prNewObjectThis pointer returns the persistent object.
[in]rRecordThe record with the data from the database.
[in]pBaseThe database in which the persistent object is stored. Is needed to reload possibly further, necessary data.
Returns
A return value < 0 indicates an error.
Attention
If a new object has been delivered (not a possibly already existing one in memory is delivered), the record has been transferred to the new object and the database has been set in the new object.
Exceptions
eut::ErrorNExceptionIf no database is passed, an exception is thrown.

◆ makeNewRecord() [1/2]

int glo::ObjectMaker::makeNewRecord ( Record *& prNewRecord,
Persistent & rObject ) const

Returns a new record (without data) which matches the given persistent object.

Parameters
[in,out]prNewRecordThe new record.
[in]rObjectThe object for which the record is to be generated.
Returns
A return value < 0 indicates an error.

◆ makeNewRecord() [2/2]

int glo::ObjectMaker::makeNewRecord ( Record *& prNewRecord,
unsigned long ulClassID ) const

Returns a new record (without data) which matches a persistent object with a given class ID.

Parameters
[in,out]prNewRecordThe new record.
[in]ulClassIDThe class ID for which the record should be generated.
Returns
A return value < 0 indicates an error.

◆ operator=()

ObjectMaker & glo::ObjectMaker::operator= ( const ObjectMaker & )
private

The assignment operator is not available.

Member Data Documentation

◆ m_pObjCreator

ObjCreator* glo::ObjectMaker::m_pObjCreator
private

The ObejectCreator, resp. its subclass, knows how to instantiate persistent objects.

◆ m_pSchema

SchemaInterface* glo::ObjectMaker::m_pSchema
private

To be able to generate and fill objects from records and to generate and fill records from these objects, the schema must be known.


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