87 #include <argos3/core/utility/logging/argos_log.h>
94 template <
typename BASE>
101 template <
typename BASE>
107 template <
typename DERIVED,
typename BASE>
115 template <
typename DERIVED,
typename BASE>
129 template <
typename DERIVED,
typename BASE>
135 template <
typename BASE>
137 template <
typename DERIVED>
139 return GetTag<DERIVED, BASE>();
146 #define ENABLE_VTABLE() \
147 virtual size_t GetTag() { \
148 return GetTagHelper(this); \
154 template <
typename CONTEXT,
typename BASE,
typename FUNCTION>
157 template <
typename DERIVED>
158 void Add(FUNCTION t_function) {
160 size_t unIndex = GetTag<DERIVED, BASE>();
162 if(unIndex >= m_vecVTable.size()) {
168 const size_t unBaseTag = GetTag<BASE, BASE>();
169 FUNCTION tDefaultFunction = 0;
170 if(unBaseTag < m_vecVTable.size()) {
171 tDefaultFunction = m_vecVTable[unBaseTag];
174 m_vecVTable.resize(unIndex+1, tDefaultFunction);
176 m_vecVTable[unIndex] = t_function;
180 if(un_index >= m_vecVTable.size()) {
181 un_index = GetTag<BASE, BASE>();
183 return m_vecVTable[un_index];
187 return m_vecVTable.size();
191 std::vector<FUNCTION> m_vecVTable;
198 template <
typename CONTEXT,
typename BASE,
typename FUNCTION>
204 #define INIT_VTABLE_FOR(BASE) \
205 struct SVTableInitializerFor ## BASE { \
206 SVTableInitializerFor ## BASE() { \
207 GetTag<BASE, BASE>(); \
209 } sVTableInitializerFor ## BASE;
The namespace containing all the ARGoS related code.
size_t GetTag()
Returns the value of the tag associated to DERIVED
CVTable< CONTEXT, BASE, FUNCTION > & GetVTable()
Function that returns a reference to the static vtable.
Holds the value of the last used tag.
static size_t Count
Holds the value of the last used tag.
Holds the value of the tag associated to DERIVED
static size_t Tag
Force initialization of tag holder.
Helper to make a class hierarchy vtable-enabled.
size_t GetTagHelper(const DERIVED *) const
FUNCTION operator[](size_t un_index) const
void Add(FUNCTION t_function)