Root.hh
Go to the documentation of this file.
1/*
2 * Copyright 2017 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17#ifndef SDF_ROOT_HH_
18#define SDF_ROOT_HH_
19
20#include <string>
21#include <vector>
22#include <gz/utils/ImplPtr.hh>
23
24#include "sdf/OutputConfig.hh"
25#include "sdf/ParserConfig.hh"
26#include "sdf/SDFImpl.hh"
27#include "sdf/Types.hh"
28#include "sdf/sdf_config.h"
29#include "sdf/system_util.hh"
30
31namespace sdf
32{
33 // Inline bracket to help doxygen filtering.
34 inline namespace SDF_VERSION_NAMESPACE {
35 //
36
37 // Forward declarations.
38 class Actor;
39 class Light;
40 class Model;
41 class World;
42
58 {
60 public: Root();
61
70 public: Errors WorldNamesFromFile(const std::string &_filename,
71 std::vector<std::string> &_worldNames);
72
78 public: Errors Load(const std::string &_filename);
79
86 public: Errors Load(
87 const std::string &_filename, const ParserConfig &_config);
88
94 public: Errors LoadSdfString(const std::string &_sdf);
95
103 const std::string &_sdf, const ParserConfig &_config);
104
110 public: Errors Load(const SDFPtr _sdf);
111
118 public: Errors Load(const SDFPtr _sdf, const ParserConfig &_config);
119
124 public: std::string Version() const;
125
129 public: void SetVersion(const std::string &_version);
130
133 public: uint64_t WorldCount() const;
134
140 public: const World *WorldByIndex(const uint64_t _index) const;
141
147 public: World *WorldByIndex(const uint64_t _index);
148
154 public: const World *WorldByName(const std::string &_name) const;
155
161 public: World *WorldByName(const std::string &_name);
162
166 public: bool WorldNameExists(const std::string &_name) const;
167
171 public: const sdf::Model *Model() const;
172
176 public: void SetModel(const sdf::Model &_model);
177
181 public: const sdf::Light *Light() const;
182
186 public: void SetLight(const sdf::Light &_light);
187
191 public: const sdf::Actor *Actor() const;
192
196 public: void SetActor(const sdf::Actor &_actor);
197
202 public: sdf::ElementPtr Element() const;
203
210 public: Errors AddWorld(const World &_world);
211
213 public: void ClearWorlds();
214
219 public: sdf::Root Clone() const;
220
228
237 public: void ResolveAutoInertials(sdf::Errors &_errors,
238 const ParserConfig &_config);
239
247 const OutputConfig &_config = OutputConfig::GlobalConfig()) const;
248
250 GZ_UTILS_IMPL_PTR(dataPtr)
251 };
252 }
253}
254#endif
Provides a description of an actor.
Definition: Actor.hh:192
Provides a description of a light source.
Definition: Light.hh:64
Definition: Model.hh:55
This class contains configuration options for SDF output.
Definition: OutputConfig.hh:59
static OutputConfig & GlobalConfig()
Mutable access to a singleton OutputConfig that serves as the global OutputConfig object for all pars...
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:100
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:58
Root()
Default constructor.
Errors LoadSdfString(const std::string &_sdf, const ParserConfig &_config)
Parse the given SDF string, and generate objects based on types specified in the SDF file.
uint64_t WorldCount() const
Get the number of worlds.
const sdf::Light * Light() const
Get a pointer to the light object if it exists.
void SetActor(const sdf::Actor &_actor)
Set the actor object.
const World * WorldByName(const std::string &_name) const
Get a world based on a name.
Errors Load(const SDFPtr _sdf)
Parse the given SDF pointer, and generate objects based on types specified in the SDF file.
void SetModel(const sdf::Model &_model)
Set the model object.
sdf::Root Clone() const
Deep copy this Root object and return the new Root object.
sdf::ElementPtr ToElement(const OutputConfig &_config=OutputConfig::GlobalConfig()) const
Create and return an SDF element filled with data from this root.
const sdf::Model * Model() const
Get a pointer to the model object if it exists.
Errors Load(const SDFPtr _sdf, const ParserConfig &_config)
Parse the given SDF pointer, and generate objects based on types specified in the SDF file.
Errors UpdateGraphs()
Recreate the frame and pose graphs for the worlds and model that are children of this Root object.
World * WorldByName(const std::string &_name)
Get a world based on a name.
void SetLight(const sdf::Light &_light)
Set the light object.
std::string Version() const
Get the SDF version specified in the parsed file or SDF pointer.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was generated during load.
World * WorldByIndex(const uint64_t _index)
Get a mutable world based on an index.
bool WorldNameExists(const std::string &_name) const
Get whether a world name exists.
void SetVersion(const std::string &_version)
Set the SDF version string.
const sdf::Actor * Actor() const
Get a pointer to the actor object if it exists.
Errors LoadSdfString(const std::string &_sdf)
Parse the given SDF string, and generate objects based on types specified in the SDF file.
void ResolveAutoInertials(sdf::Errors &_errors, const ParserConfig &_config)
Calculate & set the inertial properties (mass, mass matrix and inertial pose) for all the worlds & mo...
Errors AddWorld(const World &_world)
Add a world to the root.
Errors WorldNamesFromFile(const std::string &_filename, std::vector< std::string > &_worldNames)
Get the name of the world without loading the entire world Users shouldn't normally need to use this ...
Errors Load(const std::string &_filename)
Parse the given SDF file, and generate objects based on types specified in the SDF file.
void ClearWorlds()
Remove all worlds.
const World * WorldByIndex(const uint64_t _index) const
Get a world based on an index.
Errors Load(const std::string &_filename, const ParserConfig &_config)
Parse the given SDF file, and generate objects based on types specified in the SDF file.
Definition: World.hh:59
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:52
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:95
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:55
namespace for Simulation Description Format parser
Definition: Actor.hh:35
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:25