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 
31 namespace 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 
102  public: Errors LoadSdfString(
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 
152  public: bool WorldNameExists(const std::string &_name) const;
153 
157  public: const sdf::Model *Model() const;
158 
162  public: void SetModel(const sdf::Model &_model);
163 
167  public: const sdf::Light *Light() const;
168 
172  public: void SetLight(const sdf::Light &_light);
173 
177  public: const sdf::Actor *Actor() const;
178 
182  public: void SetActor(const sdf::Actor &_actor);
183 
188  public: sdf::ElementPtr Element() const;
189 
196  public: Errors AddWorld(const World &_world);
197 
199  public: void ClearWorlds();
200 
205  public: sdf::Root Clone() const;
206 
213  public: Errors UpdateGraphs();
214 
221  public: sdf::ElementPtr ToElement(
222  const OutputConfig &_config = OutputConfig::GlobalConfig()) const;
223 
225  GZ_UTILS_IMPL_PTR(dataPtr)
226  };
227  }
228 }
229 #endif
sdf::SDF_VERSION_NAMESPACE::SDFPtr
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:52
sdf::SDF_VERSION_NAMESPACE::OutputConfig
This class contains configuration options for SDF output.
Definition: OutputConfig.hh:58
sdf::SDF_VERSION_NAMESPACE::Model
Definition: Model.hh:54
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:34
ParserConfig.hh
Types.hh
sdf_config.h
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:25
sdf::SDF_VERSION_NAMESPACE::ParserConfig
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:84
sdf::SDF_VERSION_NAMESPACE::Light
Provides a description of a light source.
Definition: Light.hh:63
sdf::SDF_VERSION_NAMESPACE::Element
class GZ_SDFORMAT_VISIBLE Element
Definition: Element.hh:50
sdf::SDF_VERSION_NAMESPACE::Root
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:57
sdf::SDF_VERSION_NAMESPACE::Actor
Provides a description of an actor.
Definition: Actor.hh:191
SDFImpl.hh
sdf::SDF_VERSION_NAMESPACE::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:80
OutputConfig.hh
sdf::SDF_VERSION_NAMESPACE::OutputConfig::GlobalConfig
static OutputConfig & GlobalConfig()
Mutable access to a singleton OutputConfig that serves as the global OutputConfig object for all pars...
system_util.hh
sdf::SDF_VERSION_NAMESPACE::World
Definition: World.hh:57
sdf::SDF_VERSION_NAMESPACE::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54