Samchon Framework for CPP  1.0.0
Entity.hpp
1 #pragma once
2 
3 #include <string>
4 #include <memory>
5 
6 #include <samchon/library/XML.hpp>
7 
8 namespace samchon
9 {
10 namespace protocol
11 {
12  class EntityBase
13  {
14  public:
15  virtual ~EntityBase() = default;
16 
28  virtual void construct(std::shared_ptr<library::XML>) = 0;
29 
35  virtual auto TAG() const -> std::string = 0;
36 
76  virtual auto toXML() const -> std::shared_ptr<library::XML>
77  {
78  auto xml = std::make_shared<library::XML>();
79  xml->setTag(this->TAG());
80 
81  return xml;
82  };
83  };
84 
114  template <typename Key = std::string>
115  class Entity : public EntityBase
116  {
117  public:
118  typedef Key key_type;
119 
120  public:
121  virtual ~Entity() = default;
122 
133  virtual auto key() const -> Key
134  {
135  return Key();
136  };
137  };
138 };
139 };
An entity, a standard data class.
Definition: Entity.hpp:115
virtual auto key() const -> Key
Get a key that can identify the Entity uniquely.
Definition: Entity.hpp:133