Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

plist::ObjectBase Class Reference

This base class provides the root functionality for all plist entities -- Dictionary and the various templated subclasses of PrimitiveBase. More...

#include <plistBase.h>

Inheritance diagram for plist::ObjectBase:

Detailed Description

This base class provides the root functionality for all plist entities -- Dictionary and the various templated subclasses of PrimitiveBase.

The subclasses may throw XMLLoadSave::bad_format if the document is poorly structured or bad values are found.

Definition at line 133 of file plistBase.h.

List of all members.

Classes

struct  conversion_policy
 specifies that collections (e.g. plist::Array or plist::Dictionary) of these abstract base classes (ObjectBase, PrimitiveBase) can convert any primitive type to a plist::Primitive wrapper More...

Public Member Functions

 ObjectBase ()
 constructor
virtual ~ObjectBase ()=0
 destructor
virtual void set (const ObjectBase &)=0
 polymorphic assignment (throws std::bad_cast if the assignment is between invalid types, i.e. a primitive and a collection, or different collection types)
template<typename T >
castTo () const
 casting operator: return current value as specified type (throws std::runtime_error exception if bad cast, e.g. dictionary or array to value type)
virtual std::string toString () const =0
 return current value as a string
virtual bool toBool () const
 return current value as a boolean (throws std::runtime_error exception if incompatable, e.g. dictionary or array to value type)
virtual char toChar () const
 return current value as a character (throws std::runtime_error exception if incompatable, e.g. dictionary or array to value type)
virtual long toLong () const =0
 return current value as an (long) integer (throws std::runtime_error exception if incompatable, e.g. dictionary or array to value type)
virtual double toDouble () const =0
 return current value as a double (throws std::runtime_error exception if incompatable, e.g. dictionary or array to value type)
virtual void loadXML (xmlNode *node)=0
 subclasses are expected to provide a working implementation
virtual void saveXML (xmlNode *node) const =0
 subclasses are expected to provide a working implementation
virtual ObjectBaseclone () const __attribute__((warn_unused_result))=0
 allows a copy to be made of an event, supporting polymorphism
virtual void setParseTree (xmlDoc *doc) const
 assigns a parse tree which you have obtained from some other source

Protected Member Functions

ObjectBaseoperator= (const ObjectBase &)
 polymorphic assignment operator, see assign()
virtual xmlNodeFindRootXMLElement (xmlDoc *doc) const
 returns the root element of the xml document

Static Protected Member Functions

static bool matchTrue (const std::string &str)
 returns true if str is some form of affirmative (e.g. "true" or "yes")
static bool matchFalse (const std::string &str)
 returns true if str is some form of negative (e.g. "false" or "no")
libxml Forwards

Provides accessor functions to struct fields without having to include libxml.h everywhere

static bool xNodeHasName (xmlNode *node, const char *name)
 returns true if the name of node matches name
static const xmlCharxNodeGetName (xmlNode *node)
 returns name of node (not a libxml function)
static xmlCharxGetNodePath (xmlNode *node)
 returns path from document root to node (forwards to xmlGetNodePath, returns new allocation, so call xmlFree)
static const xmlCharxNodeGetURL (xmlNode *node)
 returns URL/file of node (not a libxml function)
static xmlNodexNodeGetChildren (xmlNode *node)
 returns children of node (not a libxml function)
static xmlNodexNodeGetLastChild (xmlNode *node)
 returns last child of node (not a libxml function)
static xmlNodexNodeGetNextNode (xmlNode *node)
 returns next node (sibling) after node (not a libxml function)
static xmlNodexNodeGetPrevNode (xmlNode *node)
 returns previous node (sibling) before node (not a libxml function)
static xmlNodexNodeGetParent (xmlNode *node)
 returns parent node of node (not a libxml function)
static xmlDocxNodeGetDoc (xmlNode *node)
 returns document node of node (not a libxml function)
static bool xNodeIsText (xmlNode *node)
 returns true if node is an XML_TEXT_NODE (not a libxml function)
static bool xNodeIsElement (xmlNode *node)
 returns true if node is an XML_ELEMENT_NODE (not a libxml function)
static bool xNodeIsComment (xmlNode *node)
 returns true if node is an XML_COMMENT_NODE (not a libxml function)

Friends

ObjectBaseloadXML (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.

Constructor & Destructor Documentation

plist::ObjectBase::ObjectBase (  ) 

constructor

Definition at line 11 of file plistBase.cc.

plist::ObjectBase::~ObjectBase (  )  [pure virtual]

destructor

Definition at line 15 of file plistBase.cc.


Member Function Documentation

template<typename T >
T plist::ObjectBase::castTo (  )  const

casting operator: return current value as specified type (throws std::runtime_error exception if bad cast, e.g. dictionary or array to value type)

The implementation for this function is defined by a series of specializations. This allows you to add casts for additional user-defined types, as well as get compile time error if you attempt to cast to an unsupported type. (I really wish we had virtual templated functions...)

Referenced by plist::Primitive< bool >::operator=(), XWalkMC::ParameterTransition::plistValueChanged(), and XWalkMC::ParameterTransition::update().

virtual ObjectBase* plist::ObjectBase::clone (  )  const [pure virtual]

allows a copy to be made of an event, supporting polymorphism

Implements Cloneable.

Implemented in LinkComponent, KinematicJoint, SensorInfo, SensorRangeFinder, SensorContact, SensorFeedback, GPSSensor, OdometrySensor, RectangularObstacle, CircularObstacle, EllipticalObstacle, ConvexPolyObstacle, HierarchicalObstacle, BoxObstacle, CylindricalObstacle, SphericalObstacle, EllipsoidObstacle, plist::DictionaryOf< PO, Alloc >, plist::ArrayOf< PO, Alloc >, plist::Primitive< T >, plist::NamedEnumeration< T >, plist::OutputSelector, plist::Angle, plist::RGBColor< T >, plist::DictionaryOf< SinusoidalParameters >, plist::DictionaryOf< plist::Primitive< float > >, plist::DictionaryOf< plist::Primitive< T > >, plist::DictionaryOf< plist::Point >, plist::ArrayOf< ContactPoint >, plist::ArrayOf< plist::ArrayOf< plist::Primitive< float > > >, plist::ArrayOf< LinkComponent >, plist::ArrayOf< SensorInfo >, plist::ArrayOf< plist::Primitive< std::string > >, plist::ArrayOf< KinematicJoint >, plist::ArrayOf< plist::Primitive< float > >, plist::ArrayOf< plist::Primitive< T > >, plist::ArrayOf< plist::Angle >, plist::ArrayOf< LegParameters >, plist::ArrayOf< plist::Primitive< PLISTREAL > >, plist::Primitive< fmat::fmatReal >, plist::Primitive< PLISTREAL >, plist::Primitive< std::string >, plist::Primitive< float >, plist::Primitive< int >, plist::Primitive< unsigned int >, plist::Primitive< unsigned short >, plist::Primitive< string >, plist::Primitive< storage_t >, plist::Primitive< bool >, plist::NamedEnumeration< Config::vision_config::encoding_t >, plist::NamedEnumeration< J_DCT_METHOD >, plist::NamedEnumeration< Config::transports >, plist::NamedEnumeration< gain_levels >, plist::NamedEnumeration< volume_levels >, plist::NamedEnumeration< compression_t >, plist::NamedEnumeration< white_balance_levels >, plist::NamedEnumeration< consoleMode_t >, plist::NamedEnumeration< JointType_t >, and plist::NamedEnumeration< shutter_speeds >.

xmlNode * plist::ObjectBase::FindRootXMLElement ( xmlDoc doc  )  const [protected, virtual]

returns the root element of the xml document

Reimplemented from XMLLoadSave.

Definition at line 30 of file plistBase.cc.

Referenced by setParseTree().

static bool plist::ObjectBase::matchFalse ( const std::string &  str  )  [static, protected]

returns true if str is some form of negative (e.g. "false" or "no")

Definition at line 205 of file plistBase.h.

static bool plist::ObjectBase::matchTrue ( const std::string &  str  )  [static, protected]

returns true if str is some form of affirmative (e.g. "true" or "yes")

Definition at line 203 of file plistBase.h.

ObjectBase& plist::ObjectBase::operator= ( const ObjectBase  )  [protected]

polymorphic assignment operator, see assign()

This is protected for two reasons: one, so you don't accidentally use it via simple '=' statement, and two, to avoid 'operator= was hidden' warnings in every base class (because they keep reintroducing their default operator=(), hiding/shadowing this one (if it were virtual, as it would need to be to take on the role filled by assign().

Definition at line 181 of file plistBase.h.

void plist::ObjectBase::setParseTree ( xmlDoc doc  )  const [virtual]

assigns a parse tree which you have obtained from some other source

This doesn't update the contents of the subclass's values. The values in doc will be overwritten by those in the subclass on the next Save. If you wish to have the subclass's values updated from doc, call readParseTree() after calling this.

Reimplemented from XMLLoadSave.

Definition at line 17 of file plistBase.cc.

Referenced by GaitedFootsteps::setGait().

virtual bool plist::ObjectBase::toBool (  )  const [virtual]

return current value as a boolean (throws std::runtime_error exception if incompatable, e.g. dictionary or array to value type)

Does something a little smarter than assuming numeric conversion if called on a string...

Definition at line 156 of file plistBase.h.

virtual char plist::ObjectBase::toChar (  )  const [virtual]

return current value as a character (throws std::runtime_error exception if incompatable, e.g. dictionary or array to value type)

Does something a little smarter than assuming numeric conversion if called on a string...

Definition at line 159 of file plistBase.h.

xmlChar * plist::ObjectBase::xGetNodePath ( xmlNode node  )  [static, protected]

returns path from document root to node (forwards to xmlGetNodePath, returns new allocation, so call xmlFree)

Definition at line 71 of file plistBase.cc.

Referenced by KinematicJointLoader::loadXMLNode().

xmlNode * plist::ObjectBase::xNodeGetChildren ( xmlNode node  )  [static, protected]

returns children of node (not a libxml function)

Definition at line 77 of file plistBase.cc.

Referenced by plist::ArrayBase::loadXML(), KinematicJointLoader::loadXMLNode(), plist::ArrayBase::saveXML(), KinematicJoint::saveXML(), and KinematicJointSaver::saveXML().

xmlDoc * plist::ObjectBase::xNodeGetDoc ( xmlNode node  )  [static, protected]

returns document node of node (not a libxml function)

Definition at line 92 of file plistBase.cc.

xmlNode * plist::ObjectBase::xNodeGetLastChild ( xmlNode node  )  [static, protected]

returns last child of node (not a libxml function)

Definition at line 80 of file plistBase.cc.

Referenced by OutputConfig< T >::saveXML().

const xmlChar * plist::ObjectBase::xNodeGetName ( xmlNode node  )  [static, protected]

returns name of node (not a libxml function)

Definition at line 68 of file plistBase.cc.

Referenced by plist::RGBColor< T >::loadXML(), plist::ArrayBase::loadXML(), and plist::DictionaryBase::loadXML().

xmlNode * plist::ObjectBase::xNodeGetNextNode ( xmlNode node  )  [static, protected]

returns next node (sibling) after node (not a libxml function)

Definition at line 83 of file plistBase.cc.

Referenced by plist::ArrayBase::loadXML(), plist::ArrayBase::saveXML(), and plist::DictionaryBase::saveXML().

xmlNode * plist::ObjectBase::xNodeGetParent ( xmlNode node  )  [static, protected]

returns parent node of node (not a libxml function)

Definition at line 89 of file plistBase.cc.

Referenced by KinematicJoint::saveXML(), and KinematicJointSaver::saveXML().

xmlNode * plist::ObjectBase::xNodeGetPrevNode ( xmlNode node  )  [static, protected]

returns previous node (sibling) before node (not a libxml function)

Definition at line 86 of file plistBase.cc.

const xmlChar * plist::ObjectBase::xNodeGetURL ( xmlNode node  )  [static, protected]

returns URL/file of node (not a libxml function)

Definition at line 74 of file plistBase.cc.

Referenced by KinematicJointLoader::loadXMLNode().

bool plist::ObjectBase::xNodeIsComment ( xmlNode node  )  [static, protected]

returns true if node is an XML_COMMENT_NODE (not a libxml function)

Definition at line 101 of file plistBase.cc.

bool plist::ObjectBase::xNodeIsElement ( xmlNode node  )  [static, protected]

returns true if node is an XML_ELEMENT_NODE (not a libxml function)

Definition at line 98 of file plistBase.cc.

bool plist::ObjectBase::xNodeIsText ( xmlNode node  )  [static, protected]

returns true if node is an XML_TEXT_NODE (not a libxml function)

Definition at line 95 of file plistBase.cc.

Referenced by plist::DictionaryBase::saveOverXMLNode(), and OutputConfig< T >::saveXML().


Friends And Related Function Documentation

ObjectBase* loadXML ( xmlNode node  )  [friend]

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

Implements XMLLoadSave.

Reimplemented in KinematicJoint, RectangularObstacle, CircularObstacle, EllipticalObstacle, ConvexPolyObstacle, BoxObstacle, CylindricalObstacle, SphericalObstacle, EllipsoidObstacle, InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >, plist::DictionaryBase, plist::ArrayBase, plist::Primitive< T >, plist::NamedEnumeration< T >, plist::OutputSelector, plist::Angle, plist::Point, plist::RGBColor< T >, plist::Primitive< fmat::fmatReal >, plist::Primitive< PLISTREAL >, plist::Primitive< std::string >, plist::Primitive< float >, plist::Primitive< int >, plist::Primitive< unsigned int >, plist::Primitive< unsigned short >, plist::Primitive< string >, plist::Primitive< storage_t >, plist::Primitive< bool >, plist::NamedEnumeration< Config::vision_config::encoding_t >, plist::NamedEnumeration< J_DCT_METHOD >, plist::NamedEnumeration< Config::transports >, plist::NamedEnumeration< gain_levels >, plist::NamedEnumeration< volume_levels >, plist::NamedEnumeration< compression_t >, plist::NamedEnumeration< white_balance_levels >, plist::NamedEnumeration< consoleMode_t >, plist::NamedEnumeration< JointType_t >, and plist::NamedEnumeration< shutter_speeds >.

Definition at line 27 of file plistCollections.h.


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

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