The base class for all objects. More...

#include <object.hpp>

Inherits oos::object_atomizable.

Inherited by oos::value_item< T >.

Public Member Functions

 object ()
 Create a new object. More...
 
virtual ~object ()
 
virtual void deserialize (object_reader &deserializer)
 
virtual void serialize (object_writer &serializer) const
 
const char * classname () const
 Returns the classname of the object. More...
 
long id () const
 Returns the unique identifier of the object. More...
 
void id (long oid)
 Sets the id of the object. More...
 
object_storeostore () const
 Returns the object store. More...
 
template<class T >
bool set (const std::string &name, const T &val)
 
template<class T >
bool get (const std::string &name, T &val)
 
template<class T >
bool get (const std::string &name, T &val, int precision)
 
template<class T >
void modify (T &attr, const T &val)
 
void modify (char *attr, int max_size, const char *val, int size)
 
template<class T >
void modify (oos::object_ref< T > &attr, const oos::object_ptr< T > &val)
 
void modify (varchar_base &attr, const std::string &val)
 
void modify (varchar_base &attr, const varchar_base &val)
 

Protected Member Functions

object_proxy * proxy () const
 Returns the object_proxy of the object. More...
 
void mark_modified ()
 Marks this object as modified in its object_store. More...
 

Friends

class object_store
 
class object_deleter
 
class object_base_ptr
 
class object_serializer
 
class object_container
 
class object_value_base
 
class table
 
class relation_filler
 
class query
 
class database
 
OOS_API std::ostream & operator<< (std::ostream &os, const object &o)
 

Detailed Description

The base class for all objects.

The object class must be the base class of all classes inserted into the object_store. At least the object_store handles with objects of base type object. When iterating over a view these objects are casted to the concrete type.

The object is identified by a unique id, which is set by the object_store.

Constructor & Destructor Documentation

oos::object::object ( )

Create a new object.

Creates a new object, which is not member of the object_store.

virtual oos::object::~object ( )
virtual

Destroys the object.

Member Function Documentation

const char* oos::object::classname ( ) const

Returns the classname of the object.

Returns the classname of the object if the object isn't stored in the object store 'nullptr' is returned

Returns
Name of the object type or nullptr
virtual void oos::object::deserialize ( object_reader deserializer)
inlinevirtual

Deserializes an object from the given object_atomizer object.

Parameters
deserializerThe object_atomizer to deserialize from.

Implements oos::object_atomizable.

Reimplemented in oos::container_item< T, C >, and oos::value_item< T >.

template<class T >
bool oos::object::get ( const std::string &  name,
T &  val 
)
inline

Gets the value of a member identified by the given name. If the operation succeeds true is returned.

Template Parameters
TThe type of the value to retrieve.
Parameters
nameThe name of the member variable.
valThe reference where the value is assigned to.
Returns
True if the operation succeeds.
template<class T >
bool oos::object::get ( const std::string &  name,
T &  val,
int  precision 
)
inline

Gets the value of a member identified by the given name. If the operation succeeds true is returned.

Template Parameters
TThe type of the value to retrieve.
Parameters
nameThe name of the member variable.
valThe reference where the value is assigned to.
precisionThe precision of the value to get.
Returns
True if the operation succeeds.
long oos::object::id ( ) const

Returns the unique identifier of the object.

This method returns the unique id of the object. These id is first set when the object is inserted into the object_store. On creation the value of the id is zero.

Returns
The unique id of the object.
void oos::object::id ( long  oid)

Sets the id of the object.

Sets the id of the object.

Parameters
oidThe new id of the object.
void oos::object::mark_modified ( )
protected

Marks this object as modified in its object_store.

Marks this object as modified in its object_store. This method must be called before modifing a derived object. Otherwise the object can't be restored on an error or rollback.

template<class T >
void oos::object::modify ( T &  attr,
const T &  val 
)
inline

Modify the attribute assigning the new given value to attributes reference.

Template Parameters
TType of attribute to change.
Parameters
attrRefernce to attribute to change.
valNew value for attribute.
void oos::object::modify ( char *  attr,
int  max_size,
const char *  val,
int  size 
)
inline

Modify the char attribute assigning the new given char value to attributes reference.

Parameters
attrPointer to character string to change.
max_sizeThe maximum capacity of the destinition array.
valNew stringto set.
sizeThe length of the new string.
Exceptions
std::logic_error.
template<class T >
void oos::object::modify ( oos::object_ref< T > &  attr,
const oos::object_ptr< T > &  val 
)
inline

Modify an object_ptr attribute assigning the new given value to attributes reference.

Template Parameters
TType of object_ptr to change.
Parameters
attrRefernce to object_ptr to change.
valNew value for object_ptr.
void oos::object::modify ( varchar_base &  attr,
const std::string &  val 
)
inline

Modify a varchar_base attribute assigning the new given value to attributes reference.

Parameters
attrRefernce to varchar_base to change.
valNew value for varchar_base.
void oos::object::modify ( varchar_base &  attr,
const varchar_base &  val 
)
inline

Modify a varchar_base attribute assigning the new given value to attributes reference.

Parameters
attrRefernce to varchar_base to change.
valNew value for varchar_base.
object_store* oos::object::ostore ( ) const

Returns the object store.

Returns the object_store into which this object was inserted. If this object wasn't inserted NULL is returned.

Returns
The object_store to which the object belongs.
object_proxy* oos::object::proxy ( ) const
inlineprotected

Returns the object_proxy of the object.

Returns the object_proxy of the object. If the object isn't inserted into a object_store NULL is returned.

Returns
The object_proxy of the object.
virtual void oos::object::serialize ( object_writer serializer) const
inlinevirtual

Serializes an object to the given object_atomizer object.

Parameters
serializerThe object_atomizer to serialize to.

Implements oos::object_atomizable.

Reimplemented in oos::container_item< T, C >, and oos::value_item< T >.

template<class T >
bool oos::object::set ( const std::string &  name,
const T &  val 
)
inline

Sets a value of a member identified by the given name. If the operation succeeds true is returned.

Template Parameters
TThe type of the value to set.
Parameters
nameThe name of the member variable.
valThe new value for the member.
Returns
True if the operation succeeds.

Friends And Related Function Documentation

OOS_API std::ostream& operator<< ( std::ostream &  os,
const object o 
)
friend

Print the object to a given stream

Parameters
osThe stream to write the object on.
oThe object to write
Returns
The modified stream.

The documentation for this class was generated from the following file:
  • object/object.hpp