Samchon Framework for CPP
1.0.0
|
An Entity and a container of children Entity objects. More...
#include <EntityGroup.hpp>
Public Member Functions | |
EntityGroup () | |
Default Constructor. More... | |
virtual void | construct (std::shared_ptr< library::XML > xml) |
Construct data of the Entity from an XML object. More... | |
auto | has (const std::string &key) const -> bool |
Indicates whether a container has an object having the specified identifier. More... | |
auto | get (const std::string &key) -> value_type & |
Access the element by specified identifier(key). More... | |
auto | get (const std::string &key) const -> const 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... | |
![]() | |
virtual auto | TAG () const -> std::string=0 |
A tag name when represented by XML. More... | |
Entity () | |
Default Constructor. More... | |
virtual auto | key () const -> std::string |
Get a key that can identify the Entity uniquely. More... | |
![]() | |
IEntityGroup () | |
Default Constructor. More... | |
Protected Member Functions | |
virtual auto | createChild (std::shared_ptr< library::XML >) -> entity_type *=0 |
Factory method of a child Entity. More... | |
![]() | |
virtual auto | CHILD_TAG () const -> std::string=0 |
A tag name of children. More... | |
An Entity and a container of children Entity objects.
_Container | A type of container containing children entity objects. |
_Ety | A type of children entity. It must be a class derived from an Entity class, or Entity class itself. |
_Ty | A type of children element of _Container. Using default template parameter is recommended. |
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".
As a freelancer developer and architect I am, I even design DB I/O to follow the format representing Entity and EntityGroup by XML. Below T-SQL script also follows the standard format of expressing Entity with XML by procedure and "FOR XML AUTO" statement.
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 EntityArray (static array for children entity) instead.
Entity is a class for standardization of expression method using on network I/O by XML. If Invoke is a standard message protocol of Samchon Framework which must be kept, Entity is a recommended semi-protocol of message for expressing a data class. Following the semi-protocol Entity is not imposed but encouraged.
As we could get advantages from standardization of message for network I/O with Invoke, we can get additional advantage from standardizing expression method of data class with Entity. We do not need to know a part of network communication. Thus, with the Entity, we can only concentrate on entity's own logics and relationships between another entities. Entity does not need to how network communications are being done.
I say repeatedly. Expression method of Entity is recommended, but not imposed. It's a semi protocol for network I/O but not a essential protocol must be kept. The expression method of Entity, using on network I/O, is expressed by XML string.
If your own network system has a critical performance issue on communication data class, it would be better to using binary communication (with ByteArray or boost::serialization). Don't worry about the problem! Invoke also provides methods for binary data (ByteArray).
Definition at line 52 of file EntityGroup.hpp.
|
inline |
Default Constructor.
Definition at line 69 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.
Overrides the construct() method and fetch data of member variables from the XML.
By recommended guidance, data representing member variables are contained in properties of the put XML object.
xml | An xml used to construct data of entity |
Implements samchon::protocol::Entity.
Reimplemented in samchon::protocol::master::DistributedSystem, samchon::namtree::NTCriteria, samchon::protocol::master::ParallelSystem, samchon::protocol::ExternalSystem, samchon::protocol::Invoke, samchon::protocol::master::DistributedSystemArray, samchon::protocol::master::ParallelSystemArrayMediator, samchon::protocol::master::DistributedSystemArrayMediator, samchon::namtree::NTParameter, samchon::protocol::ExternalClientArray, samchon::protocol::ExternalServer, samchon::protocol::master::DistributedClientArrayMediator, samchon::protocol::master::ParallelClientArrayMediator, samchon::protocol::master::DistributedClientArray, samchon::protocol::master::DistributedServer, and samchon::protocol::master::ParallelServer.
Definition at line 90 of file EntityGroup.hpp.
References samchon::protocol::IEntityGroup::CHILD_TAG(), samchon::protocol::EntityGroup< _Container, _ETy, T >::createChild(), and samchon::protocol::Entity::key().
Referenced by samchon::protocol::ExternalClientArray::construct(), samchon::namtree::NTParameter::construct(), samchon::protocol::master::ParallelSystemArrayMediator::construct(), samchon::protocol::master::DistributedSystemArray::construct(), samchon::protocol::Invoke::construct(), samchon::protocol::ExternalSystem::construct(), samchon::protocol::master::ParallelSystem::construct(), samchon::namtree::NTFile::construct(), and samchon::library::FTFolder::FTFolder().
|
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::protocol::master::DistributedSystem, samchon::namtree::NTCriteria, samchon::protocol::master::ParallelSystem, samchon::protocol::Invoke, samchon::namtree::NTParameter, samchon::namtree::NTParameterArray, samchon::protocol::slave::ParallelSystem, samchon::protocol::master::DSInvokeHistoryArray, samchon::protocol::master::PRInvokeHistoryArray, and samchon::protocol::InvokeHistoryArray.
Referenced by samchon::protocol::ExternalClientArray::addClient(), and samchon::protocol::EntityGroup< _Container, _ETy, T >::construct().
|
inline |
Indicates whether a container has an object having the specified identifier.
key | An identifier of an Entity |
Definition at line 155 of file EntityGroup.hpp.
References samchon::protocol::Entity::key().
Referenced by samchon::protocol::master::ParallelSystem::construct(), and samchon::protocol::ExternalSystemArray::sendData().
|
inline |
Access the element by specified identifier(key).
key | the identifier of the element wants to access |
Definition at line 170 of file EntityGroup.hpp.
References samchon::protocol::Entity::key().
Referenced by samchon::protocol::master::ParallelSystem::construct(), and samchon::protocol::master::PRMasterHistory::PRMasterHistory().
|
inline |
Access the const element by specified identifier(key).
key | the identifier of the element wants to access |
Definition at line 185 of file EntityGroup.hpp.
References samchon::protocol::Entity::key().
|
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.
Returns an XML object that can represents the Entity containing member variables into properties.
A member variable (not object, but atomic value like number, string or date) is categorized as a property within the framework of entity side. Thus, when overriding a toXML() method and archiving member variables to an XML object to return, puts each variable to be a property belongs to only an XML object.
Don't archive the member variable of atomic value to XML::value causing enormouse creation of XML objects to number of member variables. An Entity must be represented by only an XML instance (tag).
Standard Usage | Non-standard usage abusing value |
---|---|
<memberList> <member id='jhnam88' name='Jeongho+Nam' birthdate='1988-03-11' /> <member id='master' name='Administartor' birthdate='2011-07-28' /> </memberList> | <member> <id>jhnam88</id> <name>Jeongho+Nam</name> <birthdate>1988-03-11</birthdate> </member> |
Reimplemented from samchon::protocol::Entity.
Reimplemented in samchon::example::packer::WrapperArray, samchon::example::packer::Packer, samchon::protocol::Invoke, samchon::protocol::master::DistributedSystem, samchon::example::tsp::Travel, samchon::namtree::NTCriteria, samchon::protocol::ExternalSystem, samchon::protocol::master::DistributedSystemArray, samchon::example::packer::Wrapper, samchon::protocol::master::ParallelSystem, samchon::namtree::NTParameter, samchon::protocol::master::ParallelSystemArrayMediator, samchon::protocol::master::DistributedSystemArrayMediator, samchon::protocol::ExternalClientArray, samchon::protocol::ExternalServer, samchon::library::FTFolder, samchon::protocol::master::DistributedClientArrayMediator, samchon::protocol::master::ParallelClientArrayMediator, samchon::protocol::master::DistributedClientArray, samchon::protocol::master::DistributedServer, and samchon::protocol::master::ParallelServer.
Definition at line 212 of file EntityGroup.hpp.
References samchon::protocol::IEntityGroup::CHILD_TAG(), and samchon::protocol::Entity::toXML().
Referenced by samchon::library::FTFolder::toXML(), samchon::protocol::ExternalClientArray::toXML(), samchon::protocol::master::ParallelSystemArrayMediator::toXML(), samchon::namtree::NTParameter::toXML(), samchon::protocol::master::DistributedSystemRole::toXML(), samchon::protocol::master::DistributedSystemArray::toXML(), samchon::protocol::ExternalSystem::toXML(), samchon::namtree::NTFile::toXML(), samchon::protocol::master::DistributedSystem::toXML(), and samchon::protocol::Invoke::toXML().