2 #include <samchon/protocol/Entity.hpp> 3 #include <samchon/protocol/EntityGroupBase.hpp> 11 template <
typename Container,
typename Key = std::
string>
12 class StaticEntityGroup
14 public virtual Entity<Key>,
15 public EntityGroupBase
18 typedef Container container_type;
24 using container_type::container_type;
26 virtual void construct(std::shared_ptr<library::XML> xml)
32 std::shared_ptr<library::XMLList> &xml_list = xml->get(
CHILD_TAG());
35 assign(xml_list->size(), container_type::value_type());
36 for (
auto it = begin(); it != end(); it++)
37 it->construct(xml_list->at(i++));
43 using container_type::erase;
45 void erase(
const typename container_type::value_type::key_type &key)
47 for (
auto it = begin(); it != end(); )
71 auto find(
const typename container_type::value_type::key_type &key) ->
typename container_type::iterator
76 [key](
const container_type::value_type &entity) ->
bool 78 return entity.key() == key;
100 auto find(
const typename container_type::value_type::key_type &key)
const ->
typename container_type::const_iterator
105 [key](
const container_type::value_type &entity) ->
bool 107 return entity.key() == key;
118 auto has(
const typename container_type::value_type::key_type &key)
const ->
bool 123 [key](
const container_type::value_type &entity) ->
bool 125 return entity.key() == key;
136 auto count(
const typename container_type::value_type::key_type &key)
const ->
size_t 141 [key](
const container_type::value_type &entity) ->
bool 143 return entity.key() == key;
154 auto get(
const typename container_type::value_type::key_type &key) ->
typename container_type::value_type&
156 auto it = std::find_if
159 [key](
const container_type::value_type &entity) ->
bool 161 return entity.key() == key;
166 throw std::out_of_range(
"out of range");
177 auto get(
const typename container_type::value_type::key_type &key)
const ->
const typename container_type::value_type&
179 auto it = std::find_if
182 [key](
const container_type::value_type &entity) ->
bool 184 return entity.key() == key;
189 throw std::out_of_range(
"out of range");
212 virtual auto toXML() const ->
std::shared_ptr<library::XML>
214 std::shared_ptr<library::XML> &xml = Entity::toXML();
216 std::shared_ptr<library::XMLList> xmlList(
new library::XMLList());
217 xmlList->reserve(this->size());
219 for (
auto it = begin(); it != end(); it++)
220 xmlList->push_back(it->toXML());
virtual auto CHILD_TAG() const -> std::string=0
A tag name of children.