matador::object_holder Class Referenceabstract

Base class for the object pointer and reference class. More...

#include <object_holder.hpp>

Inherits matador::identifiable_holder.

Inherited by matador::object_ptr< T >.

Public Member Functions

bool operator== (const object_holder &x) const
 
bool operator== (std::nullptr_t) const
 
bool operator!= (const object_holder &x) const
 
bool operator!= (std::nullptr_t) const
 
 operator bool () const noexcept
 
void reset (object_proxy *proxy, cascade_type cascade)
 
void reset (object_proxy *proxy, cascade_type cascade, bool notify_foreign_relation)
 
void reset (object_holder &holder)
 
void reset (const identifier &id) override
 
void clear ()
 
bool empty () const noexcept
 
bool valid () const noexcept
 
bool is_loaded () const
 
unsigned long long id () const
 
object_storestore () const
 
void * ptr ()
 
const void * ptr () const
 
void * lookup_object ()
 
void * lookup_object () const
 
bool is_internal () const
 
bool is_inserted () const
 
bool has_primary_key () const override
 
const identifierprimary_key () const override
 
identifierprimary_key () override
 
unsigned long reference_count () const
 
virtual const char * type () const =0
 
cascade_type cascade () const
 
- Public Member Functions inherited from matador::identifiable_holder
virtual identifier create_identifier () const =0
 

Protected Member Functions

 object_holder ()=default
 Creates and empty base pointer.
 
 object_holder (const object_holder &x)
 
 object_holder (object_holder &&x) noexcept
 
object_holderoperator= (const object_holder &x)
 
object_holderoperator= (object_holder &&x) noexcept
 
 object_holder (object_proxy *proxy)
 Creates an object_holder with a given object_proxy.
 
 ~object_holder () override
 

Friends

class object_serializer
 
class object_proxy
 
class detail::object_deleter
 
class detail::object_inserter
 
class object_store
 
class abstract_container
 
class detail::object_proxy_accessor
 
template<class T >
class container_item_holder
 
template<class L , class R >
class has_many_to_many_item
 
class session
 
template<class T >
class object_ptr
 
struct detail::basic_relation_endpoint
 
MATADOR_OBJECT_API std::ostream & operator<< (std::ostream &out, const object_holder &x)
 

Detailed Description

Base class for the object pointer and reference class.

This is the base class for the object pointer and reference class. The class holds the proxy of the object and the id of the object.

Constructor & Destructor Documentation

◆ object_holder() [1/4]

matador::object_holder::object_holder ( )
protecteddefault

Creates and empty base pointer.

Creates and empty base pointer. The boolean tells the class if the object is handled as a reference or an pointer. The difference is that the reference couldn't be deleted from the object_store and the pointer can.

◆ object_holder() [2/4]

matador::object_holder::object_holder ( const object_holder x)
protected

Copies from another object_holder

Parameters
xthe object_holder to copy from.

◆ object_holder() [3/4]

matador::object_holder::object_holder ( object_holder &&  x)
protectednoexcept

Copy move constructor

Parameters
xobject holder to copy move

◆ object_holder() [4/4]

matador::object_holder::object_holder ( object_proxy *  proxy)
explicitprotected

Creates an object_holder with a given object_proxy.

Creates an object_holder with a given object_proxy. The boolean tells the object_holder if it should be handled as an internal.

Parameters
proxyThe object_proxy of the object_holder

◆ ~object_holder()

matador::object_holder::~object_holder ( )
overrideprotected

Destroys the object_holder and decides whether the underlying object_proxy is destroyed as well.

It is destroyed if it is not inserted into any object_store.

Member Function Documentation

◆ cascade()

cascade_type matador::object_holder::cascade ( ) const

Returns the cascade type of the holder

Returns
The cascade type

◆ clear()

void matador::object_holder::clear ( )

Clears the currently set object

◆ empty()

bool matador::object_holder::empty ( ) const
noexcept

Returns true if object_holder doesn't holds an object

Returns
True if object_holder doesn't holds an object

◆ has_primary_key()

bool matador::object_holder::has_primary_key ( ) const
overridevirtual

Returns true if object has a primary key

Returns
true if object has a primary key

Implements matador::identifiable_holder.

◆ id()

unsigned long long matador::object_holder::id ( ) const

Returns the object id.

Returns
The id of the object.

◆ is_inserted()

bool matador::object_holder::is_inserted ( ) const

Returns true if the underlying object is inserted in an object_store

Returns
True if object is inserted.

◆ is_internal()

bool matador::object_holder::is_internal ( ) const

Returns if this object_holder is inside of the object_store. This is important to calculate the reference and pointer counter.

Returns
True if the object_holder internal

◆ is_loaded()

bool matador::object_holder::is_loaded ( ) const

Returns if the object is loaded.

Returns
True if the object is loaded.

◆ lookup_object() [1/2]

void * matador::object_holder::lookup_object ( )

Returns the object pointer

Returns
The object pointer.

◆ lookup_object() [2/2]

void * matador::object_holder::lookup_object ( ) const

Returns the object pointer

Returns
The object pointer.

◆ operator bool()

matador::object_holder::operator bool ( ) const
explicitnoexcept

Returns true if holder holds a valid proxy/object.

Returns
True if proxy/object is not nullptr

◆ operator!=() [1/2]

bool matador::object_holder::operator!= ( const object_holder x) const

Not equal to operator for the object_holder

Parameters
xThe object_holder to check unequality with.
Returns
True if the holder objects are not the same

◆ operator!=() [2/2]

bool matador::object_holder::operator!= ( std::nullptr_t  ) const

Checks equality with a nullptr

Returns
True if the holder objects isn't nullptr

◆ operator=() [1/2]

object_holder & matador::object_holder::operator= ( const object_holder x)
protected

Assign operator.

Parameters
xThe object_holder to assign from.

◆ operator=() [2/2]

object_holder & matador::object_holder::operator= ( object_holder &&  x)
protectednoexcept

Assign move constructor

Parameters
xobject holder to assign move
Returns
The moved object holder

◆ operator==() [1/2]

bool matador::object_holder::operator== ( const object_holder x) const

Equal to operator for the object_holder

Parameters
xThe object_holder to check equality with.
Returns
True if the holder objects are the same

◆ operator==() [2/2]

bool matador::object_holder::operator== ( std::nullptr_t  ) const

Checks equality with a nullptr

Returns
True if the holder objects is nullptr

◆ primary_key() [1/2]

const identifier & matador::object_holder::primary_key ( ) const
overridevirtual

Gets the primary key of the foreign object

Returns
The primary key of the foreign object

Implements matador::identifiable_holder.

◆ primary_key() [2/2]

identifier & matador::object_holder::primary_key ( )
overridevirtual

◆ ptr() [1/2]

void * matador::object_holder::ptr ( )

Returns the raw object pointer

Returns
The raw object pointer.

◆ ptr() [2/2]

const void * matador::object_holder::ptr ( ) const

Returns the raw object pointer

Returns
The raw object pointer.

◆ reference_count()

unsigned long matador::object_holder::reference_count ( ) const

Returns the current reference count

Returns
The current reference count

◆ reset() [1/4]

void matador::object_holder::reset ( const identifier id)
overridevirtual

Resets the object_holder with the given identifier. If the type of identifier differs from internal type an exception is thrown

Parameters
idThe identifier to set

Implements matador::identifiable_holder.

◆ reset() [2/4]

void matador::object_holder::reset ( object_holder holder)

Resets the object holder with the given object holder.

Parameters
holderThe object holder to be used to reset

◆ reset() [3/4]

void matador::object_holder::reset ( object_proxy *  proxy,
cascade_type  cascade 
)

Resets the object_holder with the given object_proxy.

Parameters
proxyThe new object_proxy for the object_holder.
cascadeSets the cascade actions for the proxy.

◆ reset() [4/4]

void matador::object_holder::reset ( object_proxy *  proxy,
cascade_type  cascade,
bool  notify_foreign_relation 
)

Resets the object_holder with the given object_proxy.

Parameters
proxyThe new object_proxy for the object_holder.
cascadeSets the cascade actions for the proxy.
notify_foreign_relationTrue if foreign relation endpoint should be modified

◆ store()

object_store * matador::object_holder::store ( ) const

Returns the corresponding object_store or nullptr

◆ type()

virtual const char * matador::object_holder::type ( ) const
pure virtual

Return the type string of the object

Returns
The type string of the object.

Implemented in matador::object_ptr< T >.

◆ valid()

bool matador::object_holder::valid ( ) const
noexcept

Returns true if object_holder holds a valid object

Returns
True if object_holder holds an object

Friends And Related Symbol Documentation

◆ operator<<

MATADOR_OBJECT_API std::ostream & operator<< ( std::ostream &  out,
const object_holder x 
)
friend

Prints the underlying object

Parameters
outThe output stream to write on.
xThe object pointer to print.
Returns
The output stream.

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