Samchon Framework for CPP  1.0.0
Invoke.hpp
1 #pragma once
2 #include <samchon/API.hpp>
3 
4 #include <samchon/protocol/SharedEntityArray.hpp>
5 #include <samchon/protocol/InvokeParameter.hpp>
6 
7 namespace samchon
8 {
9 namespace protocol
10 {
47  class SAMCHON_FRAMEWORK_API Invoke
48  : public SharedEntityArray<InvokeParameter>
49  {
50  private:
52 
53  protected:
57  std::string listener;
58 
59  public:
60  /* --------------------------------------------------------------------
61  CONSTRUCTORS
62  -------------------------------------------------------------------- */
66  Invoke();
67  virtual ~Invoke() = default;
68 
74  Invoke(const std::string &listener);
75 
76  virtual void construct(std::shared_ptr<library::XML>) override;
77 
78  protected:
79  virtual auto createChild(std::shared_ptr<library::XML>)->InvokeParameter* override;
80 
81  /* --------------------------------------------------------------------
82  VARIADIC CONSTRUCTORS
83  -------------------------------------------------------------------- */
84  public:
107  template <typename T, typename ... _Args>
108  Invoke(const std::string &listener, const T &val, const _Args& ... args)
109  : Invoke(listener)
110  {
111  construct_by_vardic_template(val);
112  construct_by_vardic_template(args...);
113  };
114 
115  template <typename T>
116  Invoke(const std::string &listener, const T &val)
117  : Invoke(listener)
118  {
119  construct_by_vardic_template(val);
120  };
121 
122  private:
123  template <typename T, typename ... _Args>
124  void construct_by_vardic_template(const T &val, const _Args& ... args)
125  {
126  construct_by_vardic_template(val);
127  construct_by_vardic_template(args...);
128  };
129 
130  template <typename T>
131  void construct_by_vardic_template(const T &val)
132  {
133  emplace_back(new InvokeParameter("", val));
134  };
135 
136  public:
137  /* -----------------------------------------------------------------------
138  GETTERS
139  ----------------------------------------------------------------------- */
143  auto getListener() const->std::string;
144 
148  void setListener(const std::string &);
149 
150  /* -----------------------------------------------------------------------
151  EXPORTERS
152  ----------------------------------------------------------------------- */
153  virtual auto TAG() const->std::string override;
154  virtual auto CHILD_TAG() const->std::string override;
155 
156  virtual auto toXML() const->std::shared_ptr<library::XML> override;
157 
161  auto toSQL() const->std::string;
162  };
163 };
164 };
Invoke(const std::string &listener, const T &val, const _Args &...args)
Construct from arguments.
Definition: Invoke.hpp:108
An Entity and a container of children Entity objects.
Definition: EntityGroup.hpp:52
Standard message of network I/O.
Definition: Invoke.hpp:47
XML is a class representing xml object.
Definition: XML.hpp:72
std::string listener
Represent who listens, often be a function name.
Definition: Invoke.hpp:57
A parameter of an Invoke.
Top level namespace of products built from samchon.
Definition: ByteArray.hpp:7