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 
22 #include "sdf/SDFImpl.hh"
23 #include "sdf/Types.hh"
24 #include "sdf/sdf_config.h"
25 #include "sdf/system_util.hh"
26 
27 namespace sdf
28 {
29  // Inline bracket to help doxygen filtering.
30  inline namespace SDF_VERSION_NAMESPACE {
31  //
32 
33  // Forward declarations.
34  class Actor;
35  class Light;
36  class Model;
37  class RootPrivate;
38  class World;
39 
55  {
57  public: Root();
58 
60  public: ~Root();
61 
67  public: Errors Load(const std::string &_filename);
68 
74  public: Errors LoadSdfString(const std::string &_sdf);
75 
81  public: Errors Load(const SDFPtr _sdf);
82 
87  public: std::string Version() const;
88 
92  public: void SetVersion(const std::string &_version);
93 
96  public: uint64_t WorldCount() const;
97 
103  public: const World *WorldByIndex(const uint64_t _index) const;
104 
108  public: bool WorldNameExists(const std::string &_name) const;
109 
112  public: uint64_t ModelCount() const;
113 
119  public: const Model *ModelByIndex(const uint64_t _index) const;
120 
124  public: bool ModelNameExists(const std::string &_name) const;
125 
128  public: uint64_t LightCount() const;
129 
135  public: const Light *LightByIndex(const uint64_t _index) const;
136 
140  public: bool LightNameExists(const std::string &_name) const;
141 
144  public: uint64_t ActorCount() const;
145 
151  public: const Actor *ActorByIndex(const uint64_t _index) const;
152 
156  public: bool ActorNameExists(const std::string &_name) const;
157 
162  public: sdf::ElementPtr Element() const;
163 
165  private: RootPrivate *dataPtr = nullptr;
166  };
167  }
168 }
169 #endif
sdf::v9::Root::ActorNameExists
bool ActorNameExists(const std::string &_name) const
Get whether an actor name exists.
sdf::v9::Root::ActorByIndex
const Actor * ActorByIndex(const uint64_t _index) const
Get an actor based on an index.
sdf::v9::SDFPtr
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:50
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:33
sdf::v9::Root::ModelByIndex
const Model * ModelByIndex(const uint64_t _index) const
Get a model based on an index.
sdf::v9::Root::Load
Errors Load(const std::string &_filename)
Parse the given SDF file, and generate objects based on types specified in the SDF file.
sdf::v9::Root::LightCount
uint64_t LightCount() const
Get the number of lights.
sdf::v9::Root::Element
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was generated during load.
sdf::v9::Root::ModelCount
uint64_t ModelCount() const
Get the number of models.
sdf::v9::Root::WorldByIndex
const World * WorldByIndex(const uint64_t _index) const
Get a world based on an index.
Types.hh
sdf::v9::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:89
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
sdf::v9::Root::Load
Errors Load(const SDFPtr _sdf)
Parse the given SDF pointer, and generate objects based on types specified in the SDF file.
sdf::v9::World
Definition: World.hh:46
sdf::v9::Root::ActorCount
uint64_t ActorCount() const
Get the number of actors.
sdf::v9::Light
Provides a description of a light source.
Definition: Light.hh:63
sdf::v9::Root::Version
std::string Version() const
Get the SDF version specified in the parsed file or SDF pointer.
sdf::v9::Root
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:55
sdf::v9::Root::LoadSdfString
Errors LoadSdfString(const std::string &_sdf)
Parse the given SDF string, and generate objects based on types specified in the SDF file.
SDFImpl.hh
sdf::v9::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
sdf::v9::Root::ModelNameExists
bool ModelNameExists(const std::string &_name) const
Get whether a model name exists.
sdf::v9::Actor
Provides a description of an actor.
Definition: Actor.hh:278
sdf::v9::Root::~Root
~Root()
Destructor.
sdf::v9::Root::SetVersion
void SetVersion(const std::string &_version)
Set the SDF version string.
sdf::v9::Root::WorldNameExists
bool WorldNameExists(const std::string &_name) const
Get whether a world name exists.
sdf::v9::Model
Definition: Model.hh:44
sdf::v9::Root::Root
Root()
Default constructor.
system_util.hh
sdf::v9::Root::LightByIndex
const Light * LightByIndex(const uint64_t _index) const
Get a light based on an index.
sdf::v9::Root::WorldCount
uint64_t WorldCount() const
Get the number of worlds.
sdf::v9::Root::LightNameExists
bool LightNameExists(const std::string &_name) const
Get whether a light name exists.