Loading...
Searching...
No Matches
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.
 ~Root ()
 Destructor.
Errors Load (const std::string &_filename)
 Parse the given SDF file, and generate objects based on types specified in the SDF file.
void SetVersion (const std::string &_version)
 Set the SDF version string.
std::string Version () const
 Get the SDF version specified in the parsed file or SDF pointer.
const WorldWorldByIndex (const uint64_t _index) const
 Get a world based on an index.
uint64_t WorldCount () const
 Get the number of worlds.
bool WorldNameExists (const std::string &_name) const
 Get whether a world name exists.

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;
sdf::Errors errors = root.Load(argv[1]);
if (errors.empty())
{
std::cerr << "Valid SDF file.\n";
return 0;
}
else
{
std::cerr << "Errors encountered: \n";
for (auto const &e : errors)
{
std::cout << e << std::endl;
}
}

Constructor & Destructor Documentation

◆ Root()

sdf::Root::Root ( )

Default constructor.

◆ ~Root()

sdf::Root::~Root ( )

Destructor.

Member Function Documentation

◆ Load()

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.

◆ SetVersion()

void sdf::Root::SetVersion ( const std::string & _version)

Set the SDF version string.

Parameters
[in]_versionThe new SDF version.
See also
std::string Version()

◆ 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)

◆ WorldByIndex()

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

◆ WorldCount()

uint64_t sdf::Root::WorldCount ( ) const

Get the number of worlds.

Returns
Number of worlds contained in this Root object.

◆ WorldNameExists()

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: