Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

plist::ArrayOf< PO, Alloc > Class Template Reference

A collection of plist objects, similar to a Dictionary, but no keys -- order matters!, see plist::Array. More...

#include <plistCollections.h>

Inheritance diagram for plist::ArrayOf< PO, Alloc >:

Detailed Description

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
class plist::ArrayOf< PO, Alloc >

A collection of plist objects, similar to a Dictionary, but no keys -- order matters!, see plist::Array.

You can add or set entries by a quite a few variations on addEntry(), setEntry(), and addValue (via the Alloc conversion policy) Basically these boil down to either:

  • pass a pointer to an ObjectBase or directly pass a primitive value (int, float, char, etc.), in which case the Array will assume management of the corresponding ObjectBase instance (freeing the memory region when removed)
  • pass a reference to an ObjectBase, in which case you retain control over the object's allocation

You have probably noticed this is a templated class -- you can provide any of the ObjectBase subclasses to restrict the storage to that particular type, which will make life easier when retrieving objects since their type will be known.

However, if you want an Array of mixed types, you can pass ObjectBase itself for the template parameter, and you can then insert any combination of the plist types into the same array. For convenience, a plist::Array typedef is provided which does exactly this.

So plist::Array can handle any mixture of types, whereas plist::ArrayOf<PO> will only accept the plist objects of type PO (or their subclasses). The Alloc template argument allows you to define how new string values will be handled from ArrayBase.

The optional conversion policy template specifies a base class for the dictionary which can control how the dictionary will handle conversions from non-PO-based types.

Definition at line 1205 of file plistCollections.h.

List of all members.

Public Types

typedef ArrayBase::storage_t storage_t

Public Member Functions

 ArrayOf ()
 ArrayOf (typename storage_t::size_type n)
 constructor, create n entries using default constructor, defaults to non-growable (load does not change size)
 ArrayOf (typename storage_t::size_type n, const PO &t, bool growable=false)
 constructor, create n copies of t, defaults to non-growable (load does not change size)
 ArrayOf (const ArrayOf &d)
 copy constructor (don't assign listeners)
ArrayOfoperator= (const ArrayOf &a)
 assignment (don't assign listeners); subclass should call fireEntriesChanged after calling this (and updating its own storage)
virtual void set (const ObjectBase &ob)
 polymorphic assignment (throws std::bad_cast if the assignment is between invalid types, i.e. a primitive and a collection, or different collection types)
virtual void set (const ArrayBase &a)
 handles polymorphic assignment of ArrayBase subclasses, similar to operator=(ArrayOf), but allows conversion of entries
 ~ArrayOf ()
 destructor
virtual void addEntry (PO &val, const std::string &comment="")
 adds a new entry to the end of the array, (de)allocation retained by caller
virtual void addEntry (PO *val, const std::string &comment="")
 adds a new entry to the end of the array, (de)allocation responsibility of array
virtual void setEntry (size_t index, PO &val, bool warnExists=false)
 replaces previous entry at the specified index, which must be less than or equal to the current array size
virtual void addEntry (size_t index, PO &val, const std::string &comment="")
 displaces previous entry at the specified index, which must be less than or equal to the current array size
virtual void setEntry (size_t index, PO *val, bool warnExists=false)
 replaces previous entry at the specified index, which must be less than or equal to the current array size; control of (de)allocation will be assumed by the Array
virtual void addEntry (size_t index, PO *val, const std::string &comment="")
 displaces previous entry at the specified index, which must be less than or equal to the current array size; control of (de)allocation will be assumed by the Array
virtual void forceEntry (ObjectBase &val, const std::string &comment="")
 adds a new entry to the end of the array, (de)allocation retained by caller
virtual void forceEntry (ObjectBase *val, const std::string &comment="")
 adds a new entry to the end of the array, (de)allocation responsibility of array
virtual void forceEntry (size_t index, ObjectBase &val, const std::string &comment="")
 displaces previous entry at the specified index, which must be less than or equal to the current array size
virtual void forceEntry (size_t index, ObjectBase *val, const std::string &comment="")
 displaces previous entry at the specified index, which must be less than or equal to the current array size; control of (de)allocation will be assumed by the Array
PO & getEntry (size_t index) const
 return the value at position index, which must exist (no range checking)
PO & operator[] (size_t index) const
 return the value at position index, which must exist (no range checking, equivalent to getEntry(index))
const_iterator begin () const
 return an STL const_iterator to the first entry
const_iterator end () const
 return the one-past-end const_iterator
PO & front () const
 return first element
PO & back () const
 return last element
virtual bool canContain (const ObjectBase &obj)
 returns true if the array can store the specified object
virtual ArrayOfclone () const __attribute__((warn_unused_result))
 clone implementation for Array

Protected Member Functions

virtual bool loadXMLNode (size_t index, xmlNode *val, const std::string &comment)
 called with each node being loaded so subclass can handle appropriately

Member Typedef Documentation

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
typedef ArrayBase::storage_t plist::ArrayOf< PO, Alloc >::storage_t

shorthand for the type of the storage

Reimplemented from plist::ArrayBase.

Reimplemented in plist::Point.

Definition at line 1212 of file plistCollections.h.


Constructor & Destructor Documentation

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
plist::ArrayOf< PO, Alloc >::ArrayOf (  ) 

constructor

Definition at line 1255 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
plist::ArrayOf< PO, Alloc >::ArrayOf ( typename storage_t::size_type  n  )  [explicit]

constructor, create n entries using default constructor, defaults to non-growable (load does not change size)

Definition at line 1257 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
plist::ArrayOf< PO, Alloc >::ArrayOf ( typename storage_t::size_type  n,
const PO &  t,
bool  growable = false 
)

constructor, create n copies of t, defaults to non-growable (load does not change size)

Definition at line 1264 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
plist::ArrayOf< PO, Alloc >::ArrayOf ( const ArrayOf< PO, Alloc > &  d  ) 

copy constructor (don't assign listeners)

Definition at line 1281 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
plist::ArrayOf< PO, Alloc >::~ArrayOf (  ) 

destructor

Definition at line 1289 of file plistCollections.h.


Member Function Documentation

template<typename PO, typename Alloc >
void ArrayOf::addEntry ( size_t  index,
PO *  val,
const std::string &  comment = "" 
) [virtual]

displaces previous entry at the specified index, which must be less than or equal to the current array size; control of (de)allocation will be assumed by the Array

Definition at line 1406 of file plistCollections.h.

template<typename PO, typename Alloc >
void ArrayOf::addEntry ( size_t  index,
PO &  val,
const std::string &  comment = "" 
) [virtual]

displaces previous entry at the specified index, which must be less than or equal to the current array size

Definition at line 1369 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
virtual void plist::ArrayOf< PO, Alloc >::addEntry ( PO *  val,
const std::string &  comment = "" 
) [virtual]

adds a new entry to the end of the array, (de)allocation responsibility of array

Definition at line 1294 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
virtual void plist::ArrayOf< PO, Alloc >::addEntry ( PO &  val,
const std::string &  comment = "" 
) [virtual]
template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
PO& plist::ArrayOf< PO, Alloc >::back (  )  const

return last element

Reimplemented from plist::ArrayBase.

Definition at line 1326 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
virtual bool plist::ArrayOf< PO, Alloc >::canContain ( const ObjectBase obj  )  [virtual]

returns true if the array can store the specified object

Implements plist::Collection.

Reimplemented in plist::RGBColor< T >.

Definition at line 1329 of file plistCollections.h.

template<typename PO , typename Alloc >
ArrayOf< PO, Alloc > * ArrayOf::clone (  )  const [virtual]

clone implementation for Array

implements the clone function for Array

Implements plist::ObjectBase.

Reimplemented in plist::RGBColor< T >.

Definition at line 1423 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
virtual void plist::ArrayOf< PO, Alloc >::forceEntry ( size_t  index,
ObjectBase val,
const std::string &  comment = "" 
) [virtual]

displaces previous entry at the specified index, which must be less than or equal to the current array size; control of (de)allocation will be assumed by the Array

Implements plist::ArrayBase.

Definition at line 1312 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
virtual void plist::ArrayOf< PO, Alloc >::forceEntry ( size_t  index,
ObjectBase val,
const std::string &  comment = "" 
) [virtual]

displaces previous entry at the specified index, which must be less than or equal to the current array size

Implements plist::ArrayBase.

Definition at line 1310 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
virtual void plist::ArrayOf< PO, Alloc >::forceEntry ( ObjectBase val,
const std::string &  comment = "" 
) [virtual]

adds a new entry to the end of the array, (de)allocation responsibility of array

Implements plist::ArrayBase.

Definition at line 1308 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
virtual void plist::ArrayOf< PO, Alloc >::forceEntry ( ObjectBase val,
const std::string &  comment = "" 
) [virtual]

adds a new entry to the end of the array, (de)allocation retained by caller

Implements plist::ArrayBase.

Definition at line 1306 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
PO& plist::ArrayOf< PO, Alloc >::front (  )  const

return first element

Reimplemented from plist::ArrayBase.

Definition at line 1324 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
PO& plist::ArrayOf< PO, Alloc >::getEntry ( size_t  index  )  const

return the value at position index, which must exist (no range checking)

Reimplemented from plist::ArrayBase.

Definition at line 1315 of file plistCollections.h.

template<typename PO , typename Alloc >
bool ArrayOf::loadXMLNode ( size_t  index,
xmlNode val,
const std::string &  comment 
) [protected, virtual]

called with each node being loaded so subclass can handle appropriately

Implements plist::ArrayBase.

Reimplemented in KinematicJointLoader.

Definition at line 1426 of file plistCollections.h.

template<typename PO , typename Alloc >
ArrayOf< PO, Alloc > & ArrayOf::operator= ( const ArrayOf< PO, Alloc > &  a  ) 

assignment (don't assign listeners); subclass should call fireEntriesChanged after calling this (and updating its own storage)

Definition at line 1519 of file plistCollections.h.

Referenced by plist::ArrayOf< PO, Alloc >::set().

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
PO& plist::ArrayOf< PO, Alloc >::operator[] ( size_t  index  )  const

return the value at position index, which must exist (no range checking, equivalent to getEntry(index))

Reimplemented from plist::ArrayBase.

Definition at line 1317 of file plistCollections.h.

template<typename PO , typename Alloc >
void ArrayOf::set ( const ArrayBase a  )  [virtual]

handles polymorphic assignment of ArrayBase subclasses, similar to operator=(ArrayOf), but allows conversion of entries

Definition at line 1458 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<ArrayBase,PO>::value_conversion>
virtual void plist::ArrayOf< PO, Alloc >::set ( const ObjectBase  )  [virtual]

polymorphic assignment (throws std::bad_cast if the assignment is between invalid types, i.e. a primitive and a collection, or different collection types)

Implements plist::ObjectBase.

Reimplemented in plist::RGBColor< T >.

Definition at line 1285 of file plistCollections.h.

template<typename PO, typename Alloc >
void ArrayOf::setEntry ( size_t  index,
PO *  val,
bool  warnExists = false 
) [virtual]

replaces previous entry at the specified index, which must be less than or equal to the current array size; control of (de)allocation will be assumed by the Array

Definition at line 1382 of file plistCollections.h.

template<typename PO, typename Alloc >
void ArrayOf::setEntry ( size_t  index,
PO &  val,
bool  warnExists = false 
) [virtual]

replaces previous entry at the specified index, which must be less than or equal to the current array size

Definition at line 1353 of file plistCollections.h.

Referenced by plist::ArrayOf< PO, Alloc >::loadXMLNode(), plist::ArrayOf< PO, Alloc >::operator=(), and plist::ArrayOf< PO, Alloc >::set().


The documentation for this class was generated from the following file:

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:25 2016 by Doxygen 1.6.3