Class that catch XML Parser events for a specific tag and build the corresponding Object. More...
#include <hpp/manipulation/parser/parser.hh>
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) |
Set the name. More... | |
void | name (const char *n) |
See name(const std::string&) More... | |
template<typename T > | |
T * | as () |
Cast this class to any child class. More... | |
Events | |
virtual bool | init () |
Called when the object is created. More... | |
void | setAttribute (const XMLAttribute *attr) |
Called for each attribute. More... | |
virtual void | addTextChild (const XMLText *text) |
Add Text child. More... | |
virtual bool | finishAttributes () |
Called when all the attributes have been processed. More... | |
virtual void | finishTags () |
Called when all the child tags have been processed. More... | |
virtual void | finishFile () |
Called when parsing is finished. More... | |
Accessors | |
std::string | tagName () const |
Return tag name of the element is any. More... | |
std::string | name () const |
Return the content of the attribute name, or an empty string. More... | |
bool | hasAttribute (const std::string &attr) const |
Check if an attribute was set. More... | |
std::string | getAttribute (const std::string &attr) const |
Return a given attributes. More... | |
ObjectFactoryList | getChildrenOfType (std::string type) |
Get a list of ObjectFactory whose tag name is type. More... | |
bool | getChildOfType (std::string type, ObjectFactory *&o) |
Get the ObjectFactory whose tag name is type. More... | |
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 |
Friends | |
std::ostream & | operator<< (std::ostream &, const ObjectFactory &) |
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:
typedef std::vector<ObjectFactory*> hpp::manipulation::parser::ObjectFactory::ObjectFactoryList |
hpp::manipulation::parser::ObjectFactory::ObjectFactory | ( | ObjectFactory * | parent = NULL , |
const XMLElement * | element = NULL |
||
) |
Referenced by as().
|
inlinevirtual |
|
protected |
|
protected |
Referenced by as().
|
virtual |
Add Text child.
Reimplemented in hpp::manipulation::parser::SequenceFactory< ValueType >, and hpp::manipulation::parser::SequenceFactory< float >.
Referenced by ~ObjectFactory().
|
inline |
Cast this class to any child class.
References addChild(), hasParent(), impl_setAttribute(), ObjectFactory(), operator<<, parent(), print(), root(), tagName(), and XMLelement().
|
virtual |
Called when all the attributes have been processed.
Reimplemented in hpp::manipulation::srdf::RobotFactory.
Referenced by ~ObjectFactory().
|
virtual |
Called when parsing is finished.
Referenced by ~ObjectFactory().
|
virtual |
Called when all the child tags have been processed.
Reimplemented in hpp::manipulation::srdf::HandleFactory, hpp::manipulation::srdf::ContactFactory, hpp::manipulation::srdf::PositionFactory, and hpp::manipulation::srdf::GripperFactory.
Referenced by ~ObjectFactory().
std::string hpp::manipulation::parser::ObjectFactory::getAttribute | ( | const std::string & | attr | ) | const |
Return a given attributes.
Referenced by ~ObjectFactory().
bool hpp::manipulation::parser::ObjectFactory::getChildOfType | ( | std::string | type, |
ObjectFactory *& | o | ||
) |
Get the ObjectFactory whose tag name is type.
[out] | o | Set to the first element of the requested type. |
std::invalid_argument | if no ObjectFactory of the requested type exists. |
Referenced by ~ObjectFactory().
ObjectFactoryList hpp::manipulation::parser::ObjectFactory::getChildrenOfType | ( | std::string | type | ) |
Get a list of ObjectFactory whose tag name is type.
Referenced by ~ObjectFactory().
bool hpp::manipulation::parser::ObjectFactory::hasAttribute | ( | const std::string & | attr | ) | const |
Check if an attribute was set.
Referenced by ~ObjectFactory().
|
protected |
Referenced by as().
|
protectedvirtual |
Referenced by as().
|
virtual |
Called when the object is created.
Reimplemented in hpp::manipulation::parser::IgnoreTagFactory.
Referenced by ~ObjectFactory().
std::string hpp::manipulation::parser::ObjectFactory::name | ( | ) | const |
Return the content of the attribute name, or an empty string.
Referenced by ~ObjectFactory().
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.
void hpp::manipulation::parser::ObjectFactory::name | ( | const char * | n | ) |
|
protected |
Referenced by as(), hpp::manipulation::parser::create(), and hpp::manipulation::parser::Parser::prefix().
|
protectedvirtual |
Referenced by as(), and hpp::manipulation::parser::Parser::prefix().
|
protected |
Referenced by as().
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.
Referenced by ~ObjectFactory().
std::string hpp::manipulation::parser::ObjectFactory::tagName | ( | ) | const |
Return tag name of the element is any.
Returns "No element" otherwise.
Referenced by as(), and ~ObjectFactory().
|
protected |
Referenced by as().
|
friend |
Referenced by as(), and hpp::manipulation::parser::Parser::prefix().