22 #include <boost/shared_ptr.hpp>
23 #include <boost/enable_shared_from_this.hpp>
37 typedef boost::shared_ptr<SDF>
SDFPtr;
56 std::string
findFile(
const std::string &_filename,
57 bool _searchLocalPath =
true,
58 bool _useCallback =
false);
64 void addURIPath(
const std::string &_uri,
const std::string &_path);
70 void setFindCallback(boost::function<std::string (
const std::string &)> _cb);
74 class Element :
public boost::enable_shared_from_this<Element>
84 public: boost::shared_ptr<Element>
Clone()
const;
101 public:
void SetName(
const std::string &_name);
105 public:
const std::string &
GetName()
const;
138 public:
void PrintWiki(std::string _prefix);
147 int _spacing,
int &_index);
155 int _spacing,
int &_index);
160 public: std::string
ToString(
const std::string &_prefix)
const;
169 const std::string &_type,
170 const std::string &_defaultvalue,
172 const std::string &_description=
"");
179 public:
void AddValue(
const std::string &_type,
180 const std::string &_defaultValue,
bool _required,
181 const std::string &_description=
"");
241 public:
template<
typename T>
242 T
Get(
const std::string &_key =
"")
246 if (_key.empty() && this->value)
247 this->value->
Get<T>(result);
248 else if (!_key.empty())
258 sdferr <<
"Unable to find value for key[" << _key <<
"]\n";
263 public:
template<
typename T>
268 this->value->
Set(_value);
274 public:
bool HasElement(
const std::string &_name)
const;
296 public:
void Reset();
298 public:
void SetInclude(
const std::string &_filename);
310 private:
void ToString(
const std::string &_prefix,
311 std::ostringstream &_out)
const;
314 private: boost::shared_ptr<Param> CreateParam(
const std::string &_key,
315 const std::string &_type,
const std::string &_defaultValue,
316 bool _required,
const std::string &_description=
"");
320 private: std::string name;
321 private: std::string required;
322 private: std::string description;
323 private:
bool copyChildren;
340 private: std::string includeFilename;
352 public:
void Write(
const std::string &_filename);
353 public: std::string
ToString()
const;
void InsertElement(ElementPtr _elem)
void SetDescription(const std::string &_desc)
Set a text description for the element.
Generic double x, y vector.
Definition: Types.hh:155
bool GetCopyChildren() const
Return true if this Element's child elements should be copied during parsing.
float GetValueFloat(const std::string &_key="") SDF_DEPRECATED(1.4)
Element * Clone() const
Create a copy of this Element.
Base SDF class.
Definition: SDFImpl.hh:345
ElementPtr GetElement(const std::string &_name) const
virtual ~Element()
Destructor.
Element * ElementPtr
Definition: SDFImpl.hh:41
std::string GetValueString(const std::string &_key="") SDF_DEPRECATED(1.4)
void SetFromString(const std::string &_sdfData)
Set SDF values from a string.
void SetCopyChildren(bool _value)
Set whether this element should copy its child elements during parsing.
bool GetAttributeSet(const std::string &_key)
Return true if the attribute was set (i.e. not default value)
void addURIPath(const std::string &_uri, const std::string &_path)
Associate paths to a URI.
bool Get(T &_value)
Get the value of the parameter.
Definition: Param.hh:146
A parameter class.
Definition: Param.hh:52
double GetValueDouble(const std::string &_key="") SDF_DEPRECATED(1.4)
static std::string version
Definition: SDFImpl.hh:360
std::string ToString() const
bool Set(const T &_value)
Set the parameter's value.
Definition: Param.hh:124
SDF * SDFPtr
Definition: SDFImpl.hh:37
bool Set(const T &_value)
Definition: SDFImpl.hh:264
ElementPtr GetNextElement(const std::string &_name="") const
bool GetValueBool(const std::string &_key="") SDF_DEPRECATED(1.4)
ParamPtr GetValue()
Get the param of the elements value.
ElementPtr GetElementImpl(const std::string &_name) const
void AddValue(const std::string &_type, const std::string &_defaultValue, bool _required, const std::string &_description="")
Add a value to this Element.
bool HasElementDescription(const std::string &_name)
Return true if an element description exists.
sdf::Quaternion GetValueQuaternion(const std::string &_key="") SDF_DEPRECATED(1.4)
std::string GetInclude() const
void ClearElements()
Remove all child elements.
A quaternion class.
Definition: Types.hh:308
ElementPtr GetParent() const
Get a pointer to this Element's parent.
int GetValueInt(const std::string &_key="") SDF_DEPRECATED(1.4)
void Write(const std::string &_filename)
sdf::Time GetValueTime(const std::string &_key="") SDF_DEPRECATED(1.4)
std::string findFile(const std::string &_filename, bool _searchLocalPath=true, bool _useCallback=false)
Find the absolute path of a file.
sdf::Vector3 GetValueVector3(const std::string &_key="") SDF_DEPRECATED(1.4)
unsigned int GetAttributeCount() const
Get the number of attributes.
void setFindCallback(boost::function< std::string(const std::string &)> _cb)
Set the callback to use when SDF can't find a file.
void PrintWiki(std::string _prefix)
char GetValueChar(const std::string &_key="") SDF_DEPRECATED(1.4)
void RemoveFromParent()
Remove this element from its parent.
void SetParent(const ElementPtr _parent)
Set the parent of this Element.
ElementPtr GetElementDescription(unsigned int _index) const
Get an element description using an index.
SDF Element class.
Definition: SDFImpl.hh:74
void PrintDescription(const std::string &_prefix)
Output Element's description to stdout.
void PrintDocRightPane(std::string &_html, int _spacing, int &_index)
Helper function for SDF::PrintDoc.
ElementPtr GetFirstElement() const
sdf::Color GetValueColor(const std::string &_key="") SDF_DEPRECATED(1.4)
void SetRequired(const std::string &_req)
Set the requirement type.
void SetName(const std::string &_name)
Set the name of the Element.
ElementPtr root
Definition: SDFImpl.hh:358
std::string ToString(const std::string &_prefix) const
Convert the element values to a string representation.
#define sdferr
Output an error message.
Definition: Console.hh:45
std::vector< ElementPtr > ElementPtr_V
Definition: SDFImpl.hh:45
void AddElementDescription(ElementPtr _elem)
Add a new element description.
unsigned int GetElementDescriptionCount() const
Get the number of element descriptions.
std::vector< ParamPtr > Param_V
Definition: Param.hh:48
void RemoveChild(ElementPtr _child)
Remove a child element.
sdf::Pose GetValuePose(const std::string &_key="") SDF_DEPRECATED(1.4)
void SetInclude(const std::string &_filename)
Defines a color.
Definition: Types.hh:49
bool HasElement(const std::string &_name) const
void AddAttribute(const std::string &_key, const std::string &_type, const std::string &_defaultvalue, bool _required, const std::string &_description="")
Add an attribute value.
T Get(const std::string &_key="")
Definition: SDFImpl.hh:242
A Time class, can be used to hold wall- or sim-time.
Definition: Types.hh:679
bool HasAttribute(const std::string &_key)
void Copy(const ElementPtr _elem)
Copy values from an Element.
const std::string & GetName() const
Get the Element's name.
sdf::Vector2d GetValueVector2d(const std::string &_key="") SDF_DEPRECATED(1.4)
ElementPtr AddElement(const std::string &_name)
Encapsulates a position and rotation in three space.
Definition: Types.hh:580
ParamPtr GetAttribute(const std::string &_key)
Get the param of an attribute.
void PrintDocLeftPane(std::string &_html, int _spacing, int &_index)
Helper function for SDF::PrintDoc.
#define SDF_DEPRECATED(version)
Definition: Types.hh:31
The Vector3 class represents the generic vector containing 3 elements.
Definition: Types.hh:207
const std::string & GetRequired() const
Get the requirement string.
void PrintValues(std::string _prefix)
Output Element's values to stdout.
std::string GetDescription() const
Get a text description of the element.
unsigned int GetValueUInt(const std::string &_key="") SDF_DEPRECATED(1.4)