Samchon Framework for CPP  1.0.0
samchon::protocol::InvokeParameter Class Reference

A parameter of an Invoke. More...

#include <InvokeParameter.hpp>

Collaboration diagram for samchon::protocol::InvokeParameter:

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...
 
- Public Member Functions inherited from samchon::protocol::Entity
 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::XMLxml
 An XML object if the type is "XML". More...
 
ByteArray byteArray
 A binary value if the type is "ByteArray". More...
 

Detailed Description

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.

protocol_invoke.png
Example Sources
Note

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.

[Inherited]

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.

protocol_entity.png
Example Sources
Note

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

See also
protocol
Author
Jeongho Nam http://samchon.org
See also
protocol::Invoke
samchon::protocol
Author
Jeongho Nam http://samchon.org

Definition at line 58 of file InvokeParameter.hpp.

Constructor & Destructor Documentation

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

Parameters
nameA name can represent the InvokeParameter
typeType of value in the InvokeParameter
valueA value capsuled by a string
template<typename T >
samchon::protocol::InvokeParameter::InvokeParameter ( const std::string &  name,
const T &  val 
)
inline

Construct with its name and a value.

Type of the InvokeParameter will be determined automatically.

Type supported in the template constructor:

Template Parameters
_TyType of value

Definition at line 157 of file InvokeParameter.hpp.

References samchon::WeakString::str().

Here is the call graph for this function:

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.

Member Function Documentation

void InvokeParameter::construct ( std::shared_ptr< library::XML )
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.

Parameters
xmlAn xml used to construct data of entity

Implements samchon::protocol::Entity.

Definition at line 56 of file InvokeParameter.cpp.

References byteArray, name, str, and type.

auto InvokeParameter::key ( ) const -> std::string
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.

Returns
An identifier

Reimplemented from samchon::protocol::Entity.

Definition at line 89 of file InvokeParameter.cpp.

References name.

auto InvokeParameter::getName ( ) const -> std::string

Get name.

Definition at line 94 of file InvokeParameter.cpp.

References name.

auto InvokeParameter::getType ( ) const -> std::string

Get type.

Definition at line 98 of file InvokeParameter.cpp.

References type.

template<typename T >
auto samchon::protocol::InvokeParameter::getValue ( ) const -> T
inline

Get value.

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

template<typename T >
auto samchon::protocol::InvokeParameter::referValue ( ) const -> const T &

Reference value.

Template Parameters
_TyType of value to reference
template<typename T >
auto samchon::protocol::InvokeParameter::moveValue ( ) -> T

Move value.

Template Parameters
_TyType of value to move
auto InvokeParameter::TAG ( ) const -> std::string
overridevirtual

A tag name when represented by XML.

Returns
A tag name

Implements samchon::protocol::Entity.

Definition at line 111 of file InvokeParameter.cpp.

auto InvokeParameter::toXML ( ) const -> std::shared_ptr<library::XML>
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>
Returns
An XML object representing the Entity.

Reimplemented from samchon::protocol::Entity.

Definition at line 116 of file InvokeParameter.cpp.

References byteArray, name, str, samchon::protocol::Entity::toXML(), type, and xml.

Here is the call graph for this function:

auto InvokeParameter::toSQL ( ) const -> std::string

Get a string of sql statement used to archive history log.

Definition at line 139 of file InvokeParameter.cpp.

References name, str, type, and xml.

Member Data Documentation

std::string samchon::protocol::InvokeParameter::name
protected

A name can represent the parameter.

Definition at line 69 of file InvokeParameter.hpp.

Referenced by construct(), getName(), key(), toSQL(), and toXML().

std::string samchon::protocol::InvokeParameter::type
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().

std::string samchon::protocol::InvokeParameter::str
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().

std::shared_ptr<library::XML> samchon::protocol::InvokeParameter::xml
protected

An XML object if the type is "XML".

Definition at line 91 of file InvokeParameter.hpp.

Referenced by getValueAsXML(), toSQL(), and toXML().

ByteArray samchon::protocol::InvokeParameter::byteArray
protected

A binary value if the type is "ByteArray".

Definition at line 96 of file InvokeParameter.hpp.

Referenced by construct(), and toXML().


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