OEBase¶
class OEBase
This class represents OEBase.
The abstract class OEBase defines the interface for run-time class extensibility and run-time type identification. Classes which derive from OEBase can store and retrieve data by association with integer or character string ‘tag’ identifiers.
All primitive data types and user-defined classes which have valid copy constructors and assignment operators can be stored through the mechanism provided by OEBase.
The following classes derive from this class:
operator=¶
OEBase &operator=(const OEBase &)
operator+=¶
OEBase &operator+=(const OEBase &)
AddBaseData¶
bool AddBaseData(const OEBaseData *)
AddData¶
template<typename T>
bool AddData(const char *tag, const T t)
template<typename T>
bool AddData(unsigned int tag, const T t)
Stores and associates a copy of the data
passed as the second argument with the ‘tag’ identifier given as
the first argument. Integer tags should be allocated using the
OEGetTag
function. Multiple calls to
OEBase::AddData
of a
OEBase derived class instance will result in multiple copies of
data being stored. The OEBase::AddData
method
does not overwrite data
stored by previous calls.
template<typename T>
bool AddData(const char *tag, const T t, unsigned int len)
template<typename T>
bool AddData(unsigned int tag, const T t, unsigned int len)
Stores and associates a copy of the data
pointed to by the second argument with the ‘tag’ identifier given
as the first argument. The third argument passed to the method
is used to denote the length of the array pointed to by the
second argument. The array length must be specified so that
data can be copied directly. Integer tags should be allocated
using the OEGetTag
function. Multiple calls to
OEBase::AddData
of a OEBase
derived class instance will result in
multiple copies of data being stored. The
OEBase::AddData
method does
not overwrite data stored by previous calls.
Clear¶
void Clear()
Clears all data stored using the OEBase::AddData
and
OEBase::SetData
methods.
When writing classes derived from OEBase the
OEBase::Clear
method should be chained to call
the parent class OEBase::Clear
method.
CreateCopy¶
OEBase *CreateCopy() const =0
This pure virtual copy constructor should return a deep copy of the OEBase derived object. The copy of the object returned is dynamically allocated and should be deallocated using the C++ delete operator.
DeleteData¶
bool DeleteData(const char *tag)
bool DeleteData(unsigned int tag)
Deletes all instances of data stored with the
OEBase::AddData
and OEBase::SetData
methods which are associated with the data
‘tag’ passed to the method. The method will return true
if any
data was deleted, and false
if not data associated with the
data tag was found.
GetBoolData¶
bool GetBoolData(const char *tag) const
bool GetBoolData(unsigned int tag) const
Returns the first instance of boolean data stored
previously with the associated data tag. This method is
equivalent to calling the OEBase::GetData
method with template argument bool.
GetData¶
template<typename T>
const T &GetData(const char *tag) const
template<typename T>
const T &GetData(unsigned int tag) const
Returns the first instance of data stored
previously with the associated data tag. Integer tags should be
allocated using the OEGetTag
function. Run-time
type checking is performed when data is requested. A data type
mismatch between the storage and request types will result in a
default data instance being returned instead of the original
data. Request for datum not present will also result in a
default data instance being returned.
GetDataIter¶
OESystem::OEIterBase<OESystem::OEBaseData> *GetDataIter() const
Returns an iterator over data stored in an OEBase derived class instance. Data tag identification, run-time type checking, and data retrieval can be performed using the OEBaseData API.
See also
OEBaseDataT template class
OESystem::OEIterBase<OESystem::OEBaseData> *GetDataIter(unsigned int tag) const
Returns an iterator over all generic data attached to the OEBase object with the given data tag.
See also
OEBaseDataT template class
GetDataType¶
const void *GetDataType() const =0
This pure virtual function is used to perform run-time type
identification. The value returned by the method should be
equivalent to the value returned by OEGetDataType
using the derived class type as the template argument.
GetDoubleData¶
double GetDoubleData(const char *tag) const
double GetDoubleData(unsigned int tag) const
Returns the first instance of double precision
floating point data stored previously with the associated data
tag. This method is equivalent to calling the
OEBase::GetData
method
with template argument double
.
GetFloatData¶
float GetFloatData(const char *tag) const
float GetFloatData(unsigned int tag) const
Returns the first instance of single precision
floating point data stored previously with the associated data
tag. This method is equivalent to calling the
OEBase::GetData
method
with template argument float
.
GetIntData¶
int GetIntData(const char *tag) const
int GetIntData(unsigned int tag) const
Returns the first instance of integer data stored
previously with the associated data tag. This method is
equivalent to calling the OEBase::GetData
method with template argument int
.
GetStringData¶
const std::string &GetStringData(const char *tag) const
const std::string &GetStringData(unsigned int tag) const
Returns the first instance of an STL string stored
previously with the associated data tag. This method is
equivalent to calling the OEBase::GetData
method with template argument std::string
.
HasData¶
bool HasData(const char *tag) const
bool HasData(unsigned int tag) const
Returns true
if any data stored in an OEBase
derived object is associated with a particular data tag
identifier. If no stored data is associated with the passed data
‘tag’ the methods return false
.
IsDataType¶
bool IsDataType(const void *) const =0
This method is used for run-time type identification of OEBase
derived classes. The const void pointer argument passed to the
function should be a value returned by the template function
OEGetDataType
. The OEBase::IsDataType
method will return
true
if the data type identifier passed to the function matches
at least one of the data types in the inheritance tree of the
requested OEBase derived object. The method will return false
if the data type identifier passed to the method fails to match
any class type in the inheritance tree of the requested OEBase
derived object. Implementations of this pure virtual method
should chain to their parent class’ OEBase::IsDataType
method.
SetBaseData¶
bool SetBaseData(const OEBaseData *)
SetBoolData¶
bool SetBoolData(const char *tag, bool t)
bool SetBoolData(unsigned int tag, bool t)
Stores boolean values associated with the passed data
‘tag’ identifiers. The methods are equivalent to the
OEBase::SetData
method
called with a boolean value.
SetData¶
template<typename T>
bool SetData(const char *tag, const T t)
template<typename T>
bool SetData(unsigned int tag, const T t)
Stores a copy of primitive or user-defined
data passed as the second argument with a data ‘tag’ identifier
passed as the first argument. If data of the same type has been
stored using the identical tag in a previous
OEBase::AddData
or OEBase::SetData
call, subsequent calls to OEBase::SetData
will
overwrite the first instance
of data stored with the data tag. If a call to SetData succeeds in
storing or overwriting previously stored data the method will
return true
. OEBase::SetData
will return
false
if a copy of the data cannot
be made. If data has been stored previously associated with a data
tag, subsequent calls to OEBase::SetData
with
the identical data ‘tag’ but
with different data type will result in a run-time warning being
written and a return value of false
. Note that these methods will
not make copies of data passed by pointer. Values to be passed by
pointer, or arrays, should be stored using the following
OEBase::SetData
methods.
template<typename T>
bool SetData(const char *tag, const T t, unsigned int len)
template<typename T>
bool SetData(unsigned int tag, const T t, unsigned int len)
Stores copies of arrays of primitive or
user-defined data passed as the second argument with a data tag
identifier passed as the first argument. The length of the array
(number of elements) is passed as the third argument to the
method. If data of the same type has been stored using the
identical ‘tag’ in a previous OEBase::AddData
or
OEBase::SetData
call, subsequent
calls to OEBase::SetData
will overwrite the
first instance of data
stored with the data tag. The array copy stored previously will
be deallocated and a copy of the new array will be stored. If a
call to OEBase::SetData
succeeds in storing
or overwriting an array
stored previously the method will return true
.
OEBase::SetData
will
return false
if a copy of the data cannot be made. If data has
been stored previously associated with a data tag, subsequent
calls to OEBase::SetData
with the identical data
‘tag’ but with different
data type will result in a run-time warning being written and a
return value of false
.
SetDoubleData¶
bool SetDoubleData(const char *tag, double t)
bool SetDoubleData(unsigned int tag, double t)
Stores and associates double precision floating
point values passed as the second argument with the data tag
provided as the first argument. The methods are provided for
convenience and are functionally equivalent to calls to
OEBase::SetData
where the template argument is a double precision floating point
number.
SetFloatData¶
bool SetFloatData(const char *tag, float t)
bool SetFloatData(unsigned int tag, float t)
Stores and associates single precision floating
point values passed as the second argument with the data tag
provided as the first argument. The methods are provided for
convenience and are functionally equivalent to calls to
OEBase::SetData
where the template argument is a single precision floating point
number.
SetIntData¶
bool SetIntData(const char *tag, int t)
bool SetIntData(unsigned int tag, int t)
Stores and associates integer values passed as the
second argument with the data ‘tag’ provided as the first
argument. The methods are provided for convenience and are
functionally equivalent to calls to
OEBase::SetData
where the template
argument is an integer value.
SetStringData¶
bool SetStringData(const char *tag, const std::string t)
bool SetStringData(unsigned int tag, const std::string t)
Stores and associates std::string
passed as the
second argument with the data ‘tag’ provided as the first
argument. The methods are provided for convenience and are
functionally equivalent to calls to OEBase::SetData
where the template argument is a std::string
.