#pragma once #include #include namespace samchon { namespace protocol { /** * @brief An EntityGroup with vector container and children capsuled in shared pointers. * * @tparam T A type of children Entity. Must be a class derived from an Entity or Entity itself. * * @details *

For a case of inheritance of SharedEntityArray and the inherited SharedEntityArray also * contains entity objects which are inherited from original child entity type, SharedEntityArray * supports macros changing returned type of accessor methods.

* * \li SHARED_ENTITY_ARRAY_ELEMENT_ACCESSOR_HEADER * \li SHARED_ENTITY_ARRAY_ELEMENT_ACCESSOR_BODY * * @see samchon::protocol * @author Jeongho Nam */ template using SharedEntityArray = EntityGroup>, T, Key>; }; }; /* ------------------------------------------------------------------------------ MACROS ------------------------------------------------------------------------------ */ // INLINE #define SHARED_ENTITY_ARRAY_ELEMENT_ACCESSOR_INLINE(CHILD_TYPE) \ auto operator[](size_t x) const -> std::shared_ptr \ { \ return std::dynamic_pointer_cast(container_type::operator[](x)); \ }; \ auto at(size_t x) const -> std::shared_ptr \ { \ return std::dynamic_pointer_cast(container_type::at(x)); \ }; \ auto get(const typename child_type::key_type &key) const -> std::shared_ptr \ { \ return std::dynamic_pointer_cast(samchon::protocol::EntityGroup::get(key)); \ }; // HEADER #define SHARED_ENTITY_ARRAY_ELEMENT_ACCESSOR_HEADER(CHILD_TYPE) \ auto operator[](size_t) const -> std::shared_ptr; \ auto at(size_t) const -> std::shared_ptr; \ auto get(const typename child_type::key_type&) const -> std::shared_ptr; // BODY #define SHARED_ENTITY_ARRAY_ELEMENT_ACCESSOR_BODY(THIS_TYPE, CHILD_TYPE) \ auto THIS_TYPE::operator[](size_t x) const -> std::shared_ptr \ { \ return std::dynamic_pointer_cast(container_type::operator[](x)); \ } \ auto THIS_TYPE::at(size_t x) const -> std::shared_ptr \ { \ return std::dynamic_pointer_cast(container_type::at(x)); \ } \ auto THIS_TYPE::get(const typename child_type::key_type &key) const -> std::shared_ptr \ { \ return std::dynamic_pointer_cast(samchon::protocol::EntityGroup::get(key)); \ }