GlobalObjects
Loading...
Searching...
No Matches
glo::BaseRecordAttribute Class Referenceabstract

Base class for the individual attributes of a Record. More...

#include <GloBaseRecordAttribute.h>

Inheritance diagram for glo::BaseRecordAttribute:

Public Member Functions

 BaseRecordAttribute (ClassInfoAttribute *pClassInfoAttribut, const std::streampos &rFilePos)
 
virtual ~BaseRecordAttribute ()
 
virtual bool dataIsFieldContent () const =0
 
unsigned int forget ()
 
AttributeID getAttributeID () const
 
virtual int getAttributeValueBlob (eut::Blob &rBlob) const
 
ClassInfoAttributegetClassInfoAttribute () const
 
std::string getClassMemberName () const
 
std::string getClassName () const
 
virtual BaseRecordAttributegetCopy ()=0
 
virtual unsigned short getDataFieldLength () const =0
 
virtual std::string getDataReference () const
 
EnDataType getDataType () const
 
std::string getFieldName () const
 
int getFieldPos ()
 
std::streampos getFilePosition () const
 
virtual int getFormattedFieldContents (std::string &rsRetVal, DATA_REFERENCE_INFO &rRetValInfo, ObjID ObjID)
 
EnDataTypeGroup getInfoType ()
 
unsigned int getReferenceCount () const
 
std::string getTableFieldName () const
 
std::string getTableName () const
 
ClassInfoAttribute::Type getType () const
 
std::string getTypeAsCppString () const
 
std::string getTypeAsString () const
 
std::string getTypeInfo () const
 
virtual std::string getValueAsDataString () const =0
 
virtual std::string getValueAsDisplayString () const =0
 
virtual std::string getValueAsStreamString () const =0
 
virtual std::string getValueAsString () const =0
 
virtual void * getValueAsVoidPointer ()=0
 
virtual void initNew ()=0
 
unsigned int remember ()
 
virtual void setDataReference (const std::string &rsDataReference)
 
void setFilePosition (const std::streampos &rFilePos)
 
virtual int setValueFromObjectAttributeID (Persistent &rObject, const AttributeID &rAttributeID)
 
virtual void setValueFromVoid (void *pValue)=0
 
virtual int takeValue (const BaseRecordAttribute &rT)
 
virtual int updateDataReference (const std::string &rsDataPath, DATA_REFERENCE_INFO MethodInfo)
 
bool operator== (const BaseRecordAttribute &rT) const
 Comparison operator, all attributes are compared.
 
bool operator!= (const BaseRecordAttribute &rT) const
 Comparison operator, all attributes are compared.
 

Protected Member Functions

 BaseRecordAttribute ()
 
 BaseRecordAttribute (const BaseRecordAttribute &rT)
 

Private Member Functions

BaseRecordAttributeoperator= (const BaseRecordAttribute &)
 

Private Attributes

std::streampos m_FilePosition
 
eut::CriticalSection m_LocalCriticalSection
 
ClassInfoAttributem_pClassInfoAttribut
 
unsigned int m_uiReferenceCount
 

Static Private Attributes

static unsigned int sm_uiInstanceCount
 

Friends

class ptl::TDVList< BaseRecordAttribute >
 

Detailed Description

Base class for the individual attributes of a Record.

Only certain attributes are supported by GlobalObjects as storable. Every supported attribute of a persistent class must be derived from this class.

Objects of this type have a reference counter and must not be removed from memory using the destructor.

Objects with reference counters may only be instantiated once. When passing to another instance, the reference counter is incremented using remember(). If the instance that now owns the object no longer needs it, the reference counter is decremented using forget().

If the reference counter runs to 0, the destructor is called.

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ BaseRecordAttribute() [1/3]

glo::BaseRecordAttribute::BaseRecordAttribute ( )
protected

The standard constructor is not available.

◆ ~BaseRecordAttribute()

virtual glo::BaseRecordAttribute::~BaseRecordAttribute ( )
virtual

The destructor is not available. The object may only be removed from memory using forget().

◆ BaseRecordAttribute() [2/3]

glo::BaseRecordAttribute::BaseRecordAttribute ( ClassInfoAttribute * pClassInfoAttribut,
const std::streampos & rFilePos )

Constructor with parameter passing.

Parameters
[in]pClassInfoAttributA class information attribute is expected.
[in]rFilePosThe file position.
Exceptions
eut::ErrorNExceptionAn exception is thrown if an error occurs.

◆ BaseRecordAttribute() [3/3]

glo::BaseRecordAttribute::BaseRecordAttribute ( const BaseRecordAttribute & rT)
protected

Copy constructor.

Parameters
[in]rTThe data is copied from this object.
See also
getCopy()

Member Function Documentation

◆ dataIsFieldContent()

virtual bool glo::BaseRecordAttribute::dataIsFieldContent ( ) const
pure virtual

Returns true if the attribute data is stored as field content.
Returns false if attributes whose contents are not necessarily in a table column (because they may sometimes or even always be too large, and therefore a reference to a file is used as field content).

Returns
see above
Note
Must be overwritten by all non-abstract record attributes.
Attention
If record attributes can have a reference to the data, they must use the methods
  • std::string getDataReference() const
  • void setDataReference (...) const
  • int getFormattedFieldContents (...) overwrite!"

Implemented in glo::BlobRecordAttribute, glo::BoolRecordAttribute, glo::CharRecordAttribute, glo::DateTimeRecordAttribute, glo::DoubleRecordAttribute, glo::FloatRecordAttribute, glo::IDRecordAttribute, glo::IntRecordAttribute, glo::LongDoubleRecordAttribute, glo::LongLongRecordAttribute, glo::LongRecordAttribute, glo::LotRecordAttribute, glo::ShortRecordAttribute, glo::StringRecordAttribute, glo::UCharRecordAttribute, glo::UIntRecordAttribute, glo::ULongLongRecordAttribute, glo::ULongRecordAttribute, and glo::UShortRecordAttribute.

◆ forget()

unsigned int glo::BaseRecordAttribute::forget ( )

An object of this class should always be delivered with a previous call to remember(). The supplied instance must then 'forget' the object again using this method.

Returns
The return value is the number of references to the object of this class.
Exceptions
eut::ErrorNExceptionAn exception is thrown if the reference counter goes into minus.

◆ getAttributeID()

AttributeID glo::BaseRecordAttribute::getAttributeID ( ) const

Returns a unique attribute ID from m_pClassInfoAttribut.

Returns
The attribute ID.

◆ getAttributeValueBlob()

virtual int glo::BaseRecordAttribute::getAttributeValueBlob ( eut::Blob & rBlob) const
virtual

Inserts the string from getValueAsStreamString() at the end of the passed blob. Is for the DataStreamer.

Parameters
[in,out]rBlobThe passed blob to which the data is appended.
Returns
A return value < 0 indicates an error.
Attention
Not all subclasses allow this method because they are streamed slightly differently. These subclasses return an error when this method is called.

Reimplemented in glo::BlobRecordAttribute, glo::LotRecordAttribute, and glo::StringRecordAttribute.

◆ getClassInfoAttribute()

ClassInfoAttribute * glo::BaseRecordAttribute::getClassInfoAttribute ( ) const

Returns the own class information attribute.

Returns
The class information attribute.
Attention
The delivered object only lives as long as the delivering object.

◆ getClassMemberName()

std::string glo::BaseRecordAttribute::getClassMemberName ( ) const

Returns the attribute description with class name separated by a period. For example, "MyClass.m_MyAttributes".

Returns
The class and attribute name.

◆ getClassName()

std::string glo::BaseRecordAttribute::getClassName ( ) const

Returns the class name to which the attribute belongs.

Returns
The class description.

◆ getCopy()

◆ getDataFieldLength()

◆ getDataReference()

virtual std::string glo::BaseRecordAttribute::getDataReference ( ) const
virtual

Just delivers an empty string here.
This method must be overwritten for attributes whose contents are not necessarily to be placed in a table column (because they may sometimes or always be too large, and therefore a reference to a file is used as the field content).
This method should provide the file name in which the data is stored.

Returns
The existing file name. If empty, then there is probably none.

Reimplemented in glo::BlobRecordAttribute, glo::LotRecordAttribute, and glo::StringRecordAttribute.

◆ getDataType()

EnDataType glo::BaseRecordAttribute::getDataType ( ) const

Returns the attribute type as Enum.

Returns
The attribute type as Enum.

◆ getFieldName()

std::string glo::BaseRecordAttribute::getFieldName ( ) const

The table field description is returned.

Returns
The table field name.

◆ getFieldPos()

int glo::BaseRecordAttribute::getFieldPos ( )

Returns the column position in the table (starts at 0).

Returns
The tables column position.

◆ getFilePosition()

std::streampos glo::BaseRecordAttribute::getFilePosition ( ) const

Returns the position in the table file.

Returns
The file position.

◆ getFormattedFieldContents()

virtual int glo::BaseRecordAttribute::getFormattedFieldContents ( std::string & rsRetVal,
DATA_REFERENCE_INFO & rRetValInfo,
ObjID ObjID )
virtual

Returns its formatted table field here as well as getValueAsDataString (...)
If the record attribute can have a reference to the data, this method returns its formatted table field and an information whether an external file for the data of the record attribute should be rewritten, kept or deleted; must then be overwritten in corresponding subclasses.

Parameters
[in,out]rsRetValThe table field as it should be written.
[in,out]rRetValInfoThe information how to handle an external file.
[in]ObjIDIf a file name has to be created, the file name is formed from this object ID. Usually this is the object ID of the object whose attribute value is requested.
Returns
A return value < 0 indicates an error.

Reimplemented in glo::BlobRecordAttribute, glo::LotRecordAttribute, and glo::StringRecordAttribute.

◆ getInfoType()

EnDataTypeGroup glo::BaseRecordAttribute::getInfoType ( )

Returns the group type of the supported attribute type.

Returns
The group type.

◆ getReferenceCount()

unsigned int glo::BaseRecordAttribute::getReferenceCount ( ) const

Returns the number of referencing instances.

Returns
The number of referencing instances.

◆ getTableFieldName()

std::string glo::BaseRecordAttribute::getTableFieldName ( ) const

Returns the table and table field name separated by a period. For example, "TableName.FieldName".

Returns
The table and field name.

◆ getTableName()

std::string glo::BaseRecordAttribute::getTableName ( ) const

The table description is returned.

Returns
The table name.

◆ getType()

ClassInfoAttribute::Type glo::BaseRecordAttribute::getType ( ) const

Returns the type of the own class information attribute.

Returns
The type of the own class information attribute.

◆ getTypeAsCppString()

std::string glo::BaseRecordAttribute::getTypeAsCppString ( ) const

Returns the type of attribute supported by GlobalObjects as it appears in the header- and source-file.

Returns
The supported type attribute type.

◆ getTypeAsString()

std::string glo::BaseRecordAttribute::getTypeAsString ( ) const

Returns the type of attribute supported by GlobalObjects as it appears in the schema.

Returns
The supported type attribute type.

◆ getTypeInfo()

std::string glo::BaseRecordAttribute::getTypeInfo ( ) const

Returns an attribute type information like a number for a string length or an expression like dependent etc. Is always dependent on the attribute type.

Returns
The attribute type information.

◆ getValueAsDataString()

virtual std::string glo::BaseRecordAttribute::getValueAsDataString ( ) const
pure virtual

◆ getValueAsDisplayString()

◆ getValueAsStreamString()

◆ getValueAsString()

◆ getValueAsVoidPointer()

◆ initNew()

◆ operator!=()

bool glo::BaseRecordAttribute::operator!= ( const BaseRecordAttribute & rT) const

Comparison operator, all attributes are compared.

Parameters
[in]rTThe object to be compared with this one.

◆ operator=()

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

The assignment operator is not available.

◆ operator==()

bool glo::BaseRecordAttribute::operator== ( const BaseRecordAttribute & rT) const

Comparison operator, all attributes are compared.

Parameters
[in]rTThe object to be compared with this one.

◆ remember()

unsigned int glo::BaseRecordAttribute::remember ( )

Increments the m_uiReferenceCount. Should always be called when an object of this class is delivered. The delivered instance must then 'forget' the object with forget().

Returns
The return value is the number of references to the object of this class.

◆ setDataReference()

virtual void glo::BaseRecordAttribute::setDataReference ( const std::string & rsDataReference)
virtual

Not doing anything here.
This method must be overwritten for attributes whose contents are not necessarily to be placed in a table column (because they may sometimes or always be too large, and therefore a reference to a file is used as the field content).
This method should set the file name in which the data is stored.

Parameters
[in]rsDataReferenceThe file name.

Reimplemented in glo::BlobRecordAttribute, and glo::StringRecordAttribute.

◆ setFilePosition()

void glo::BaseRecordAttribute::setFilePosition ( const std::streampos & rFilePos)

Sets the position in the table file.

Parameters
[in]rFilePosThe file position.

◆ setValueFromObjectAttributeID()

virtual int glo::BaseRecordAttribute::setValueFromObjectAttributeID ( Persistent & rObject,
const AttributeID & rAttributeID )
virtual

The value of the RecordAttribut is determined from the class attribute of the passed Persistent using the passed AttributeID and usually the value is set using setValueFromVoid (...).
In subclasses, this method should be overwritten if the attribute is still to be fetched. See for example EmbeddedRecordAttribute::setValueFromObjectAttributeID (...).

Parameters
[in]rObjectThe persistent object whose attribute is used.
[in]rAttributeIDThe ID of the attribute of the passed object.
Returns
A return value < 0 indicates an error.
Exceptions
eut::ErrorNExceptionIn case of an error, an exception can be thrown in subclasses.

Reimplemented in glo::EmbeddedRecordAttribute, glo::ObjIDRecordAttribute, glo::OdRefListRecordAttribute, glo::OdRefRecordAttribute, glo::OdRefSetRecordAttribute, glo::PoRefListRecordAttribute, glo::PoRefRecordAttribute, glo::PoRefSetRecordAttribute, and glo::StdShrdPoRefRecordAttribute.

◆ setValueFromVoid()

◆ takeValue()

◆ updateDataReference()

virtual int glo::BaseRecordAttribute::updateDataReference ( const std::string & rsDataPath,
DATA_REFERENCE_INFO MethodInfo )
virtual

Not doing anything here.
This method must be overwritten for attributes whose contents are not necessarily to be placed in a table column (because they may sometimes or always be too large, and therefore a reference to a file is used as the field content).
This method should delete or write the file with the data if necessary.

Parameters
[in]rsDataPathThe 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 (e.g. "C:/Path/Data/").
[in]MethodInfoThe information how to handle an external file.
Returns
A return value < 0 indicates an error.

Reimplemented in glo::BlobRecordAttribute, glo::LotRecordAttribute, and glo::StringRecordAttribute.

Friends And Related Symbol Documentation

◆ ptl::TDVList< BaseRecordAttribute >

friend class ptl::TDVList< BaseRecordAttribute >
friend

Member Data Documentation

◆ m_FilePosition

std::streampos glo::BaseRecordAttribute::m_FilePosition
private

Each persistent attribute, when saved, has a unique file location

◆ m_LocalCriticalSection

eut::CriticalSection glo::BaseRecordAttribute::m_LocalCriticalSection
private

So that several threads can access remember() and forget(), access is synchronized with this object.

◆ m_pClassInfoAttribut

ClassInfoAttribute* glo::BaseRecordAttribute::m_pClassInfoAttribut
private

Each persistent attribute needs specific schema information. These are available in the schema in the respective class information (ClassInfo) as class information attributes (GloClassInfoAttributes).

◆ m_uiReferenceCount

unsigned int glo::BaseRecordAttribute::m_uiReferenceCount
private

The reference counter.

◆ sm_uiInstanceCount

unsigned int glo::BaseRecordAttribute::sm_uiInstanceCount
staticprivate

For debug purposes, a static reference counter to check if all instances are cleared.


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