hpp-manipulation-urdf: hpp::manipulation::parser::ObjectFactory Class Reference

hpp-manipulation-urdf 9.0.2 Implementation of a parser for hpp-manipulation.

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
hpp::manipulation::parser::ObjectFactory Class Reference
Factories

Class that catch XML Parser events for a specific tag and build the corresponding Object. More...

`#include <hpp/manipulation/parser/parser.hh>`

Inheritance diagram for hpp::manipulation::parser::ObjectFactory:
[legend]

## Public Types
typedef std::vector< ObjectFactory * > | ObjectFactoryList

## Public Member Functions
| ObjectFactory (ObjectFactory *parent=NULL, const XMLElement *element=NULL)
virtual | ~ObjectFactory ()
void | name (const std::string &n)
void | name (const char *n)
| See name(const std::string&)
template<typename T >
T * | as ()
| Cast this class to any child class.
Events
virtual bool | init ()
void | setAttribute (const XMLAttribute *attr)
virtual void | addTextChild (const XMLText *text)
| Add Text child.
virtual bool | finishAttributes ()
virtual void | finishTags ()
| Called when all the child tags have been processed.
virtual void | finishFile ()
| Called when parsing is finished.
Accessors
std::string | tagName () const
std::string | name () const
bool | hasAttribute (const std::string &attr) const
| Check if an attribute was set.
std::string | getAttribute (const std::string &attr) const
| Return a given attributes.
ObjectFactoryList | getChildrenOfType (std::string type)
| Get a list of ObjectFactory whose tag name is type.
bool | getChildOfType (std::string type, ObjectFactory *&o)

## Protected Member Functions
| ObjectFactory (RootFactory *root)
ObjectFactory * | parent ()
RootFactory * | root ()
bool | hasParent () const
const XMLElement * | XMLelement ()
virtual void | impl_setAttribute (const XMLAttribute *attr)
void | addChild (ObjectFactory *child)
virtual std::ostream & | print (std::ostream &os) const

## Detailed Description

Class that catch XML Parser events for a specific tag and build the corresponding Object.

Derive this class if you wish to extend the Parser. The event callbacks are called in the following order:

- ObjectFactory::init after having created the object.
- ObjectFactory::setAttribute for each attribute of the tag.
- ObjectFactory::finishAttributes after having processed every attribute.
- ObjectFactory::addTextChild when a child is a text element.
- ObjectFactory::finishTags when all the children have been parsed.
- ObjectFactory::finishFile when the file has been fully parsed.

Note
  The derived class must have the following construtor
  DerivedFactory (ObjectFactory* parent, const XMLElement* element) :
  ObjectFactory (parent, element)
  {
  /*
  * Keep in mind that it might be more convenient
  * to build objects in an event callback, when some information
  * has already been parsed.
  */
  }
  hpp::manipulation::parser::ObjectFactory
  Class that catch XML Parser events for a specific tag and build the corresponding Object.
  Definition parser.hh:85
  hpp::manipulation::parser::ObjectFactory::parent
  ObjectFactory * parent()
  hpp::manipulation::parser::XMLElement
  tinyxml2::XMLElement XMLElement
  Definition parser.hh:43

## Member Typedef Documentation

## ◆ ObjectFactoryList

typedef std::vector<ObjectFactory*> hpp::manipulation::parser::ObjectFactory::ObjectFactoryList

## Constructor & Destructor Documentation

## ◆ ObjectFactory() [1/2]

hpp::manipulation::parser::ObjectFactory::ObjectFactory | ( | ObjectFactory * | parent = NULL,
|  | const XMLElement * | element = NULL )

## ◆ ~ObjectFactory()

virtual hpp::manipulation::parser::ObjectFactory::~ObjectFactory | ( |  | ) |
| inline virtual

## ◆ ObjectFactory() [2/2]

hpp::manipulation::parser::ObjectFactory::ObjectFactory | ( | RootFactory * | root | ) |
| protected

## Member Function Documentation

## ◆ addChild()

void hpp::manipulation::parser::ObjectFactory::addChild | ( | ObjectFactory * | child | ) |
| protected

## ◆ addTextChild()

virtual void hpp::manipulation::parser::ObjectFactory::addTextChild | ( | const XMLText * | text | ) |
| virtual

Add Text child.

Reimplemented in hpp::manipulation::parser::SequenceFactory< ValueType >, and hpp::manipulation::parser::SequenceFactory< float >.

## ◆ as()

template<typename T >

T * hpp::manipulation::parser::ObjectFactory::as | ( |  | ) |
| inline

Cast this class to any child class.

## ◆ finishAttributes()

virtual bool hpp::manipulation::parser::ObjectFactory::finishAttributes | ( |  | ) |
| virtual

Called when all the attributes have been processed.

Returns
  True to continue parsing this tag, False otherwise.

Reimplemented in hpp::manipulation::srdf::RobotFactory.

## ◆ finishFile()

virtual void hpp::manipulation::parser::ObjectFactory::finishFile | ( |  | ) |
| virtual

Called when parsing is finished.

## ◆ finishTags()

virtual void hpp::manipulation::parser::ObjectFactory::finishTags | ( |  | ) |
| virtual

Called when all the child tags have been processed.

Reimplemented in hpp::manipulation::srdf::ContactFactory, hpp::manipulation::srdf::GripperFactory, hpp::manipulation::srdf::HandleFactory, and hpp::manipulation::srdf::PositionFactory.

## ◆ getAttribute()

std::string hpp::manipulation::parser::ObjectFactory::getAttribute | ( | const std::string & | attr | ) | const

Return a given attributes.

## ◆ getChildOfType()

bool hpp::manipulation::parser::ObjectFactory::getChildOfType | ( | std::string | type,
|  | ObjectFactory *& | o )

Get the ObjectFactory whose tag name is type.

Parameters

  [out] | o | Set to the first element of the requested type.

Returns
  true if there was only element of the requested type. false if there are more than one.

Exceptions

  std::invalid_argument | if no ObjectFactory of the requested type exists.

## ◆ getChildrenOfType()

ObjectFactoryList hpp::manipulation::parser::ObjectFactory::getChildrenOfType | ( | std::string | type | ) |

Get a list of ObjectFactory whose tag name is type.

## ◆ hasAttribute()

bool hpp::manipulation::parser::ObjectFactory::hasAttribute | ( | const std::string & | attr | ) | const

Check if an attribute was set.

## ◆ hasParent()

bool hpp::manipulation::parser::ObjectFactory::hasParent | ( |  | ) | const
| protected

## ◆ impl_setAttribute()

virtual void hpp::manipulation::parser::ObjectFactory::impl_setAttribute | ( | const XMLAttribute * | attr | ) |
| protected virtual

## ◆ init()

virtual bool hpp::manipulation::parser::ObjectFactory::init | ( |  | ) |
| virtual

Called when the object is created.

Returns
  True to continue parsing this tag, False otherwise.

Reimplemented in hpp::manipulation::parser::IgnoreTagFactory.

## ◆ name() [1/3]

std::string hpp::manipulation::parser::ObjectFactory::name | ( |  | ) | const

Return the content of the attribute name, or an empty string.

## ◆ name() [2/3]

void hpp::manipulation::parser::ObjectFactory::name | ( | const char * | n | ) |

See name(const std::string&)

## ◆ name() [3/3]

void hpp::manipulation::parser::ObjectFactory::name | ( | const std::string & | n | ) |

Set the name. The default value is the value of the attribute "name" of the XML tag or an empty string if this does not exist.

## ◆ parent()

ObjectFactory * hpp::manipulation::parser::ObjectFactory::parent | ( |  | ) |
| protected

## ◆ print()

virtual std::ostream & hpp::manipulation::parser::ObjectFactory::print | ( | std::ostream & | os | ) | const
| protected virtual

## ◆ root()

RootFactory * hpp::manipulation::parser::ObjectFactory::root | ( |  | ) |
| protected

## ◆ setAttribute()

void hpp::manipulation::parser::ObjectFactory::setAttribute | ( | const XMLAttribute * | attr | ) |

Called for each attribute. A few reserved name are automatocally catched. The reserved names are "name" and "id". "name" expects a string. "id" expects an unsigned integer and can be use to define pointers to elements.

## ◆ tagName()

std::string hpp::manipulation::parser::ObjectFactory::tagName | ( |  | ) | const

Return tag name of the element is any. Returns "No element" otherwise.

## ◆ XMLelement()

const XMLElement * hpp::manipulation::parser::ObjectFactory::XMLelement | ( |  | ) |
| protected

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

- include/hpp/manipulation/parser/parser.hh