22 #include <boost/shared_ptr.hpp>
23 #include <boost/enable_shared_from_this.hpp>
38 typedef boost::shared_ptr<SDF>
SDFPtr;
58 std::string
findFile(
const std::string &_filename,
59 bool _searchLocalPath =
true,
60 bool _useCallback =
false);
67 void addURIPath(
const std::string &_uri,
const std::string &_path);
74 void setFindCallback(boost::function<std::string (
const std::string &)> _cb);
79 public boost::enable_shared_from_this<Element>
89 public: boost::shared_ptr<Element> Clone()
const;
93 public:
void Copy(
const ElementPtr _elem);
98 public: ElementPtr GetParent()
const;
102 public:
void SetParent(
const ElementPtr _parent);
106 public:
void SetName(
const std::string &_name);
110 public:
const std::string &GetName()
const;
118 public:
void SetRequired(
const std::string &_req);
123 public:
const std::string &GetRequired()
const;
128 public:
void SetCopyChildren(
bool _value);
133 public:
bool GetCopyChildren()
const;
137 public:
void PrintDescription(
const std::string &_prefix);
141 public:
void PrintValues(std::string _prefix);
143 public:
void PrintWiki(std::string _prefix);
151 public:
void PrintDocLeftPane(std::string &_html,
152 int _spacing,
int &_index);
159 public:
void PrintDocRightPane(std::string &_html,
160 int _spacing,
int &_index);
165 public: std::string ToString(
const std::string &_prefix)
const;
173 public:
void AddAttribute(
const std::string &_key,
174 const std::string &_type,
175 const std::string &_defaultvalue,
177 const std::string &_description=
"");
184 public:
void AddValue(
const std::string &_type,
185 const std::string &_defaultValue,
bool _required,
186 const std::string &_description=
"");
191 public:
ParamPtr GetAttribute(
const std::string &_key);
194 public:
unsigned int GetAttributeCount()
const;
197 public:
ParamPtr GetAttribute(
unsigned int _index)
const;
200 public:
unsigned int GetElementDescriptionCount()
const;
203 public: ElementPtr GetElementDescription(
unsigned int _index)
const;
206 public: ElementPtr GetElementDescription(
const std::string &_key)
const;
209 public:
bool HasElementDescription(
const std::string &_name);
211 public:
bool HasAttribute(
const std::string &_key);
214 public:
bool GetAttributeSet(
const std::string &_key);
219 public:
bool GetValueBool(
221 public:
int GetValueInt(
223 public:
float GetValueFloat(
225 public:
double GetValueDouble(
227 public:
unsigned int GetValueUInt(
229 public:
char GetValueChar(
231 public: std::string GetValueString(
246 public:
template<
typename T>
247 T
Get(
const std::string &_key =
"")
251 if (_key.empty() && this->value)
252 this->value->Get<T>(result);
253 else if (!_key.empty())
255 ParamPtr param = this->GetAttribute(_key);
258 else if (this->HasElement(_key))
259 result = this->GetElementImpl(_key)->Get<T>();
260 else if (this->HasElementDescription(_key))
261 result = this->GetElementDescription(_key)->
Get<T>();
263 sdferr <<
"Unable to find value for key[" << _key <<
"]\n";
268 public:
template<
typename T>
273 this->value->Set(_value);
279 public:
bool HasElement(
const std::string &_name)
const;
281 public: ElementPtr GetElement(
const std::string &_name)
const;
282 public: ElementPtr GetFirstElement()
const;
284 public: ElementPtr GetNextElement(
const std::string &_name =
"")
const;
286 public: ElementPtr GetElement(
const std::string &_name);
287 public: ElementPtr AddElement(
const std::string &_name);
288 public:
void InsertElement(ElementPtr _elem);
291 public:
void RemoveFromParent();
295 public:
void RemoveChild(ElementPtr _child);
298 public:
void ClearElements();
300 public:
void Update();
301 public:
void Reset();
303 public:
void SetInclude(
const std::string &_filename);
304 public: std::string GetInclude()
const;
307 public: std::string GetDescription()
const;
310 public:
void SetDescription(
const std::string &_desc);
313 public:
void AddElementDescription(ElementPtr _elem);
315 private:
void ToString(
const std::string &_prefix,
316 std::ostringstream &_out)
const;
319 private: boost::shared_ptr<Param> CreateParam(
const std::string &_key,
320 const std::string &_type,
const std::string &_defaultValue,
321 bool _required,
const std::string &_description=
"");
323 public: ElementPtr GetElementImpl(
const std::string &_name)
const;
325 private: std::string name;
326 private: std::string required;
327 private: std::string description;
330 private: ElementPtr parent;
339 private: ElementPtr_V elements;
342 private: ElementPtr_V elementDescriptions;
345 private: std::string includeFilename;
353 public:
void PrintDescription();
354 public:
void PrintValues();
355 public:
void PrintWiki();
356 public:
void PrintDoc();
357 public:
void Write(
const std::string &_filename);
358 public: std::string ToString()
const;
361 public:
void SetFromString(
const std::string &_sdfData);
Generic double x, y vector.
Definition: Types.hh:157
Base SDF class.
Definition: SDFImpl.hh:350
Element * ElementPtr
Definition: SDFImpl.hh:42
bool Get(T &_value)
Get the value of the parameter.
Definition: Param.hh:147
A parameter class.
Definition: Param.hh:53
static std::string version
Definition: SDFImpl.hh:365
SDF * SDFPtr
Definition: SDFImpl.hh:38
bool Set(const T &_value)
Definition: SDFImpl.hh:269
class SDFORMAT_VISIBLE Element
Definition: SDFImpl.hh:34
A quaternion class.
Definition: Types.hh:310
SDFORMAT_VISIBLE void setFindCallback(boost::function< std::string(const std::string &)> _cb)
Set the callback to use when SDF can't find a file.
class SDFORMAT_VISIBLE SDF
Definition: SDFImpl.hh:33
SDF Element class.
Definition: SDFImpl.hh:78
SDFORMAT_VISIBLE std::string findFile(const std::string &_filename, bool _searchLocalPath=true, bool _useCallback=false)
Find the absolute path of a file.
ElementPtr root
Definition: SDFImpl.hh:363
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
#define sdferr
Output an error message.
Definition: Console.hh:47
std::vector< ElementPtr > ElementPtr_V
Definition: SDFImpl.hh:46
std::vector< ParamPtr > Param_V
Definition: Param.hh:49
Defines a color.
Definition: Types.hh:51
namespace for Simulation Description Format parser
Definition: Console.hh:29
T Get(const std::string &_key="")
Definition: SDFImpl.hh:247
A Time class, can be used to hold wall- or sim-time.
Definition: Types.hh:681
SDFORMAT_VISIBLE void copyChildren(ElementPtr _sdf, TiXmlElement *_xml)
SDFORMAT_VISIBLE void addURIPath(const std::string &_uri, const std::string &_path)
Associate paths to a URI.
Encapsulates a position and rotation in three space.
Definition: Types.hh:582
#define SDF_DEPRECATED(version)
Definition: Types.hh:33
The Vector3 class represents the generic vector containing 3 elements.
Definition: Types.hh:209