All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
sdf::Root Class Reference

Root class that acts as an entry point to the SDF document model. More...

#include <Root.hh>

Public Member Functions

 Root ()
 Default constructor. More...
 
 ~Root ()
 Destructor. More...
 
Errors Load (const std::string &_filename)
 Parse the given SDF file, and generate objects based on types specified in the SDF file. More...
 
void SetVersion (const std::string &_version)
 Set the SDF version string. More...
 
std::string Version () const
 Get the SDF version specified in the parsed file or SDF pointer. More...
 
const WorldWorldByIndex (const uint64_t _index) const
 Get a world based on an index. More...
 
uint64_t WorldCount () const
 Get the number of worlds. More...
 
bool WorldNameExists (const std::string &_name) const
 Get whether a world name exists. More...
 

Detailed Description

Root class that acts as an entry point to the SDF document model.

Usage

In this example, a root object is loaded from a file specified in the first command line argument to a program.

sdf::Root root;
if (root.Load(argv[1]))
{
root.Print();
std::cerr << "Valid SDF file. Parsed values shown above.\n";
return 0;
}

Constructor & Destructor Documentation

sdf::Root::Root ( )

Default constructor.

sdf::Root::~Root ( )

Destructor.

Member Function Documentation

Errors sdf::Root::Load ( const std::string &  _filename)

Parse the given SDF file, and generate objects based on types specified in the SDF file.

Parameters
[in]_filenameName of the SDF file to parse.
Returns
Errors, which is a vector of Error objects. Each Error includes an error code and message. An empty vector indicates no error.
void sdf::Root::SetVersion ( const std::string &  _version)

Set the SDF version string.

Parameters
[in]_versionThe new SDF version.
See Also
std::string Version()
std::string sdf::Root::Version ( ) const

Get the SDF version specified in the parsed file or SDF pointer.

Returns
SDF version string.
See Also
void SetVersion(const std::string &_version)
const World* sdf::Root::WorldByIndex ( const uint64_t  _index) const

Get a world based on an index.

Parameters
[in]_indexIndex of the world. The index should be in the range [0..WorldCount()).
Returns
Pointer to the world. Nullptr if the index does not exist.
See Also
uint64_t WorldCount() const
uint64_t sdf::Root::WorldCount ( ) const

Get the number of worlds.

Returns
Number of worlds contained in this Root object.
bool sdf::Root::WorldNameExists ( const std::string &  _name) const

Get whether a world name exists.

Parameters
[in]_nameName of the world to check.
Returns
True if there exists a world with the given name.

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