Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

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

A dictionary which requires all elements to be subtypes of the PO template argument. More...

#include <plistCollections.h>

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

Detailed Description

template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
class plist::DictionaryOf< PO, Alloc >

A dictionary which requires all elements to be subtypes of the PO template argument.

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 dictionary 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 dictionary 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 dictionary. For convenience, a plist::Dictionary typedef is provided which does exactly this.

So plist::Dictionary can handle any mixture of types, whereas plist::DictionaryOf<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 DictionaryBase.

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 538 of file plistCollections.h.

List of all members.

Public Types

typedef DictionaryBase::storage_t storage_t
typedef PO entryRet_t
 older compilers don't support covariant returns, so this is the templated storage type on modern compilers, generic ObjectBase otherwise, can check defined(PLIST_NO_COVRET)

Public Member Functions

 DictionaryOf ()
 DictionaryOf (bool growable)
 constructor
 DictionaryOf (const DictionaryOf &d)
 copy constructor (don't assign listeners)
DictionaryOfoperator= (const DictionaryOf &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 DictionaryBase &a)
 handles actual setting of one dictionary to another, similar to operator=(DictionaryOf), but allows for polymorphic conversion to the template type
 ~DictionaryOf ()
 destructor
virtual void setEntry (const std::string &name, PO &val, bool warnExists=false)
 Replaces the entry with the specified key, optionally warns as it does so. If you simply want to set the *value* of the specified entry, try getEntry() and assignment...
virtual void addEntry (const std::string &name, PO &val, const std::string &comment="", bool warnExists=true)
 Convenience method for adding new entries, with optional comment and warning if replacing a previous entry.
virtual void setEntry (const std::string &name, PO *val, bool warnExists=false)
 Replaces the entry with the specified key, optionally warns as it does so. If you simply want to set the *value* of the specified entry, try getEntry() and assignment...
virtual void addEntry (const std::string &name, PO *val, const std::string &comment="", bool warnExists=true)
 Convenience method for adding new entries, with optional comment and warning if replacing a previous entry.
entryRet_tgetEntry (const std::string &name)
 returns a reference to the entry with the specified name, creating it if it doesn't exist
entryRet_toperator[] (const std::string &name)
 returns a reference to the entry with the specified name, creating it if it doesn't exist
const_iterator findEntry (const std::string &name) const
 returns an iterator the <key, value> pair with the specified key (returns end() if not found)
const_iterator begin () const
 return an STL const_iterator to the first entry (note implicit conversion to specialized const_iterator)
const_iterator end () const
 return the one-past-end const_iterator (note implicit conversion to specialized const_iterator)
virtual bool canContain (const ObjectBase &obj)
 returns true if the Collection subclass allows storage of the argument
virtual DictionaryOfclone () const __attribute__((warn_unused_result))
 clone implementation for Dictionary

Protected Member Functions

virtual bool loadXMLNode (const std::string &name, 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<DictionaryBase,PO>::value_conversion>
typedef PO plist::DictionaryOf< PO, Alloc >::entryRet_t

older compilers don't support covariant returns, so this is the templated storage type on modern compilers, generic ObjectBase otherwise, can check defined(PLIST_NO_COVRET)

Definition at line 600 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
typedef DictionaryBase::storage_t plist::DictionaryOf< PO, Alloc >::storage_t

shorthand for the type of the storage

Reimplemented from plist::DictionaryBase.

Definition at line 546 of file plistCollections.h.


Constructor & Destructor Documentation

template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
plist::DictionaryOf< PO, Alloc >::DictionaryOf (  ) 

constructor

Definition at line 570 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
plist::DictionaryOf< PO, Alloc >::DictionaryOf ( bool  growable  )  [explicit]

constructor

Definition at line 572 of file plistCollections.h.

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

copy constructor (don't assign listeners)

Definition at line 574 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
plist::DictionaryOf< PO, Alloc >::~DictionaryOf (  ) 

destructor

Definition at line 583 of file plistCollections.h.


Member Function Documentation

template<typename PO, typename Alloc >
void plist::DictionaryOf< PO, Alloc >::addEntry ( const std::string &  name,
PO *  val,
const std::string &  comment = "",
bool  warnExists = true 
) [virtual]

Convenience method for adding new entries, with optional comment and warning if replacing a previous entry.

By passing a pointer to the entry, you indicate you wish the dictionary to assume responsibility for deallocation

Definition at line 712 of file plistCollections.h.

template<typename PO, typename Alloc >
void plist::DictionaryOf< PO, Alloc >::addEntry ( const std::string &  name,
PO &  val,
const std::string &  comment = "",
bool  warnExists = true 
) [virtual]

Convenience method for adding new entries, with optional comment and warning if replacing a previous entry.

By passing a reference to the entry, you indicate you will retain responsibility for deallocation

Definition at line 667 of file plistCollections.h.

Referenced by Config::behaviors_config::behaviors_config(), CameraData::CameraData(), Config::Config(), Config::controller_config::controller_config(), OdometrySensor::declareValues(), GPSSensor::declareValues(), SensorFeedback::declareValues(), SensorContact::declareValues(), SensorRangeFinder::declareValues(), Config::vision_config::DepthCamConfig::DepthCamConfig(), ConfigurationEditor::getObjectTemplates(), XWalkParameters::init(), OdometrySensor::init(), GPSSensor::init(), SensorContact::init(), SensorRangeFinder::init(), SensorInfo::init(), PlannerObstacle< N >::init(), KinematicJoint::ControllerInfo::init(), LinkComponent::init(), DynamicRobotState::init(), DriverMessaging::ContactPoint::init(), KinematicJoint::initEntries(), InstanceTypeLoader::InstanceTypeLoader(), KoduConfig::KoduConfig(), XWalkParameters::LegParameters::LegParameters(), LinearMotorController::LinearMotorController(), DriverMessaging::LoadPrediction::LoadPrediction(), EllipsoidObstacle::loadXML(), SphericalObstacle::loadXML(), CylindricalObstacle::loadXML(), BoxObstacle::loadXML(), ConvexPolyObstacle::loadXML(), EllipticalObstacle::loadXML(), CircularObstacle::loadXML(), RectangularObstacle::loadXML(), plist::loadXML(), plist::DictionaryOf< PO, Alloc >::loadXMLNode(), Config::main_config::main_config(), Config::motion_config::motion_config(), MotorController::MotorController(), plist::DictionaryOf< PO, Alloc >::operator=(), OutputConfig< plist::Primitive< float > >::OutputConfig(), PhysicsWorld::PhysicsWorld(), PIDMotorController::PIDMotorController(), ProportionalMotorController::ProportionalMotorController(), Config::vision_config::RawCamConfig::RawCamConfig(), Config::vision_config::RegionCamConfig::RegionCamConfig(), InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::registerInstance(), EllipsoidObstacle::saveXML(), SphericalObstacle::saveXML(), CylindricalObstacle::saveXML(), BoxObstacle::saveXML(), ConvexPolyObstacle::saveXML(), EllipticalObstacle::saveXML(), CircularObstacle::saveXML(), RectangularObstacle::saveXML(), Config::vision_config::SegCamConfig::SegCamConfig(), DriverMessaging::SensorPriority::SensorPriority(), plist::DictionaryOf< PO, Alloc >::set(), XWalkParameters::SinusoidalParameters::SinusoidalParameters(), Config::sound_config::sound_config(), Config::sound_config::streaming_config::streaming_config(), Config::vision_config::StreamingConfig::StreamingConfig(), Config::vision_config::vision_config(), WheeledWalkMC::WheeledWalkMC(), and Config::wireless_config::wireless_config().

template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
const_iterator plist::DictionaryOf< PO, Alloc >::begin (  )  const

return an STL const_iterator to the first entry (note implicit conversion to specialized const_iterator)

Reimplemented from plist::DictionaryBase.

Reimplemented in PhysicsWorld.

Definition at line 624 of file plistCollections.h.

Referenced by InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::loadXML(), plist::DictionaryOf< PO, Alloc >::operator=(), plist::DictionaryOf< PO, Alloc >::set(), and XWalkMC::updateOutputsWalking().

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

returns true if the Collection subclass allows storage of the argument

Implements plist::Collection.

Reimplemented in plist::RGBColor< T >.

Definition at line 628 of file plistCollections.h.

template<typename PO , typename Alloc >
DictionaryOf< PO, Alloc > * plist::DictionaryOf< PO, Alloc >::clone (  )  const [virtual]
template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
const_iterator plist::DictionaryOf< PO, Alloc >::findEntry ( const std::string &  name  )  const
template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
entryRet_t& plist::DictionaryOf< PO, Alloc >::getEntry ( const std::string &  name  )  [virtual]

returns a reference to the entry with the specified name, creating it if it doesn't exist

Implements plist::DictionaryBase.

Reimplemented in OutputConfig< T >, and OutputConfig< plist::Primitive< float > >.

Definition at line 607 of file plistCollections.h.

Referenced by plist::DictionaryOf< plist::Point >::operator[]().

template<typename PO , typename Alloc >
bool plist::DictionaryOf< PO, Alloc >::loadXMLNode ( const std::string &  name,
xmlNode val,
const std::string &  comment 
) [protected, virtual]

called with each node being loaded so subclass can handle appropriately

Implements plist::DictionaryBase.

Reimplemented in ConfigDictionary, OutputConfig< T >, and OutputConfig< plist::Primitive< float > >.

Definition at line 740 of file plistCollections.h.

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

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

Definition at line 859 of file plistCollections.h.

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

template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
entryRet_t& plist::DictionaryOf< PO, Alloc >::operator[] ( const std::string &  name  )  [virtual]

returns a reference to the entry with the specified name, creating it if it doesn't exist

Implements plist::DictionaryBase.

Definition at line 619 of file plistCollections.h.

template<typename PO , typename Alloc >
void plist::DictionaryOf< PO, Alloc >::set ( const DictionaryBase a  )  [virtual]

handles actual setting of one dictionary to another, similar to operator=(DictionaryOf), but allows for polymorphic conversion to the template type

Definition at line 782 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
virtual void plist::DictionaryOf< 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 578 of file plistCollections.h.

template<typename PO, typename Alloc >
void plist::DictionaryOf< PO, Alloc >::setEntry ( const std::string &  name,
PO *  val,
bool  warnExists = false 
) [virtual]

Replaces the entry with the specified key, optionally warns as it does so. If you simply want to set the *value* of the specified entry, try getEntry() and assignment...

By passing a pointer to the entry, you indicate you wish the dictionary to assume responsibility for deallocation

Definition at line 690 of file plistCollections.h.

template<typename PO, typename Alloc >
void plist::DictionaryOf< PO, Alloc >::setEntry ( const std::string &  name,
PO &  val,
bool  warnExists = false 
) [virtual]

Replaces the entry with the specified key, optionally warns as it does so. If you simply want to set the *value* of the specified entry, try getEntry() and assignment...

By passing a reference to the entry, you indicate you will retain responsibility for deallocation

Definition at line 646 of file plistCollections.h.


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