Samchon Framework for CPP
1.0.0
|
An Entity and a container of children Entity objects. More...
#include <EntityGroup.hpp>
Public Member Functions | |
virtual void | construct (std::shared_ptr< library::XML > xml) |
Construct data of the Entity from an XML object. More... | |
auto | find (const typename child_type::key_type &key) -> typename container_type::iterator |
Get iterator to element. More... | |
auto | find (const typename child_type::key_type &key) const -> typename container_type::const_iterator |
Get const iterator to element. More... | |
auto | has (const typename child_type::key_type &key) const -> bool |
Indicates whether a container has an object having the specified identifier. More... | |
auto | count (const typename child_type::key_type &key) const -> size_t |
Count elements with a specific key. More... | |
auto | get (const typename child_type::key_type &key) -> typename container_type::value_type & |
Access the element by specified identifier(key). More... | |
auto | get (const typename child_type::key_type &key) const -> const typename container_type::value_type & |
Access the const element by specified identifier(key). More... | |
virtual auto | toXML () const -> std::shared_ptr< library::XML > |
Get an XML object represents the EntityGroup. More... | |
Public Member Functions inherited from samchon::protocol::Entity< Key > | |
virtual auto | key () const -> Key |
Get a key that can identify the Entity uniquely. More... | |
Public Member Functions inherited from samchon::protocol::EntityGroupBase | |
virtual auto | CHILD_TAG () const -> std::string=0 |
A tag name of children. More... | |
Protected Member Functions | |
virtual auto | createChild (std::shared_ptr< library::XML >) -> child_type *=0 |
Factory method of a child Entity. More... | |
An Entity and a container of children Entity objects.
Container | A type of container containing children entity objects. |
EntityGroup is a template class for containinig children Entity objects, and also another type of an Entity, too. You can realize hierarchical relationship. Although some entities have complicated hierarchical relationship, you can deduct a optimal solution easily with EntityGroup and Entity.
If an entity has some subordinate entities of same type, they are in "Composite relationship". Make the entity to be EmntityGroup and subordinate entities to be children of the entity. When those relationships are continued, continue to create classes dervied from EntityGroup. When those relationshiop meets a terminal node, then make the terminal node to be an Entity.
EntityGroup is an Entity, and a container of children Entity objects at the same time. If children type, of a class derived from an EntityGroup, is itself, you can realize hierarchical and recursive relationship. The relationship is called as "Composite pattern".
EntityGroup contains children entity elements as type of pointer. Because children entity objects are not serialized and referenced by pointer, its iteration and accessment is not fast. If it needs higher performance, then use StaticEntityArray (static array for children entity) instead.
Definition at line 40 of file EntityGroup.hpp.
|
inlinevirtual |
Construct data of the Entity from an XML object.
Constructs the EntityGroup's own member variables only from the input XML object.
Do not consider about constructing children Entity objects' data in EntityGroup::construct(). Those children Entity objects' data will constructed by their own construct() method. Even insertion of XML objects representing children are done by abstract method of EntityGroup::toXML().
Constructs only data of EntityGroup's own.
Reimplemented in samchon::templates::distributed::DistributedSystemArray< System >, samchon::templates::distributed::DistributedSystemArray< MasterSystem >, samchon::templates::external::ExternalSystem, samchon::templates::parallel::ParallelSystem, and samchon::protocol::Invoke.
Definition at line 71 of file EntityGroup.hpp.
Referenced by samchon::protocol::Invoke::construct(), samchon::templates::external::ExternalSystem::construct(), and samchon::templates::distributed::DistributedSystemArray< MasterSystem >::construct().
|
protectedpure virtual |
Factory method of a child Entity.
EntityGroup::createChild() is a factory method creating a new child Entity which is belonged to the EntityGroup. This method is called by EntityGroup::construct(). The children construction methods Entity::construct() will be called by abstract method of the EntityGroup::construct().
Implemented in samchon::templates::external::ExternalClientArray< System >, samchon::templates::external::ExternalClientArray< MasterSystem >, samchon::templates::external::ExternalClientArray< SlaveDriver >, samchon::templates::external::ExternalClientArray< Viewer >, samchon::templates::distributed::DistributedSystem, samchon::protocol::Invoke, and samchon::templates::external::ExternalServerClientArray< System >.
Referenced by samchon::protocol::EntityGroup< std::deque< System * >, System, int >::construct().
|
inline |
Get iterator to element.
Searches the container for an element with a identifier equivalent to key and returns an iterator to it if found, otherwise it returns an iterator to end().
Two keys are considered equivalent if the container's comparison object returns false reflexively (i.e., no matter the order in which the elements are passed as arguments).
Another member functions, has() and count(), can be used to just check whether a particular key exists.
key | Key to be searched for |
Definition at line 144 of file EntityGroup.hpp.
|
inline |
Get const iterator to element.
Searches the container for an element with a identifier equivalent to key and returns an iterator to it if found, otherwise it returns an iterator to end().
Two keys are considered equivalent if the container's comparison object returns false reflexively (i.e., no matter the order in which the elements are passed as arguments).
Another member functions, has() and count(), can be used to just check whether a particular key exists.
key | Key to be searched for |
Definition at line 173 of file EntityGroup.hpp.
|
inline |
Indicates whether a container has an object having the specified identifier.
key | An identifier of an Entity |
Definition at line 191 of file EntityGroup.hpp.
|
inline |
Count elements with a specific key.
Searches the container for elements whose key is key and returns the number of elements found.
Definition at line 209 of file EntityGroup.hpp.
|
inline |
Access the element by specified identifier(key).
key | the identifier of the element wants to access |
Definition at line 227 of file EntityGroup.hpp.
Referenced by samchon::templates::external::ExternalServer::connect().
|
inline |
Access the const element by specified identifier(key).
key | the identifier of the element wants to access |
Definition at line 250 of file EntityGroup.hpp.
|
inlinevirtual |
Get an XML object represents the EntityGroup.
Archives the EntityGroup's own member variables only to the returned XML object.
Do not consider about archiving children Entity objects' data in EntityGroup::toXML(). Those children Entity objects will converted to XML object by their own toXML() method. The insertion of XML objects representing children are done by abstract method of EntityGroup::toXML().
Archives only data of EntityGroup's own.
Reimplemented in samchon::templates::distributed::DistributedSystemArray< System >, samchon::templates::distributed::DistributedSystemArray< MasterSystem >, samchon::templates::parallel::ParallelSystem, samchon::examples::packer::WrapperArray, samchon::templates::external::ExternalSystem, samchon::examples::packer::Packer, samchon::protocol::Invoke, and samchon::examples::tsp::Travel.
Definition at line 285 of file EntityGroup.hpp.
Referenced by samchon::protocol::Invoke::toXML(), samchon::templates::external::ExternalSystem::toXML(), and samchon::templates::distributed::DistributedSystemArray< MasterSystem >::toXML().