#pragma once #include "../../common/specialized.hpp" #include "../../common/compat.hpp" namespace sprawl { namespace collections { namespace detail { template class AccessorGroup_Impl; template class AccessorGroup_Impl { public: AccessorGroup_Impl(ValueType const& value) : next(nullptr) , prev(nullptr) , m_value(value) { // } AccessorGroup_Impl(AccessorGroup_Impl const& other) : next(nullptr) , prev(nullptr) , m_value(other.m_value) { // } inline MostInheritedType* Next(Specialized) { return nullptr; } inline MostInheritedType* Prev(Specialized) { return nullptr; } inline void SetNext(Specialized, MostInheritedType*) { // } inline void SetPrev(Specialized, MostInheritedType*) { // } inline size_t Idx(Specialized) { return -1; } inline void SetIndex(Specialized, size_t) { // } inline size_t GetHash(Specialized) { return -1; } inline void SetHash(Specialized, size_t) { // } inline NullAccessor& Accessor(Specialized) { static NullAccessor accessor; return accessor; } MostInheritedType* next; MostInheritedType* prev; ValueType m_value; }; template class AccessorGroup_Impl : public AccessorGroup_Impl { public: typedef AccessorGroup_Impl Base; AccessorGroup_Impl(ValueType const& value) : Base(value) , m_thisAccessor(this->m_value) , m_nextThisAccessor(nullptr) , m_prevThisAccessor(nullptr) , m_thisIdx(0) { // } AccessorGroup_Impl(AccessorGroup_Impl const& other) : Base(other) , m_thisAccessor(this->m_value) , m_nextThisAccessor(nullptr) , m_prevThisAccessor(nullptr) , m_thisIdx(0) { // } template AccessorGroup_Impl(ValueType const& value, Param1 key, typename std::enable_if::value>::type* = nullptr) : Base(value) , m_thisAccessor(this->m_value, key) , m_nextThisAccessor(nullptr) , m_prevThisAccessor(nullptr) , m_thisIdx(0) { // } template AccessorGroup_Impl(ValueType const& value, Param1 key, Params... moreKeys, typename std::enable_if::value>::type* = nullptr) : Base(value, moreKeys...) , m_thisAccessor(this->m_value, key) , m_nextThisAccessor(nullptr) , m_prevThisAccessor(nullptr) , m_thisIdx(0) { // } template AccessorGroup_Impl(ValueType const& value, Param1 firstParam, typename std::enable_if::value>::type* = nullptr) : Base(value, firstParam) , m_thisAccessor(this->m_value) , m_nextThisAccessor(nullptr) , m_prevThisAccessor(nullptr) , m_thisIdx(0) { // } template AccessorGroup_Impl(ValueType const& value, Param1 firstParam, Params... moreKeys, typename std::enable_if::value>::type* = nullptr) : Base(value, firstParam, moreKeys...) , m_thisAccessor(this->m_value) , m_nextThisAccessor(nullptr) , m_prevThisAccessor(nullptr) , m_thisIdx(0) { // } using Base::Next; inline MostInheritedType* Next(Specialized) { return m_nextThisAccessor; } using Base::Prev; inline MostInheritedType* Prev(Specialized) { return m_prevThisAccessor; } using Base::SetNext; inline void SetNext(Specialized, MostInheritedType* next) { m_nextThisAccessor = next; } using Base::SetPrev; inline void SetPrev(Specialized, MostInheritedType* prev) { m_prevThisAccessor = prev; } using Base::Idx; inline size_t Idx(Specialized) { return m_thisIdx; } using Base::SetIndex; inline void SetIndex(Specialized, size_t idx) { m_thisIdx = idx; } using Base::GetHash; inline size_t GetHash(Specialized) { return m_thisHash; } using Base::SetHash; inline void SetHash(Specialized, size_t hash) { m_thisHash = hash; } using Base::Accessor; inline AccessorType& Accessor(Specialized) { return m_thisAccessor; } AccessorType m_thisAccessor; MostInheritedType* m_nextThisAccessor; MostInheritedType* m_prevThisAccessor; size_t m_thisIdx; size_t m_thisHash; }; template class AccessorGroup : public AccessorGroup_Impl, 0, Accessors...> { public: typedef AccessorGroup_Impl, 0, Accessors...> Base; AccessorGroup(ValueType const& value) : Base(value) { // } template AccessorGroup(ValueType const& value, Params... keys) : Base(value, keys...) { // } }; } } }