Go to the documentation of this file.
5 #ifndef CNOID_UTIL_POLYMORPHIC_REFERENCED_ARRAY_H
6 #define CNOID_UTIL_POLYMORPHIC_REFERENCED_ARRAY_H
13 template <
class BaseReferencedType = Referenced>
19 virtual BaseReferencedType*
get_element(
size_t i) = 0;
20 virtual const BaseReferencedType*
get_element(
size_t i)
const = 0;
26 template <
class ReferencedType,
class BaseReferencedType = Referenced,
class Po
interType = ReferencedType*>
29 typedef std::vector<PointerType> Container;
42 template <
class RhsReferencedType,
class RhsPo
interType>
51 if(ReferencedType* p =
dynamic_cast<ReferencedType*
>(obj)){
69 template <
class RhsReferencedType,
class RhsPo
interType>
77 template <
class RetReferencedType,
class RetPo
interType>
79 for(std::size_t i=0; i < rhs.
size(); ++i){
85 template <
class RetReferencedType,
class RetPo
interType>
87 size_t orgSize =
size();
89 typename ArgType::iterator p = another.
begin();
90 while(p != another.
end()){
91 if(ReferencedType* element =
dynamic_cast<ReferencedType*
>(p->get())){
98 return (
size() > orgSize);
105 if(RetReferencedType* element =
dynamic_cast<RetReferencedType*
>(p->get())){
116 return elements.empty();
120 elements.reserve(
size);
124 elements.resize(
size);
128 return elements.size();
136 return elements.begin();
140 return elements.begin();
144 return elements.end();
148 return elements.end();
152 return elements.back();
155 const PointerType&
back()
const {
156 return elements.back();
160 return elements.front();
164 return elements.front();
192 elements.push_back(obj);
200 return elements.erase(pos);
Container::iterator iterator
Definition: PolymorphicReferencedArray.h:35
virtual size_t get_size() const =0
bool empty() const
Definition: PolymorphicReferencedArray.h:115
PolymorphicReferencedArray(const PolymorphicReferencedArray< RhsReferencedType, BaseReferencedType, RhsPointerType > &rhs)
Definition: PolymorphicReferencedArray.h:43
PolymorphicReferencedArrayBase< BaseReferencedType > ArrayBase
Definition: PolymorphicReferencedArray.h:33
const_iterator begin() const
Definition: PolymorphicReferencedArray.h:139
void push_back(const PointerType &obj)
Definition: PolymorphicReferencedArray.h:191
iterator end()
Definition: PolymorphicReferencedArray.h:143
virtual void clear_elements()=0
void clear()
Definition: PolymorphicReferencedArray.h:183
const PointerType & back() const
Definition: PolymorphicReferencedArray.h:155
virtual bool try_push_back(BaseReferencedType *obj)=0
virtual void clear_elements()
Definition: PolymorphicReferencedArray.h:187
virtual BaseReferencedType * get_element(size_t i)=0
void pop_back()
Definition: PolymorphicReferencedArray.h:195
Container::value_type value_type
Definition: PolymorphicReferencedArray.h:34
const PointerType & operator[](std::size_t i) const
Definition: PolymorphicReferencedArray.h:171
PolymorphicReferencedArray()
Definition: PolymorphicReferencedArray.h:40
virtual BaseReferencedType * get_element(size_t i)
Definition: PolymorphicReferencedArray.h:175
virtual ~PolymorphicReferencedArrayBase()
Definition: PolymorphicReferencedArray.h:17
virtual size_t get_size() const
Definition: PolymorphicReferencedArray.h:131
PointerType & operator[](std::size_t i)
Definition: PolymorphicReferencedArray.h:167
PolymorphicReferencedArray & assign(const PolymorphicReferencedArray< RhsReferencedType, BaseReferencedType, RhsPointerType > &another)
Definition: PolymorphicReferencedArray.h:70
Definition: AbstractSceneLoader.h:11
Container::const_reference const_reference
Definition: PolymorphicReferencedArray.h:38
bool extractFrom(PolymorphicReferencedArray< RetReferencedType, BaseReferencedType, RetPointerType > &another)
Definition: PolymorphicReferencedArray.h:86
iterator erase(iterator pos)
Definition: PolymorphicReferencedArray.h:199
const_iterator end() const
Definition: PolymorphicReferencedArray.h:147
PointerType & back()
Definition: PolymorphicReferencedArray.h:151
Container::const_iterator const_iterator
Definition: PolymorphicReferencedArray.h:36
PolymorphicReferencedArray extract()
Definition: PolymorphicReferencedArray.h:101
virtual ~PolymorphicReferencedArray()
Definition: PolymorphicReferencedArray.h:48
Definition: PolymorphicReferencedArray.h:14
bool operator==(const PolymorphicReferencedArray &rhs) const
Definition: PolymorphicReferencedArray.h:58
iterator begin()
Definition: PolymorphicReferencedArray.h:135
bool operator!=(const PolymorphicReferencedArray &rhs) const
Definition: PolymorphicReferencedArray.h:65
virtual bool try_push_back(BaseReferencedType *obj)
Definition: PolymorphicReferencedArray.h:50
void resize(size_t size)
Definition: PolymorphicReferencedArray.h:123
PolymorphicReferencedArray & operator<<(const PolymorphicReferencedArray< RetReferencedType, BaseReferencedType, RetPointerType > &rhs)
Definition: PolymorphicReferencedArray.h:78
std::size_t size() const
Definition: PolymorphicReferencedArray.h:127
Definition: PolymorphicReferencedArray.h:27
PointerType & front()
Definition: PolymorphicReferencedArray.h:159
virtual const BaseReferencedType * get_element(size_t i) const
Definition: PolymorphicReferencedArray.h:179
void reserve(size_t size)
Definition: PolymorphicReferencedArray.h:119
const PointerType & front() const
Definition: PolymorphicReferencedArray.h:163
Container::reference reference
Definition: PolymorphicReferencedArray.h:37