Changeset 11071 for code/trunk/src/libraries/core/object/ObjectList.h
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/object/ObjectList.h
r10624 r11071 47 47 #include "core/CorePrereqs.h" 48 48 49 #include <boost/static_assert.hpp>50 #include <boost/type_traits/is_base_of.hpp>51 52 49 #include "ObjectListBase.h" 53 50 #include "ObjectListIterator.h" … … 69 66 class ObjectList 70 67 { 71 BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value));68 static_assert(std::is_base_of<Listable, T>::value, "ObjectList can only be used with Listables"); 72 69 73 70 public: 74 71 typedef ObjectListIterator<T> iterator; 75 72 76 /// Returns the size of the list (for the root context) 77 inline static size_t size() 78 { return size(Context::getRootContext()); } 73 ObjectList() : ObjectList(Context::getRootContext()) {} 74 ObjectList(Context* context) : ObjectList(context->getObjectList<T>()) {} 75 ObjectList(ObjectListBase* list) : list_(list) {} 76 79 77 /// Returns the size of the list 80 inline static size_t size(Context* context) 81 { 82 return context->getObjectList<T>()->size(); 83 } 78 inline size_t size() 79 { return this->list_->size(); } 84 80 85 /// Returns an Iterator to the first element in the list (for the root context).86 inline static ObjectListElement<T>* begin()87 { return begin(Context::getRootContext()); }88 81 /// Returns an Iterator to the first element in the list. 89 inline static ObjectListElement<T>* begin(Context* context)90 { 91 ObjectListBase* list = context->getObjectList<T>();92 return static_cast<ObjectListElement<T>*>(list->begin());93 }82 inline ObjectListIterator<T> begin() 83 { return static_cast<ObjectListElement<T>*>(this->list_->begin()); } 84 /// Returns an Iterator to the element after the last element in the list. 85 inline ObjectListIterator<T> end() 86 { return static_cast<ObjectListElement<T>*>(this->list_->end()); } 94 87 95 /// Returns an Iterator to the element after the last element in the list (for the root context). 96 inline static ObjectListElement<T>* end() 97 { return end(Context::getRootContext()); } 98 /// Returns an Iterator to the element after the last element in the list. 99 inline static ObjectListElement<T>* end(Context* context) 100 { 101 ObjectListBase* list = context->getObjectList<T>(); 102 return static_cast<ObjectListElement<T>*>(list->end()); 103 } 88 /// Returns an Iterator to the last element in the list. 89 inline ObjectListIterator<T> rbegin() 90 { return static_cast<ObjectListElement<T>*>(this->list_->rbegin()); } 91 /// Returns an Iterator to the element before the first element in the list. 92 inline ObjectListIterator<T> rend() 93 { return static_cast<ObjectListElement<T>*>(this->list_->rend()); } 104 94 105 /// Returns an Iterator to the last element in the list (for the root context). 106 inline static ObjectListElement<T>* rbegin() 107 { return rbegin(Context::getRootContext()); } 108 /// Returns an Iterator to the last element in the list. 109 inline static ObjectListElement<T>* rbegin(Context* context) 110 { 111 ObjectListBase* list = context->getObjectList<T>(); 112 return static_cast<ObjectListElement<T>*>(list->rbegin()); 113 } 114 115 /// Returns an Iterator to the element before the first element in the list (for the root context). 116 inline static ObjectListElement<T>* rend() 117 { return rend(Context::getRootContext()); } 118 /// Returns an Iterator to the element before the first element in the list. 119 inline static ObjectListElement<T>* rend(Context* context) 120 { 121 ObjectListBase* list = context->getObjectList<T>(); 122 return static_cast<ObjectListElement<T>*>(list->rend()); 123 } 95 private: 96 ObjectListBase* list_; 124 97 }; 125 98 }
Note: See TracChangeset
for help on using the changeset viewer.