Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

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

#include <plistCollections.h>

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

List of all members.


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


Public Types

typedef DictionaryBase::storage_t storage_t

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.
PO & getEntry (const std::string &name)
 returns a reference to the entry with the specified name, creating it if it doesn't exist
PO & operator[] (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

Static Protected Member Functions

static PO * allocatePO ()
 allocates a new PO instance, unless PO is an abstract type, in which case a template specialization will throw a bad_cast
static void assignPO (PO &a, const PO &b)
 assigns one PO to another, unless PO is ObjectBase, in which case set() is used (via template specialization)

Member Typedef Documentation

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 422 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 (  )  [inline]

constructor

Definition at line 446 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  )  [inline, explicit]

constructor

Definition at line 448 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  )  [inline]

copy constructor (don't assign listeners)

Definition at line 450 of file plistCollections.h.

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

destructor

Definition at line 459 of file plistCollections.h.


Member Function Documentation

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

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

Definition at line 741 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>
virtual void plist::DictionaryOf< PO, Alloc >::set ( const ObjectBase  )  [inline, 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.

Definition at line 454 of file plistCollections.h.

template<typename PO, typename Alloc>
void plist::DictionaryOf< PO, Alloc >::set ( const DictionaryBase a  )  [inline, 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 669 of file plistCollections.h.

template<typename PO, typename Alloc>
void plist::DictionaryOf< PO, Alloc >::setEntry ( const std::string &  name,
PO &  val,
bool  warnExists = false 
) [inline, 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 517 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 
) [inline, 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 538 of file plistCollections.h.

Referenced by plist::ArrayBase::WrapValueConversion< PO >::addValue(), plist::ArrayBase::ConversionTo< PO >::addValue(), ConfigurationEditor::getObjectTemplates(), plist::DictionaryOf< PO, Alloc >::loadXMLNode(), plist::DictionaryOf< PO, Alloc >::operator=(), InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::registerInstance(), and plist::DictionaryOf< PO, Alloc >::set().

template<typename PO, typename Alloc>
void plist::DictionaryOf< PO, Alloc >::setEntry ( const std::string &  name,
PO *  val,
bool  warnExists = false 
) [inline, 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 561 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 
) [inline, 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 583 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
PO& plist::DictionaryOf< PO, Alloc >::getEntry ( const std::string &  name  )  [inline, 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 475 of file plistCollections.h.

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

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

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

Implements plist::DictionaryBase.

Definition at line 486 of file plistCollections.h.

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 [inline]

returns an iterator the <key, value> pair with the specified key (returns end() if not found)

Reimplemented from plist::DictionaryBase.

Definition at line 488 of file plistCollections.h.

Referenced by Config::setValue().

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

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

Reimplemented from plist::DictionaryBase.

Definition at line 491 of file plistCollections.h.

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

template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
const_iterator plist::DictionaryOf< PO, Alloc >::end (  )  const [inline]

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

returns true if the Collection subclass allows storage of the argument

Implements plist::Collection.

Definition at line 495 of file plistCollections.h.

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

clone implementation for Dictionary

implements the clone function for dictionary

Implements plist::ObjectBase.

Definition at line 608 of file plistCollections.h.

template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
static PO* plist::DictionaryOf< PO, Alloc >::allocatePO (  )  [inline, static, protected]

allocates a new PO instance, unless PO is an abstract type, in which case a template specialization will throw a bad_cast

Definition at line 502 of file plistCollections.h.

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

template<typename PO, typename Alloc = typename PO::template conversion_policy<DictionaryBase,PO>::value_conversion>
static void plist::DictionaryOf< PO, Alloc >::assignPO ( PO &  a,
const PO &  b 
) [inline, static, protected]

assigns one PO to another, unless PO is ObjectBase, in which case set() is used (via template specialization)

Definition at line 504 of file plistCollections.h.

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

template<typename PO, typename Alloc>
bool plist::DictionaryOf< PO, Alloc >::loadXMLNode ( const std::string &  name,
xmlNode val,
const std::string &  comment 
) [inline, 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 622 of file plistCollections.h.


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

Tekkotsu v4.0
Generated Thu Nov 22 00:58:55 2007 by Doxygen 1.5.4