[Orxonox-commit 5908] r10567 - code/branches/core7/src/libraries/core/object
landauf at orxonox.net
landauf at orxonox.net
Tue Sep 8 16:16:28 CEST 2015
Author: landauf
Date: 2015-09-08 16:16:28 +0200 (Tue, 08 Sep 2015)
New Revision: 10567
Modified:
code/branches/core7/src/libraries/core/object/ObjectList.h
Log:
added functions to use ObjectList<T> for any context
Modified: code/branches/core7/src/libraries/core/object/ObjectList.h
===================================================================
--- code/branches/core7/src/libraries/core/object/ObjectList.h 2015-09-08 13:42:30 UTC (rev 10566)
+++ code/branches/core7/src/libraries/core/object/ObjectList.h 2015-09-08 14:16:28 UTC (rev 10567)
@@ -73,37 +73,52 @@
public:
typedef ObjectListIterator<T> iterator;
+ /// Returns the size of the list (for the root context)
+ inline static size_t size()
+ { return size(Context::getRootContext()); }
/// Returns the size of the list
- inline static size_t size()
+ inline static size_t size(Context* context)
{
- return Context::getRootContext()->getObjectList<T>()->size();
+ return context->getObjectList<T>()->size();
}
+ /// Returns an Iterator to the first element in the list (for the root context).
+ inline static ObjectListElement<T>* begin()
+ { return begin(Context::getRootContext()); }
/// Returns an Iterator to the first element in the list.
- inline static ObjectListElement<T>* begin()
+ inline static ObjectListElement<T>* begin(Context* context)
{
- ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
+ ObjectListBase* list = context->getObjectList<T>();
return static_cast<ObjectListElement<T>*>(list->begin());
}
+ /// Returns an Iterator to the element after the last element in the list (for the root context).
+ inline static ObjectListElement<T>* end()
+ { return end(Context::getRootContext()); }
/// Returns an Iterator to the element after the last element in the list.
- inline static ObjectListElement<T>* end()
+ inline static ObjectListElement<T>* end(Context* context)
{
- ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
+ ObjectListBase* list = context->getObjectList<T>();
return static_cast<ObjectListElement<T>*>(list->end());
}
+ /// Returns an Iterator to the last element in the list (for the root context).
+ inline static ObjectListElement<T>* rbegin()
+ { return rbegin(Context::getRootContext()); }
/// Returns an Iterator to the last element in the list.
- inline static ObjectListElement<T>* rbegin()
+ inline static ObjectListElement<T>* rbegin(Context* context)
{
- ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
+ ObjectListBase* list = context->getObjectList<T>();
return static_cast<ObjectListElement<T>*>(list->rbegin());
}
+ /// Returns an Iterator to the element before the first element in the list (for the root context).
+ inline static ObjectListElement<T>* rend()
+ { return rend(Context::getRootContext()); }
/// Returns an Iterator to the element before the first element in the list.
- inline static ObjectListElement<T>* rend()
+ inline static ObjectListElement<T>* rend(Context* context)
{
- ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
+ ObjectListBase* list = context->getObjectList<T>();
return static_cast<ObjectListElement<T>*>(list->rend());
}
};
More information about the Orxonox-commit
mailing list