Samchon Framework for CPP  1.0.0
SharedEntityArray.hpp
1 #pragma once
2 
3 #include <samchon/protocol/EntityGroup.hpp>
4 #include <vector>
5 
6 namespace samchon
7 {
8 namespace protocol
9 {
26  template <typename _Ty = Entity>
27  using SharedEntityArray =
28  EntityGroup
29  <
30  std::vector<std::shared_ptr<_Ty>>,
31  _Ty, std::shared_ptr<_Ty>
32  >;
33 };
34 };
35 
36 /* ------------------------------------------------------------------------------
37  MACROS
38 ------------------------------------------------------------------------------ */
39 //HEADER
40 #define SHARED_ENTITY_ARRAY_ELEMENT_ACCESSOR_HEADER(CHILD_TYPE) \
41 auto operator[](size_t) const -> std::shared_ptr<CHILD_TYPE>; \
42 auto at(size_t) const -> std::shared_ptr<CHILD_TYPE>; \
43 auto get(const std::string&) const -> std::shared_ptr<CHILD_TYPE>;
44 
45 //BODY
46 #define SHARED_ENTITY_ARRAY_ELEMENT_ACCESSOR_BODY(THIS_TYPE, CHILD_TYPE) \
47 auto THIS_TYPE::operator[](size_t x) const -> std::shared_ptr<CHILD_TYPE> { return std::dynamic_pointer_cast<CHILD_TYPE>(container_type::operator[](x)); }; \
48 auto THIS_TYPE::at(size_t x) const -> std::shared_ptr<CHILD_TYPE> { return std::dynamic_pointer_cast<CHILD_TYPE>(container_type::at(x)); }; \
49 auto THIS_TYPE::get(const std::string &key) const -> std::shared_ptr<CHILD_TYPE> { return std::dynamic_pointer_cast<CHILD_TYPE>(samchon::protocol::EntityGroup<container_type, entity_type, value_type>::get(key)); }
EntityGroup< std::vector< std::shared_ptr< _Ty >>, _Ty, std::shared_ptr< _Ty > > SharedEntityArray
An EntityGroup with vector container and children capsuled in shared pointers.
Top level namespace of products built from samchon.
Definition: ByteArray.hpp:7