Holds the prototype of a concrete serializable. More...
#include <prototype_node.hpp>
Public Member Functions | |
prototype_node (const prototype_node &)=delete | |
prototype_node & | operator= (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_node * | next_node () const |
prototype_node * | next_node (const prototype_node *root) const |
prototype_node * | previous_node () const |
prototype_node * | previous_node (const prototype_node *root) const |
object_store * | tree () const |
bool | is_child_of (const prototype_node *prnt) const |
bool | has_children () const |
bool | has_primary_key () const |
const identifier & | id () 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_node * | make_node (object_store *store, const char *type, T *prototype, bool abstract=false) |
template<class T > | |
static prototype_node * | make_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) |
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.
|
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.
tree | The node containing tree. |
type | The type name of the node. |
proto | Prototype object of the node |
abstract | Tells the node if its prototype is abstract. |
void matador::prototype_node::append | ( | prototype_node * | sibling | ) |
Appends the given prototype node as a sibling on the same level.
sibling | The new sibling node. |
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
recursive | Indicates whether all or only nodes objects are deleted |
T * matador::prototype_node::create | ( | ) | const |
Create the represented object. The type is checked. If the type is invalid nullptr is returned.
T | Type of object to create |
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.
self | If true only elements inside this node are considered. |
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
pk | The primary key |
bool matador::prototype_node::has_children | ( | ) | const |
Returns true if node has children.
bool matador::prototype_node::has_primary_key | ( | ) | const |
Returns true if the serializable represented by this node owns a primary key
const identifier & matador::prototype_node::id | ( | ) | const |
Returns a pointer to the identifier prototype.
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.
tree | The node containing tree. |
type | The type name of this node. |
abstract | Tells the node if its prototype is abstract. |
void matador::prototype_node::insert | ( | object_proxy * | proxy | ) |
Inserts a serializable proxy into the
void matador::prototype_node::insert | ( | prototype_node * | child | ) |
Appends the given prototype node to the list of children.
child | The child node to add. |
bool matador::prototype_node::is_abstract | ( | ) | const |
Returns true if the node represents an abstract object.
bool matador::prototype_node::is_child_of | ( | const prototype_node * | prnt | ) | const |
Returns true if node is child of given parent node.
prnt | The parent node. |
bool matador::prototype_node::is_relation_node | ( | ) | const |
Returns true if this node represents a relation node (has_many_item<T>).
|
static |
Creates a regular prototype node.
T | Type of the node |
store | Corresponding object_store |
type | Type name |
prototype | The one prototype object |
abstract | Flag indicating if node is abstract. |
|
static |
Creates a relation prototype node.
T | Type of the node |
store | Corresponding object_store |
type | Type name |
item | Prototype item |
abstract | Flag indicating if node is abstract. |
owner_type | Type name of the owner node |
relation_id | Name of the relation in the prototype object |
prototype_node * matador::prototype_node::next_node | ( | ) | const |
Returns nodes successor node or NULL if node is last.
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
root | The sentinel root node not to pass. |
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>).
prototype_node * matador::prototype_node::previous_node | ( | ) | const |
Return nodes predecessor node or NULL if node is first.
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
root | The sentinel root node not to pass. |
T * matador::prototype_node::prototype | ( | ) | const |
Returns the prototype object of the node
T | The object type of the prototype object |
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.
T | The object type of the observer |
obs | The observer to register |
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.
tindex | type index for identification. |
endpoint | pointer to a relation_field_endpoint object |
void matador::prototype_node::remove | ( | object_proxy * | proxy | ) |
Removes an serializable proxy from prototype node.
proxy | Object proxy to remove |
unsigned long matador::prototype_node::size | ( | ) | const |
Returns the size of the serializable proxy list.
object_store * matador::prototype_node::tree | ( | ) | const |
Returns the corresponding tree/object_store
const char * matador::prototype_node::type | ( | ) | const |
Return the type name of this node.
const char * matador::prototype_node::type_id | ( | ) | const |
Return the type id of this node.
std::type_index matador::prototype_node::type_index | ( | ) | const |
Return the type index of the represented object type.
void matador::prototype_node::unlink | ( | ) |
Unlinks node from list.
void matador::prototype_node::unregister_relation_endpoint | ( | const std::type_index & | tindex | ) |
Unregister relation_field_endpoint identified by the given type index.
tindex |