Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

plist::ArrayBase Class Reference

Maintains an array of value, see ArrayOf, and the Array typedef. More...

#include <plistCollections.h>

Inheritance diagram for plist::ArrayBase:

Detailed Description

Maintains an array of value, see ArrayOf, and the Array typedef.

You can add or set entries by a quite a few variations on addEntry(), setEntry(), or addValue(). 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

Definition at line 929 of file plistCollections.h.

List of all members.

Classes

struct  ConversionTo
 This conversion policy accepts entries of the specified template type, and will try to create new instances of that type constructed from any values which are passed. More...
struct  DeniedValueConversions
 Indicates that no value conversions are allowed. More...
struct  EntryConstraint
struct  IntegerConversion
 Abstract base class to test whether the collection will accept integers (possibly converting to another value type, or storing directly as a [unsigned] long depending on concrete type). More...
struct  RealConversion
 Abstract base class to test whether the collection will accept floating point numbers (possibly converting to another value type, or storing directly as a double depending on concrete type). More...
struct  StringConversion
 Abstract base class to test whether the collection will accept strings (possibly converting to a value type, or storing directly as string depending on concrete type). More...
struct  WrapValueConversion
 This conversion policy accepts any entries of the specified template type, values will be directly wrapped as Primitives so no conversion at all is actually performed. More...

Public Types

typedef std::vector< ObjectBase * > storage_t
 shorthand for the type of the storage
typedef storage_t::iterator iterator
 shorthand for iterators to be returned
typedef storage_t::const_iterator const_iterator
 shorthand for iterators to be returned

Public Member Functions

virtual void forceEntry (ObjectBase &val, const std::string &comment="")=0
 adds a new entry to the end of the array, (de)allocation retained by caller
virtual void forceEntry (ObjectBase *val, const std::string &comment="")=0
 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="")=0
 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="")=0
 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 bool removeEntry (size_t index)
 remove the entry at position index, returns true if something was actually removed (if false, wasn't there to begin with)
ObjectBasegetEntry (size_t index) const
 return the value at position index, which must exist (no range checking)
ObjectBaseoperator[] (size_t index) const
 return the value at position index, which must exist (no range checking, equivalent to getEntry(index))
virtual ObjectBaseresolveEntry (const std::string &path) const
 recursively resolves path interpreted as a series of collection entry names separated by '.', returns NULL if it doesn't exist
virtual void clear ()
 remove all entries in one fell swoop
const_iterator begin () const
 return an STL const_iterator to the first entry
const_iterator end () const
 return the one-past-end const_iterator
virtual size_t size () const
 return the size of the array
ObjectBasefront () const
 return first element
ObjectBaseback () const
 return last element
virtual void setComment (size_t index, const std::string &comment)
 replaces previous comment for name, or adds it if it doesn't already exist (can preceed actual entry!)
virtual const std::string & getComment (size_t index) const
 returns comment retrieved from loaded file, or any subsequent call to setComment
virtual void loadXML (xmlNode *node)
 This specialization looks for the SensorInfo::sensorType, then has the factory construct the correct subtype before loading the node into and returning that.
virtual void saveXML (xmlNode *node) const
 subclasses are expected to provide a working implementation
virtual std::string toString () const
 return current value as a string
virtual unsigned int getLongestKeyLen (const regex_t *reg=NULL, unsigned int depth=-1) const
 returns longest key length which matches the regular expression
bool ownsReference (ObjectBase *val) const
 returns true if the specified object will be deallocated when removed from the array
virtual void setSaveInlineStyle (bool b)
 sets saveInlineStyle
virtual bool getSaveInlineStyle () const
 returns saveInlineStyle

Protected Types

typedef std::map< size_t,
std::string > 
comments_t
 shorthand for the type of comments

Protected Member Functions

 ArrayBase (bool growable)
 constructor
 ArrayBase (const ArrayBase &d)
 copy constructor
ArrayBaseoperator= (const ArrayBase &d)
 assignment
 ~ArrayBase ()
 destructor
virtual void takeObject (size_t index, ObjectBase *obj)
 indicates that the storage implementation should mark this as an externally supplied heap reference, which needs to be deleted on removal/destruction
virtual void fireEntryRemoved (ObjectBase &val)
 run through collectionListeners, calling CollectionListener::plistCollectionEntryRemoved(*this,val)
iterator getSubEntry (const std::string &name, std::string::size_type &seppos)
 returns an entry matching just the prefix
const_iterator getSubEntry (const std::string &name, std::string::size_type &seppos) const
 returns an entry matching just the prefix
virtual void cloneMyRef ()
 called after an assignment or copy to clone the objects in myRef to perform a deep copy
virtual bool loadXMLNode (size_t index, xmlNode *val, const std::string &comment)=0
 called by loadXML(), loads a single xmlNode into a specified position, replacing previous entry if it can't accept the new value (subject to the load/save policy...)

Protected Attributes

storage_t arr
 storage of entries
std::set< ObjectBase * > myRef
 objects which have been handed over to the collection for eventual de-allocation
comments_t comments
 storage of entry comments -- mapping from keys to help text comments for manual editing or user feedback
bool saveInlineStyle
 If true, will avoid line breaks between entries in serialized output, also skips comment headers.

Friends

std::ostream & operator<< (std::ostream &os, const ArrayBase &d)
 provides textual output

Member Typedef Documentation

typedef std::map<size_t,std::string> plist::ArrayBase::comments_t [protected]

shorthand for the type of comments

Definition at line 1169 of file plistCollections.h.

typedef storage_t::const_iterator plist::ArrayBase::const_iterator

shorthand for iterators to be returned

Definition at line 937 of file plistCollections.h.

typedef storage_t::iterator plist::ArrayBase::iterator

shorthand for iterators to be returned

Definition at line 935 of file plistCollections.h.


Constructor & Destructor Documentation

plist::ArrayBase::ArrayBase ( bool  growable  )  [protected]

constructor

Definition at line 1131 of file plistCollections.h.

plist::ArrayBase::ArrayBase ( const ArrayBase d  )  [protected]

copy constructor

Definition at line 1133 of file plistCollections.h.

plist::ArrayBase::~ArrayBase (  )  [protected]

destructor

Definition at line 1138 of file plistCollections.h.


Member Function Documentation

void plist::ArrayBase::clear (  )  [virtual]

remove all entries in one fell swoop

Implements plist::Collection.

Reimplemented in plist::RGBColor< T >.

Definition at line 797 of file plistCollections.cc.

Referenced by XWalkMC::stop(), GaitedFootstepMC::updateOutputs(), XWalkMC::updateOutputsInitial(), XWalkMC::updateOutputsWalking(), and ~ArrayBase().

void plist::ArrayBase::cloneMyRef (  )  [protected, virtual]

called after an assignment or copy to clone the objects in myRef to perform a deep copy

Definition at line 1021 of file plistCollections.cc.

Referenced by ArrayBase().

void plist::ArrayBase::fireEntryRemoved ( ObjectBase val  )  [protected, virtual]

run through collectionListeners, calling CollectionListener::plistCollectionEntryRemoved(*this,val)

Reimplemented from plist::Collection.

Reimplemented in plist::RGBColor< T >.

Definition at line 983 of file plistCollections.cc.

Referenced by removeEntry().

virtual void plist::ArrayBase::forceEntry ( size_t  index,
ObjectBase val,
const std::string &  comment = "" 
) [pure virtual]
const std::string & plist::ArrayBase::getComment ( size_t  index  )  const [virtual]

returns comment retrieved from loaded file, or any subsequent call to setComment

Definition at line 819 of file plistCollections.cc.

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

unsigned int plist::ArrayBase::getLongestKeyLen ( const regex_t *  reg = NULL,
unsigned int  depth = -1 
) const [virtual]

returns longest key length which matches the regular expression

Implements plist::Collection.

Reimplemented in plist::RGBColor< T >.

Definition at line 961 of file plistCollections.cc.

virtual bool plist::ArrayBase::getSaveInlineStyle (  )  const [virtual]

returns saveInlineStyle

Definition at line 1127 of file plistCollections.h.

ArrayBase::const_iterator plist::ArrayBase::getSubEntry ( const std::string &  name,
std::string::size_type &  seppos 
) const [protected]

returns an entry matching just the prefix

Parameters:
[in] name the name being looked up
[out] seppos the position of the separator (sub-collections are separated by '.')
Returns:
iterator of the sub entry

Definition at line 1006 of file plistCollections.cc.

ArrayBase::iterator plist::ArrayBase::getSubEntry ( const std::string &  name,
std::string::size_type &  seppos 
) [protected]

returns an entry matching just the prefix

Parameters:
[in] name the name being looked up
[out] seppos the position of the separator (sub-collections are separated by '.')
Returns:
iterator of the sub entry

Definition at line 992 of file plistCollections.cc.

Referenced by resolveEntry().

void plist::ArrayBase::loadXML ( xmlNode node  )  [virtual]

This specialization looks for the SensorInfo::sensorType, then has the factory construct the correct subtype before loading the node into and returning that.

From the name of node, will instantiate a new ObjectBase subclass to load it.

supports use of plist::ArrayOf<PlannerObstacle> for polymorphic load/save

The mapping from node names to actual instantiated types is:

If successful, returns a pointer to a newly allocated region, which the caller is responsible for freeing. If an error occurs, NULL is returned.

attempts to load a new T instance from the specified xmlNode

Reimplemented from plist::ObjectBase.

Reimplemented in plist::Point, and plist::RGBColor< T >.

Definition at line 827 of file plistCollections.cc.

Referenced by KinematicJointLoader::KinematicJointLoader().

virtual bool plist::ArrayBase::loadXMLNode ( size_t  index,
xmlNode val,
const std::string &  comment 
) [protected, pure virtual]
ArrayBase& plist::ArrayBase::operator= ( const ArrayBase d  )  [protected]

assignment

Definition at line 1135 of file plistCollections.h.

bool plist::ArrayBase::ownsReference ( ObjectBase val  )  const

returns true if the specified object will be deallocated when removed from the array

Definition at line 1124 of file plistCollections.h.

bool plist::ArrayBase::removeEntry ( size_t  index  )  [virtual]

remove the entry at position index, returns true if something was actually removed (if false, wasn't there to begin with)

Definition at line 773 of file plistCollections.cc.

Referenced by loadXML(), and ConvexPolyObstacle::saveXML().

ObjectBase * plist::ArrayBase::resolveEntry ( const std::string &  path  )  const [virtual]

recursively resolves path interpreted as a series of collection entry names separated by '.', returns NULL if it doesn't exist

Implements plist::Collection.

Reimplemented in plist::RGBColor< T >.

Definition at line 785 of file plistCollections.cc.

void plist::ArrayBase::saveXML ( xmlNode node  )  const [virtual]

subclasses are expected to provide a working implementation

Implements plist::ObjectBase.

Reimplemented in KinematicJointSaver, plist::Point, and plist::RGBColor< T >.

Definition at line 846 of file plistCollections.cc.

void plist::ArrayBase::setComment ( size_t  index,
const std::string &  comment 
) [virtual]

replaces previous comment for name, or adds it if it doesn't already exist (can preceed actual entry!)

Definition at line 810 of file plistCollections.cc.

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

void plist::ArrayBase::takeObject ( size_t  index,
ObjectBase obj 
) [protected, virtual]

indicates that the storage implementation should mark this as an externally supplied heap reference, which needs to be deleted on removal/destruction

Definition at line 979 of file plistCollections.cc.

Referenced by plist::ArrayOf< PO, Alloc >::addEntry(), plist::ArrayOf< plist::Primitive< PLISTREAL > >::addEntry(), and plist::ArrayOf< PO, Alloc >::setEntry().

std::string plist::ArrayBase::toString (  )  const [virtual]

return current value as a string

Implements plist::ObjectBase.

Reimplemented in plist::RGBColor< T >.

Definition at line 955 of file plistCollections.cc.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const ArrayBase d 
) [friend]

provides textual output

Definition at line 1581 of file plistCollections.h.


Member Data Documentation

storage of entry comments -- mapping from keys to help text comments for manual editing or user feedback

not every key necessarily has a comment!

Definition at line 1172 of file plistCollections.h.

Referenced by clear(), getComment(), removeEntry(), saveXML(), and setComment().

If true, will avoid line breaks between entries in serialized output, also skips comment headers.

This might make short lists more readable.

Definition at line 1176 of file plistCollections.h.

Referenced by getSaveInlineStyle(), saveXML(), and setSaveInlineStyle().


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

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