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 <ignition/utils/ImplPtr.hh>
22 
23 #include "sdf/SDFImpl.hh"
24 #include "sdf/Types.hh"
25 #include "sdf/sdf_config.h"
26 #include "sdf/system_util.hh"
27 
28 namespace sdf
29 {
30  // Inline bracket to help doxygen filtering.
31  inline namespace SDF_VERSION_NAMESPACE {
32  //
33 
34  // Forward declarations.
35  class Actor;
36  class Light;
37  class Model;
38  class World;
39 
55  {
57  public: Root();
58 
64  public: Errors Load(const std::string &_filename);
65 
72  public: Errors Load(
73  const std::string &_filename, const ParserConfig &_config);
74 
80  public: Errors LoadSdfString(const std::string &_sdf);
81 
89  const std::string &_sdf, const ParserConfig &_config);
90 
96  public: Errors Load(const SDFPtr _sdf);
97 
104  public: Errors Load(const SDFPtr _sdf, const ParserConfig &_config);
105 
110  public: std::string Version() const;
111 
115  public: void SetVersion(const std::string &_version);
116 
119  public: uint64_t WorldCount() const;
120 
126  public: const World *WorldByIndex(const uint64_t _index) const;
127 
131  public: bool WorldNameExists(const std::string &_name) const;
132 
136  public: const sdf::Model *Model() const;
137 
141  public: const sdf::Light *Light() const;
142 
146  public: const sdf::Actor *Actor() const;
147 
152  public: sdf::ElementPtr Element() const;
153 
155  IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr)
156  };
157  }
158 }
159 #endif
Provides a description of an actor.
Definition: Actor.hh:191
Provides a description of a light source.
Definition: Light.hh:64
Definition: Model.hh:49
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:85
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:55
Root()
Default constructor.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was generated during load.
Errors LoadSdfString(const std::string &_sdf)
Parse the given SDF string, and generate objects based on types specified in the SDF file.
const sdf::Light * Light() const
Get a pointer to the light object if it exists.
const sdf::Actor * Actor() const
Get a pointer to the actor object if it exists.
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.
Errors Load(const SDFPtr _sdf)
Parse the given SDF pointer, and generate objects based on types specified in the SDF file.
Errors Load(const std::string &_filename)
Parse the given SDF file, and generate objects based on types specified in the SDF file.
std::string Version() const
Get the SDF version specified in the parsed file or SDF pointer.
const World * WorldByIndex(const uint64_t _index) const
Get a world based on an index.
bool WorldNameExists(const std::string &_name) const
Get whether a world name exists.
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.
void SetVersion(const std::string &_version)
Set the SDF version string.
Errors Load(const SDFPtr _sdf, const ParserConfig &_config)
Parse the given SDF pointer, and generate objects based on types specified in the SDF file.
const sdf::Model * Model() const
Get a pointer to the model object if it exists.
uint64_t WorldCount() const
Get the number of worlds.
Definition: World.hh:55
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:106
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:52
namespace for Simulation Description Format parser
Definition: Actor.hh:34
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:41