Samchon Framework for CPP
1.0.0
|
A parameter of an Invoke. More...
#include <InvokeParameter.hpp>
Public Member Functions | |
InvokeParameter () | |
Default Constructor. More... | |
InvokeParameter (const std::string &, const std::string &, const std::string &) | |
Construct from arguments. More... | |
template<typename T > | |
InvokeParameter (const std::string &name, const T &val) | |
Construct with its name and a value. More... | |
InvokeParameter (const std::string &, std::string &&) | |
Construct from the name and a moved string. More... | |
InvokeParameter (const std::string &, ByteArray &&) | |
Construct from name and a moved ByteArray. More... | |
virtual void | construct (std::shared_ptr< library::XML >) override |
Construct data of the Entity from an XML object. More... | |
virtual auto | key () const -> std::string override |
Get a key that can identify the Entity uniquely. More... | |
auto | getName () const -> std::string |
Get name. More... | |
auto | getType () const -> std::string |
Get type. More... | |
template<typename T > | |
auto | getValue () const -> T |
Get value. More... | |
auto | getValueAsXML () const -> std::shared_ptr< library::XML > |
Get value as XML object. More... | |
template<typename T > | |
auto | referValue () const -> const T & |
Reference value. More... | |
template<typename T > | |
auto | moveValue () -> T |
Move value. More... | |
virtual auto | TAG () const -> std::string override |
A tag name when represented by XML. More... | |
virtual auto | toXML () const -> std::shared_ptr< library::XML > override |
Get an XML object represents the Entity. More... | |
auto | toSQL () const -> std::string |
Get a string of sql statement used to archive history log. More... | |
![]() | |
Entity () | |
Default Constructor. More... | |
Protected Attributes | |
std::string | name |
A name can represent the parameter. More... | |
std::string | type |
Type of the parameter. More... | |
std::string | str |
A string value if the type is "string" or "number". More... | |
std::shared_ptr< library::XML > | xml |
An XML object if the type is "XML". More... | |
ByteArray | byteArray |
A binary value if the type is "ByteArray". More... | |
A parameter of an Invoke.
A parameter with its name, type and value in an Invoke message.
InvokeParameter supports 4 types pre-defined.
You can specify InvokeParameter to have some type which is not one of the basic 4 types, but values of the custom type must be enable to expressed by one of those types; number, string, XML and ByteArray.
A member variable void* representing any type of value is deprecated.
Since C++11, method of void pointer (Declare a variable as void pointer whose type can not specified. And convert the pointer type to specified one for each case) is recommended to avoid.
As that reason, the void value was a candidate to be deprecated or to be replaced to boost::any. And the void value is really deprecated since version v1.0.
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 58 of file InvokeParameter.hpp.
InvokeParameter::InvokeParameter | ( | ) |
Default Constructor.
Definition at line 51 of file InvokeParameter.cpp.
samchon::protocol::InvokeParameter::InvokeParameter | ( | const std::string & | , |
const std::string & | , | ||
const std::string & | |||
) |
Construct from arguments.
Specifies all arguments of an InvokeParameter. You can specify a custom type, that is not one of number or string, but value of the type must be enable to expressed by a string.
If you want to express an object or container group, use XML instead; Invoke::InvokeParameter(string, XML).
name | A name can represent the InvokeParameter |
type | Type of value in the InvokeParameter |
value | A value capsuled by a string |
|
inline |
Construct with its name and a value.
Type of the InvokeParameter will be determined automatically.
Type supported in the template constructor:
_Ty | Type of value |
Definition at line 157 of file InvokeParameter.hpp.
References samchon::WeakString::str().
samchon::protocol::InvokeParameter::InvokeParameter | ( | const std::string & | , |
std::string && | |||
) |
Construct from the name and a moved string.
samchon::protocol::InvokeParameter::InvokeParameter | ( | const std::string & | , |
ByteArray && | |||
) |
Construct from name and a moved ByteArray.
|
overridevirtual |
Construct data of the Entity from an XML object.
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.
Definition at line 56 of file InvokeParameter.cpp.
|
overridevirtual |
Get a key that can identify the Entity uniquely.
If identifier of the Entity is not atomic value, returns a string represents the composite identifier. If identifier of the Entity is not string, converts the identifier to string and returns the string.
Reimplemented from samchon::protocol::Entity.
Definition at line 89 of file InvokeParameter.cpp.
References name.
auto InvokeParameter::getName | ( | ) | const -> std::string |
auto InvokeParameter::getType | ( | ) | const -> std::string |
|
inline |
Get value.
_Ty | Type of value to get |
Definition at line 239 of file InvokeParameter.hpp.
auto InvokeParameter::getValueAsXML | ( | ) | const -> std::shared_ptr<library::XML> |
Get value as XML object.
Same with getValue< std::shared_ptr<library::XML> >();
Definition at line 103 of file InvokeParameter.cpp.
References xml.
auto samchon::protocol::InvokeParameter::referValue | ( | ) | const -> const T & |
Reference value.
_Ty | Type of value to reference |
auto samchon::protocol::InvokeParameter::moveValue | ( | ) | -> T |
Move value.
_Ty | Type of value to move |
|
overridevirtual |
A tag name when represented by XML.
Implements samchon::protocol::Entity.
Definition at line 111 of file InvokeParameter.cpp.
|
overridevirtual |
Get an XML object represents the Entity.
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.
Definition at line 116 of file InvokeParameter.cpp.
References byteArray, name, str, samchon::protocol::Entity::toXML(), type, and xml.
auto InvokeParameter::toSQL | ( | ) | const -> std::string |
|
protected |
A name can represent the parameter.
Definition at line 69 of file InvokeParameter.hpp.
Referenced by construct(), getName(), key(), toSQL(), and toXML().
|
protected |
Type of the parameter.
List of pre-defined types
Definition at line 81 of file InvokeParameter.hpp.
Referenced by construct(), getType(), toSQL(), and toXML().
|
protected |
A string value if the type is "string" or "number".
Definition at line 86 of file InvokeParameter.hpp.
Referenced by construct(), toSQL(), and toXML().
|
protected |
An XML object if the type is "XML".
Definition at line 91 of file InvokeParameter.hpp.
Referenced by getValueAsXML(), toSQL(), and toXML().
|
protected |
A binary value if the type is "ByteArray".
Definition at line 96 of file InvokeParameter.hpp.
Referenced by construct(), and toXML().