Holds the prototype of a concrete serializable. More...

#include <prototype_node.hpp>

Public Member Functions

 prototype_node (const prototype_node &)=delete
 
prototype_nodeoperator= (const prototype_node &)=delete
 
template<class T >
 prototype_node (object_store *tree, const char *type, T *proto, bool abstract=false)
 Creates a new prototype_node.
 
void initialize (object_store *tree, const char *type, bool abstract)
 Initializes a prototype_node.
 
bool empty (bool self) const
 
unsigned long size () const
 
const char * type () const
 
const char * type_id () const
 
void append (prototype_node *sibling)
 
void insert (prototype_node *child)
 
void insert (object_proxy *proxy)
 
void remove (object_proxy *proxy)
 Removes an serializable proxy from prototype node.
 
void clear (bool recursive)
 
void unlink ()
 
template<class T >
T * create () const
 
prototype_nodenext_node () const
 
prototype_nodenext_node (const prototype_node *root) const
 
prototype_nodeprevious_node () const
 
prototype_nodeprevious_node (const prototype_node *root) const
 
object_storetree () const
 
bool is_child_of (const prototype_node *prnt) const
 
bool has_children () const
 
bool has_primary_key () const
 
const identifierid () const
 Returns a pointer to the identifier prototype.
 
bool is_abstract () const
 Returns true if the node represents an abstract object.
 
std::type_index type_index () const
 Return the type index of the represented object type.
 
bool is_relation_node () const
 
const relation_node_info & node_info () const
 
template<class T >
void register_observer (typed_object_store_observer< T > *obs)
 
template<class T >
T * prototype () const
 
object_proxy * find_proxy (const identifier &pk)
 
void register_relation_endpoint (const std::type_index &tindex, const std::shared_ptr< detail::basic_relation_endpoint > &endpoint)
 
void unregister_relation_endpoint (const std::type_index &tindex)
 

Static Public Member Functions

template<class T >
static prototype_nodemake_node (object_store *store, const char *type, T *prototype, bool abstract=false)
 
template<class T >
static prototype_nodemake_relation_node (object_store *store, const char *type, T *item, bool abstract, const char *owner_type, const char *relation_id)
 

Friends

class object_holder
 
class object_store
 
template<class T >
class object_view
 
template<class T >
class const_object_view_iterator
 
template<class T >
class object_view_iterator
 
template<class T , template< class ... > class C>
class container
 
template<class T , template< class U=T > class O>
class detail::node_analyzer
 
class detail::object_inserter
 
MATADOR_OBJECT_API std::ostream & operator<< (std::ostream &stream, const prototype_node &node)
 

Detailed Description

Holds the prototype of a concrete serializable.

The prototype_node class holds the prototype of a concrete serializable inside a producer serializable. Whenever requested the class produces a new serializable.

It also holds a partial list containing all objects of this and all children nodes. This list is defined by three marker: the beginning of the list, the end of the own objects and the end of the last child objects.

Constructor & Destructor Documentation

◆ prototype_node()

template<class T >
matador::prototype_node::prototype_node ( object_store tree,
const char *  type,
T *  proto,
bool  abstract = false 
)
inline

Creates a new prototype_node.

Creates a new prototype_node which creates an serializable from given object_base_producer. The node gets the given type name t.

Parameters
treeThe node containing tree.
typeThe type name of the node.
protoPrototype object of the node
abstractTells the node if its prototype is abstract.

Member Function Documentation

◆ append()

void matador::prototype_node::append ( prototype_node sibling)

Appends the given prototype node as a sibling on the same level.

Parameters
siblingThe new sibling node.

◆ clear()

void matador::prototype_node::clear ( bool  recursive)

Delete all objects inside this node if recursive flag is set, delete all objects below this node as well. To adjust the serializable proxy marker for the capacity objects the corresponding prototype tree must be passed

Parameters
recursiveIndicates whether all or only nodes objects are deleted

◆ create()

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

Create the represented object. The type is checked. If the type is invalid nullptr is returned.

Template Parameters
TType of object to create
Returns
A new instance or nullptr

◆ empty()

bool matador::prototype_node::empty ( bool  self) const

Returns true if serializable proxy list is empty. If self is true, only list of own objects is checked. If self is false, complete list is checked.

Parameters
selfIf true only elements inside this node are considered.
Returns
True if the node is empty.

◆ find_proxy()

object_proxy * matador::prototype_node::find_proxy ( const identifier pk)

Find the underlying proxy of the given primary key. If no proxy is found nullptr is returned

Parameters
pkThe primary key
Returns
The corresponding object_proxy or nullptr

◆ has_children()

bool matador::prototype_node::has_children ( ) const

Returns true if node has children.

Returns
True if node has children.

◆ has_primary_key()

bool matador::prototype_node::has_primary_key ( ) const

Returns true if the serializable represented by this node owns a primary key

Returns
True if serializable owns a primary key

◆ id()

const identifier & matador::prototype_node::id ( ) const

Returns a pointer to the identifier prototype.

Returns
A pointer to the identifier prototype

◆ initialize()

void matador::prototype_node::initialize ( object_store tree,
const char *  type,
bool  abstract 
)

Initializes a prototype_node.

Initializes a prototype_node. The node gets the given type name alias t.

Parameters
treeThe node containing tree.
typeThe type name of this node.
abstractTells the node if its prototype is abstract.

◆ insert() [1/2]

void matador::prototype_node::insert ( object_proxy *  proxy)

Inserts a serializable proxy into the

◆ insert() [2/2]

void matador::prototype_node::insert ( prototype_node child)

Appends the given prototype node to the list of children.

Parameters
childThe child node to add.

◆ is_abstract()

bool matador::prototype_node::is_abstract ( ) const

Returns true if the node represents an abstract object.

Returns
True if the node represents an abstract object

◆ is_child_of()

bool matador::prototype_node::is_child_of ( const prototype_node prnt) const

Returns true if node is child of given parent node.

Parameters
prntThe parent node.
Returns
True if node is child of given parent node.

◆ is_relation_node()

bool matador::prototype_node::is_relation_node ( ) const

Returns true if this node represents a relation node (has_many_item<T>).

Returns
True if this node represents a relation node.

◆ make_node()

template<class T >
prototype_node * matador::prototype_node::make_node ( object_store store,
const char *  type,
T *  prototype,
bool  abstract = false 
)
static

Creates a regular prototype node.

Template Parameters
TType of the node
Parameters
storeCorresponding object_store
typeType name
prototypeThe one prototype object
abstractFlag indicating if node is abstract.
Returns
The created node.

◆ make_relation_node()

template<class T >
prototype_node * matador::prototype_node::make_relation_node ( object_store store,
const char *  type,
T *  item,
bool  abstract,
const char *  owner_type,
const char *  relation_id 
)
static

Creates a relation prototype node.

Template Parameters
TType of the node
Parameters
storeCorresponding object_store
typeType name
itemPrototype item
abstractFlag indicating if node is abstract.
owner_typeType name of the owner node
relation_idName of the relation in the prototype object
Returns
The created node.

◆ next_node() [1/2]

prototype_node * matador::prototype_node::next_node ( ) const

Returns nodes successor node or NULL if node is last.

Returns
The next node.

◆ next_node() [2/2]

prototype_node * matador::prototype_node::next_node ( const prototype_node root) const

Returns nodes successor node or nullptr if node is last. Where given root node is the sentinel not to pass while traversing

Parameters
rootThe sentinel root node not to pass.
Returns
The next node.

◆ node_info()

const relation_node_info & matador::prototype_node::node_info ( ) const

Returns the relation node info. This struct contains only valid data if this node represents a n relation node (has_many_item<T>).

Returns

◆ previous_node() [1/2]

prototype_node * matador::prototype_node::previous_node ( ) const

Return nodes predecessor node or NULL if node is first.

Returns
The previous node.

◆ previous_node() [2/2]

prototype_node * matador::prototype_node::previous_node ( const prototype_node root) const

Returns nodes predeccessor node or nullptr if node is last. Where given root node is the sentinel not to pass while traversing

Parameters
rootThe sentinel root node not to pass.
Returns
The previous node.

◆ prototype()

template<class T >
T * matador::prototype_node::prototype ( ) const

Returns the prototype object of the node

Template Parameters
TThe object type of the prototype object
Returns
The prototype object

◆ register_observer()

template<class T >
void matador::prototype_node::register_observer ( typed_object_store_observer< T > *  obs)

Registers an object store observer for the object type of the node. The observer is notified on attach, detach, insert, update and delete.

Template Parameters
TThe object type of the observer
Parameters
obsThe observer to register

◆ register_relation_endpoint()

void matador::prototype_node::register_relation_endpoint ( const std::type_index &  tindex,
const std::shared_ptr< detail::basic_relation_endpoint > &  endpoint 
)

Register relation_field_endpoint identified by the given type index.

Parameters
tindextype index for identification.
endpointpointer to a relation_field_endpoint object

◆ remove()

void matador::prototype_node::remove ( object_proxy *  proxy)

Removes an serializable proxy from prototype node.

Parameters
proxyObject proxy to remove

◆ size()

unsigned long matador::prototype_node::size ( ) const

Returns the size of the serializable proxy list.

Returns
The number of objects.

◆ tree()

object_store * matador::prototype_node::tree ( ) const

Returns the corresponding tree/object_store

Returns
The corresponding object_store

◆ type()

const char * matador::prototype_node::type ( ) const

Return the type name of this node.

Returns
The type name

◆ type_id()

const char * matador::prototype_node::type_id ( ) const

Return the type id of this node.

Returns
The type id

◆ type_index()

std::type_index matador::prototype_node::type_index ( ) const

Return the type index of the represented object type.

Returns
Type index of the represented object type

◆ unlink()

void matador::prototype_node::unlink ( )

Unlinks node from list.

◆ unregister_relation_endpoint()

void matador::prototype_node::unregister_relation_endpoint ( const std::type_index &  tindex)

Unregister relation_field_endpoint identified by the given type index.

Parameters
tindex

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