matador::object_store Class Reference

A class that stores all kind of objects. More...

#include <object_store.hpp>

Public Types

enum  abstract_type { abstract , not_abstract }
 
typedef prototype_iterator iterator
 
typedef const_prototype_iterator const_iterator
 

Public Member Functions

 object_store (const object_store &)=delete
 
object_storeoperator= (const object_store &)=delete
 
 object_store ()
 
 ~object_store ()
 
template<class T >
prototype_iterator attach (const char *type, const char *parent=nullptr)
 
template<class T >
prototype_iterator attach_abstract (const char *type, const char *parent=nullptr)
 
template<class T , class S >
prototype_iterator attach (const char *type)
 
template<class T , class S >
prototype_iterator attach_abstract (const char *type)
 
template<class T >
prototype_iterator attach (const char *type, abstract_type abstract, const char *parent)
 
template<class T , template< class U=T > class O>
prototype_iterator attach (const char *type, std::initializer_list< O< T > * > observer={})
 
template<class T , class S , template< class U=T > class O>
prototype_iterator attach (const char *type, std::initializer_list< O< T > * > observer={})
 
template<class T , class S , template< class U=T > class O>
prototype_iterator attach_abstract (const char *type, std::initializer_list< O< T > * > observer)
 
template<class T , template< class U=T > class O>
prototype_iterator attach (const char *type, abstract_type abstract, const char *parent, std::initializer_list< O< T > * > observer)
 
template<class T , template< class U=T > class O>
prototype_iterator attach (prototype_node *node, const char *parent, std::initializer_list< O< T > * > observer)
 
template<class T , template< class U=T > class O>
prototype_iterator attach (prototype_node *node, std::initializer_list< O< T > * > observer)
 
template<class T >
prototype_iterator attach (prototype_node *node, const char *parent=nullptr)
 
template<class T , template< class U=T > class O>
prototype_iterator attach_internal (prototype_node *node, const char *parent, std::vector< O< T > * > observer)
 
void detach (const char *type)
 
iterator detach (const prototype_iterator &i)
 
template<class T >
std::string type () const
 
iterator find (const char *type)
 Finds prototype node.
 
const_iterator find (const char *type) const
 Finds prototype node.
 
template<class T >
iterator find ()
 Finds prototype node by template type.
 
template<class T >
const_iterator find () const
 Finds prototype node by template type.
 
template<class T >
object_ptr< T > get (const identifier &pk)
 Get object by primary key.
 
const_iterator begin () const
 
iterator begin ()
 
const_iterator end () const
 
iterator end ()
 
void clear (bool full=false)
 
void clear (const char *type)
 
void clear (const prototype_iterator &node)
 
size_t size () const
 
bool empty () const
 
template<class T >
T * create () const
 
template<typename P >
void for_each_root_node (P pred) const
 
object_proxy * insert (object_proxy *proxy, bool notify)
 Inserts a new proxy into the object store.
 
template<class T >
object_ptr< T > insert (T *o)
 
template<class Type , typename... Args>
object_ptr< Type > insert (Args &&... args)
 
template<class T >
object_ptr< T > insert (const object_ptr< T > &o)
 
template<class T >
bool is_removable (const object_ptr< T > &o)
 
void remove_proxy (object_proxy *proxy)
 
void remove (object_proxy *proxy, bool check_if_deletable)
 
template<class T >
void remove (object_ptr< T > &o)
 
object_proxy * find_proxy (unsigned long long id) const
 Finds object proxy with id.
 
object_proxy * insert_proxy (object_proxy *proxy)
 
transaction current_transaction ()
 
bool has_transaction () const
 
void mark_modified (object_proxy *proxy)
 
template<class T >
void mark_modified (const object_ptr< T > &optr)
 
void on_proxy_delete (std::function< void(object_proxy *)> callback)
 

Friends

class detail::object_inserter
 
struct detail::basic_relation_endpoint
 
class object_serializer
 
class object_holder
 
class object_proxy
 
class prototype_node
 
class transaction
 
class detail::object_type_registry_entry_base
 
template<class T , template< class ... > class C>
class container
 

Detailed Description

A class that stores all kind of objects.

This class is the main container class for all objects. To manage the internal list of objects the store must know the object class hierarchy.

Therefor an object prototype tree holds the object hierarchy representation including a producer class object of all known types.

Member Typedef Documentation

◆ const_iterator

typedef const_prototype_iterator matador::object_store::const_iterator

Shortcut for the list const iterator.

◆ iterator

typedef prototype_iterator matador::object_store::iterator

Shortcut for the list iterator.

Member Enumeration Documentation

◆ abstract_type

Describes whether the inserted object type is handle as a concrete or abstract type

Enumerator
abstract 

Indicates an abstract object type

not_abstract 

Indicates a concrete object type

Constructor & Destructor Documentation

◆ object_store()

matador::object_store::object_store ( )

Create an empty object store.

◆ ~object_store()

matador::object_store::~object_store ( )

Destroys all prototypes, objects and observers in store.

Member Function Documentation

◆ attach() [1/9]

template<class T , class S >
prototype_iterator matador::object_store::attach ( const char *  type)
inline

Inserts a new concrete object prototype into the prototype tree. The prototype consists of a unique type name.

Template Parameters
TThe type of the prototype node
SThe type of the parent prototype node
Parameters
typeThe unique name of the type.
Returns
Returns new inserted prototype iterator.

◆ attach() [2/9]

template<class T >
prototype_iterator matador::object_store::attach ( const char *  type,
abstract_type  abstract,
const char *  parent 
)
inline

If the abstract flag is true prototype is treated as abstract. No concrete object can be inserted for this prototype.

Template Parameters
TThe type of the prototype node
Parameters
typeThe unique name of the type.
abstractIndicates if the producers object is treated as an abstract node.
parentName of the parent node
Returns
Returns new inserted prototype iterator.

◆ attach() [3/9]

template<class T , template< class U=T > class O>
prototype_iterator matador::object_store::attach ( const char *  type,
abstract_type  abstract,
const char *  parent,
std::initializer_list< O< T > * >  observer 
)
inline

Inserts a new abstract object prototype into the prototype tree. The prototype consists of a unique type name.

Template Parameters
TThe type of the prototype node
OThe type of the observer classes
Parameters
typeThe unique name of the type.
abstractIndicates weather type is abstract or not
parentThe name of the parent node.
observerA list of observer to be called an attach
Returns
Returns new inserted prototype iterator.

◆ attach() [4/9]

template<class T >
prototype_iterator matador::object_store::attach ( const char *  type,
const char *  parent = nullptr 
)
inline

Inserts a new concrete object prototype into the object_store. The prototype consists of a unique type name. The type of the prototype is given via template parameter T. If parent name is given prototype node is inserted below the found parent node.

Template Parameters
TType of the prototype
Parameters
typeName of the prototype
parentName of the parent node
Returns
Iterator representing the inserted prototype node

◆ attach() [5/9]

template<class T , template< class U=T > class O>
prototype_iterator matador::object_store::attach ( const char *  type,
std::initializer_list< O< T > * >  observer = {} 
)
inline

Inserts a new concrete object prototype into the prototype tree. The prototype consists of a unique type name.

Template Parameters
TThe type of the prototype node
OThe type of the observer classes
Parameters
typeThe unique name of the type.
observerA list of observer to be called an attach
Returns
Returns new inserted prototype iterator.

◆ attach() [6/9]

template<class T , class S , template< class U=T > class O>
prototype_iterator matador::object_store::attach ( const char *  type,
std::initializer_list< O< T > * >  observer = {} 
)
inline

Inserts a new concrete object prototype into the prototype tree. The prototype consists of a unique type name.

Template Parameters
TThe type of the prototype node
SThe type of the parent prototype node
OThe type of the observer classes
Parameters
typeThe unique name of the type.
observerA list of observer to be called an attach
Returns
Returns new inserted prototype iterator.

◆ attach() [7/9]

template<class T , template< class U=T > class O>
prototype_iterator matador::object_store::attach ( prototype_node node,
const char *  parent,
std::initializer_list< O< T > * >  observer 
)

Inserts a new object prototype into the object_store. The type of the prototype is given via template parameter T. A prepared prototype node is passed to be inserted. If parent name is given prototype node is inserted below the found parent node.

Template Parameters
TThe type of the prototype node
OThe type of the observer classes
Parameters
nodeThe prototype node to be inserted
parentThe name of the parent node.
observerA list of observer to be called an attach
Returns
Returns new inserted prototype iterator.

◆ attach() [8/9]

template<class T >
prototype_iterator matador::object_store::attach ( prototype_node node,
const char *  parent = nullptr 
)
inline

Inserts a new object prototype into the object_store. The type of the prototype is given via template parameter T. A prepared prototype node is passed to be inserted. If parent name is given prototype node is inserted below the found parent node.

Template Parameters
TThe type of the prototype node
Parameters
nodeThe prototype node to be inserted
parentThe name of the parent node.
Returns
Returns new inserted prototype iterator.

◆ attach() [9/9]

template<class T , template< class U=T > class O>
prototype_iterator matador::object_store::attach ( prototype_node node,
std::initializer_list< O< T > * >  observer 
)
inline

Inserts a new object prototype into the object_store as a root object type. The type of the prototype is given via template parameter T. A prepared prototype node is passed to be inserted.

Template Parameters
TThe type of the prototype node
OThe type of the observer classes
Parameters
nodeThe prototype node to be inserted
observerA list of observer to be called an attach
Returns
Returns new inserted prototype iterator.

◆ attach_abstract() [1/3]

template<class T , class S >
prototype_iterator matador::object_store::attach_abstract ( const char *  type)
inline

Inserts a new abstract object prototype into the prototype tree. The prototype consists of a unique type name.

Template Parameters
TThe type of the prototype node
SThe type of the parent prototype node
Parameters
typeThe unique name of the type.
Returns
Returns new inserted prototype iterator.

◆ attach_abstract() [2/3]

template<class T >
prototype_iterator matador::object_store::attach_abstract ( const char *  type,
const char *  parent = nullptr 
)
inline

Inserts a new abstract object prototype into the object_store. The prototype consists of a unique type name. The type of the prototype is given via template parameter T. If parent name is given prototype node is inserted below the found parent node.

Template Parameters
TType of the prototype
Parameters
typeName of the prototype
parentName of the parent node
Returns
Iterator representing the inserted prototype node

◆ attach_abstract() [3/3]

template<class T , class S , template< class U=T > class O>
prototype_iterator matador::object_store::attach_abstract ( const char *  type,
std::initializer_list< O< T > * >  observer 
)
inline

Inserts a new abstract object prototype into the prototype tree. The prototype consists of a unique type name.

Template Parameters
TThe type of the prototype node
SThe type of the parent prototype node
OThe type of the observer classes
Parameters
typeThe unique name of the type.
observerA list of observer to be called an attach
Returns
Returns new inserted prototype iterator.

◆ attach_internal()

template<class T , template< class U=T > class O>
prototype_iterator matador::object_store::attach_internal ( prototype_node node,
const char *  parent,
std::vector< O< T > * >  observer 
)

Inserts a new object prototype into the object_store as a root object type. The type of the prototype is given via template parameter T. A prepared prototype node is passed to be inserted.

Template Parameters
TThe type of the prototype node
OThe type of the observer classes
Parameters
nodeThe prototype node to be inserted
parentThe name of the parent node.
observerA list of observer to be called an attach
Returns
Returns new inserted prototype iterator.

◆ begin() [1/2]

iterator matador::object_store::begin ( )

Return the first prototype node.

Returns
The first prototype node iterator.

◆ begin() [2/2]

const_iterator matador::object_store::begin ( ) const

Return the first prototype node.

Returns
The first prototype node iterator.

◆ clear() [1/3]

void matador::object_store::clear ( bool  full = false)

Removes all inserted prototypes and all inserted objects.

◆ clear() [2/3]

void matador::object_store::clear ( const char *  type)

Clears a prototype node and its children nodes. All objects will be deleted.

Parameters
typeThe name of the type to remove.
Exceptions
matador::object_exceptionon error

◆ clear() [3/3]

void matador::object_store::clear ( const prototype_iterator &  node)

Clears a prototype node by an iterator and its children nodes. All object_proxy objects will be deleted.

Parameters
nodeThe prototype_iterator to remove.
Exceptions
matador::object_exceptionon error

◆ create()

template<class T >
T * matador::object_store::create ( ) const
inline

Creates an object of the given type name.

Returns
The created object on success or NULL if the type couldn't be found.

◆ current_transaction()

transaction matador::object_store::current_transaction ( )

Return the current transaction in stack

Returns
The current transaction in stack

◆ detach() [1/2]

void matador::object_store::detach ( const char *  type)

Removes an object prototype from the prototype tree. All children nodes and all objects are also removed.

Parameters
typeThe name of the type to remove.

◆ detach() [2/2]

iterator matador::object_store::detach ( const prototype_iterator &  i)

Erase a prototype node identified by its iterator. The successor iterator is returned.

Parameters
iThe prototype iterator to be erased
Returns
The successor of the erased iterator

◆ empty()

bool matador::object_store::empty ( ) const

Returns true if the object_store contains no elements (objects)

Returns
True on empty object_store.

◆ end() [1/2]

iterator matador::object_store::end ( )

Return the last prototype node.

Returns
The last prototype node iterator.

◆ end() [2/2]

const_iterator matador::object_store::end ( ) const

Return the last prototype node.

Returns
The last prototype node iterator.

◆ find() [1/4]

template<class T >
iterator matador::object_store::find ( )
inline

Finds prototype node by template type.

Template Parameters
Templatetype.

Finds and returns prototype node iterator identified by the given template typeid. If the prototype couldn't be found prototype_iterator end is returned.

Returns
Returns a prototype iterator.

◆ find() [2/4]

template<class T >
const_iterator matador::object_store::find ( ) const
inline

Finds prototype node by template type.

Template Parameters
Templatetype.

Finds and returns prototype node iterator identified by the given template typeid. If the prototype couldn't be found prototype_iterator end is returned.

Returns
Returns a prototype iterator.

◆ find() [3/4]

iterator matador::object_store::find ( const char *  type)

Finds prototype node.

Finds and returns prototype node iterator identified by the given name or classname (typeid). If the prototype couldn't be found prototype_iterator end is returned.

Parameters
typeName or class name of the prototype
Returns
Returns a prototype iterator.

◆ find() [4/4]

const_iterator matador::object_store::find ( const char *  type) const

Finds prototype node.

Finds and returns prototype node iterator identified by the given name or classname (typeid). If the prototype couldn't be found prototype_iterator end is returned.

Parameters
typeName or class name of the prototype
Returns
Returns a prototype iterator.

◆ find_proxy()

object_proxy * matador::object_store::find_proxy ( unsigned long long  id) const

Finds object proxy with id.

Try to find the object proxy with given id in object stores proxy map. If object can't be found NULL is returned.

Parameters
idID of object proxy to find
Returns
On success it returns an object proxy on failure null

◆ for_each_root_node()

template<typename P >
void matador::object_store::for_each_root_node ( pred) const
inline

Executes a predicate for each root node

Template Parameters
PThe type of the predicate function object
Parameters
predThe function object to be executed

◆ get()

template<class T >
object_ptr< T > matador::object_store::get ( const identifier pk)
inline

Get object by primary key.

Gets an object of given type and given primary key. If the object can't be found an empty object is returned.

Template Parameters
TThe type of the requested object.
Parameters
pkThe primary key value
Returns
The found object or an empty object

◆ has_transaction()

bool matador::object_store::has_transaction ( ) const

Returns true if there is at least one transaction on stack.

Returns
True if there at least one transaction.

◆ insert() [1/4]

template<class Type , typename... Args>
object_ptr< Type > matador::object_store::insert ( Args &&...  args)
inline

Inserts an object of a specific type. On successful insertion an object_ptr element with the inserted object is returned.

Template Parameters
TypeType of the object to insert
ArgsArgument types of the constructor arguments
Parameters
argsArguments to construct the object
Returns
Inserted object contained by an object_ptr on success.

◆ insert() [2/4]

template<class T >
object_ptr< T > matador::object_store::insert ( const object_ptr< T > &  o)
inline

Inserts a given object_ptr of specific type. On successfully insertion an object_ptr element with the inserted object is returned.

Parameters
oobject_ptr to be inserted.
Returns
Inserted object contained by an object_ptr on success.

◆ insert() [3/4]

object_proxy * matador::object_store::insert ( object_proxy *  proxy,
bool  notify 
)

Inserts a new proxy into the object store.

Parameters
proxyObject proxy to insert
notifyIndicates whether all observers should be notified.

◆ insert() [4/4]

template<class T >
object_ptr< T > matador::object_store::insert ( T *  o)
inline

Inserts an object of a specific type. On successful insertion an object_ptr element with the inserted object is returned.

Parameters
oObject to be inserted.
Returns
Inserted object contained by an object_ptr on success.

◆ insert_proxy()

object_proxy * matador::object_store::insert_proxy ( object_proxy *  proxy)

Insert object proxy into object store Object id must be set

◆ is_removable()

template<class T >
bool matador::object_store::is_removable ( const object_ptr< T > &  o)
inline

Returns true if the underlying object is removable.

Parameters
oThe object to check.
Returns
True if object is removable.

◆ mark_modified() [1/2]

template<class T >
void matador::object_store::mark_modified ( const object_ptr< T > &  optr)
inline

Marks the given object_ptr as modified and notifies all transactions

Template Parameters
TObject type of the object_ptr
Parameters
optrThe modified object_ptr

◆ mark_modified() [2/2]

void matador::object_store::mark_modified ( object_proxy *  proxy)

Marks the given object proxy as modified and notifies all transactions

Parameters
proxyThe modified object proxy

◆ on_proxy_delete()

void matador::object_store::on_proxy_delete ( std::function< void(object_proxy *)>  callback)

Registers a callback when an object proxy is deleted from the object store

Parameters
callbackTo be called when an object proxy is deleted

◆ remove() [1/2]

void matador::object_store::remove ( object_proxy *  proxy,
bool  check_if_deletable 
)

Remove the given object_proxy. The prototype_node id extracted from the given proxy to remove the proxy from its proxy list.

If the notify flag is true all observers are notified on successfully deletion.

If check_if_deletable flag is true method checks if the proxy is deletable.

Parameters
proxyThe object_proxy to be removed.
check_if_deletableIf true methods checks if proxy is deletable.

◆ remove() [2/2]

template<class T >
void matador::object_store::remove ( object_ptr< T > &  o)
inline

Removes an object from the object store. After successful removal the object is set to zero and isn't valid any more.

Before removal is done a reference and pointer counter check is done. If at least one counter is greater than zero the object can't be removed and false is returned.

Exceptions
object_exception
Parameters
oObject to remove.

◆ remove_proxy()

void matador::object_store::remove_proxy ( object_proxy *  proxy)

Remove the given object_proxy. The prototype_node id extracted from the given proxy to remove the proxy from its proxy list.

Parameters
proxyThe object_proxy to be removed.

◆ size()

size_t matador::object_store::size ( ) const

Return count of prototype nodes

Returns
Count of prototype nodes

◆ type()

template<class T >
std::string matador::object_store::type ( ) const
inline

Finds the typename to the given class. If no typename is found an empty string is returned.

Template Parameters
classtype to find
Returns
The corresponding typename

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