Samchon Framework for CPP  1.0.0
samchon::protocol::EntityGroup< Container, T, Key > Class Template Referenceabstract

An Entity and a container of children Entity objects. More...

#include <EntityGroup.hpp>

Collaboration diagram for samchon::protocol::EntityGroup< Container, T, Key >:

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...
 

Detailed Description

template<typename Container, typename T, typename Key = std::string>
class samchon::protocol::EntityGroup< Container, T, Key >

An Entity and a container of children Entity objects.

Template Parameters
ContainerA 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.

Basic Components

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".

Warning

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.

Author
Jeongho Nam http://samchon.org

Definition at line 40 of file EntityGroup.hpp.

Member Function Documentation

template<typename Container, typename T, typename Key = std::string>
virtual void samchon::protocol::EntityGroup< Container, T, Key >::construct ( std::shared_ptr< library::XML xml)
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.

[Inherited]

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().

Here is the caller graph for this function:

template<typename Container, typename T, typename Key = std::string>
virtual auto samchon::protocol::EntityGroup< Container, T, Key >::createChild ( std::shared_ptr< library::XML ) -> child_type *
protectedpure virtual
template<typename Container, typename T, typename Key = std::string>
auto samchon::protocol::EntityGroup< Container, T, Key >::find ( const typename child_type::key_type &  key) -> typename container_type::iterator
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.

Parameters
keyKey to be searched for
Returns
An iterator to the element, if an element with specified key is found, or end() otherwise.

Definition at line 144 of file EntityGroup.hpp.

template<typename Container, typename T, typename Key = std::string>
auto samchon::protocol::EntityGroup< Container, T, Key >::find ( const typename child_type::key_type &  key) const -> typename container_type::const_iterator
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.

Parameters
keyKey to be searched for
Returns
An iterator to the element, if an element with specified key is found, or end() otherwise.

Definition at line 173 of file EntityGroup.hpp.

template<typename Container, typename T, typename Key = std::string>
auto samchon::protocol::EntityGroup< Container, T, Key >::has ( const typename child_type::key_type &  key) const -> bool
inline

Indicates whether a container has an object having the specified identifier.

Parameters
keyAn identifier of an Entity
Returns
If there's the object then true, otherwise false

Definition at line 191 of file EntityGroup.hpp.

template<typename Container, typename T, typename Key = std::string>
auto samchon::protocol::EntityGroup< Container, T, Key >::count ( const typename child_type::key_type &  key) const -> size_t
inline

Count elements with a specific key.

Searches the container for elements whose key is key and returns the number of elements found.

Returns
The number of elements in the container with a key.

Definition at line 209 of file EntityGroup.hpp.

template<typename Container, typename T, typename Key = std::string>
auto samchon::protocol::EntityGroup< Container, T, Key >::get ( const typename child_type::key_type &  key) -> typename container_type::value_type&
inline

Access the element by specified identifier(key).

Parameters
keythe identifier of the element wants to access
Returns
The element having the key, or throw exception if there is none.

Definition at line 227 of file EntityGroup.hpp.

Referenced by samchon::templates::external::ExternalServer::connect().

Here is the caller graph for this function:

template<typename Container, typename T, typename Key = std::string>
auto samchon::protocol::EntityGroup< Container, T, Key >::get ( const typename child_type::key_type &  key) const -> const typename container_type::value_type&
inline

Access the const element by specified identifier(key).

Parameters
keythe identifier of the element wants to access
Returns
The const element having the key, or throw exception if there is none.

Definition at line 250 of file EntityGroup.hpp.

template<typename Container, typename T, typename Key = std::string>
virtual auto samchon::protocol::EntityGroup< Container, T, Key >::toXML ( ) const -> std::shared_ptr<library::XML>
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.

[Inherited]

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().

Here is the caller graph for this function:


The documentation for this class was generated from the following file: