Loading...
Searching...
No Matches
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
27namespace 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
Provides a description of an actor.
Definition Actor.hh:278
Provides a description of a light source.
Definition Light.hh:63
Definition Model.hh:44
Root class that acts as an entry point to the SDF document model.
Definition Root.hh:55
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.
Errors LoadSdfString(const std::string &_sdf)
Parse the given SDF string, 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.
uint64_t ModelCount() const
Get the number of models.
uint64_t ActorCount() const
Get the number of actors.
void SetVersion(const std::string &_version)
Set the SDF version string.
Root()
Default constructor.
uint64_t WorldCount() const
Get the number of worlds.
bool LightNameExists(const std::string &_name) const
Get whether a light name exists.
~Root()
Destructor.
Errors Load(const SDFPtr _sdf)
Parse the given SDF pointer, and generate objects based on types specified in the SDF file.
const Model * ModelByIndex(const uint64_t _index) const
Get a model based on an index.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was generated during load.
uint64_t LightCount() const
Get the number of lights.
const Light * LightByIndex(const uint64_t _index) const
Get a light based on an index.
bool WorldNameExists(const std::string &_name) const
Get whether a world name exists.
bool ActorNameExists(const std::string &_name) const
Get whether an actor name exists.
bool ModelNameExists(const std::string &_name) const
Get whether a model name exists.
const Actor * ActorByIndex(const uint64_t _index) const
Get an actor based on an index.
Definition World.hh:46
std::shared_ptr< SDF > SDFPtr
Definition SDFImpl.hh:50
std::vector< Error > Errors
A vector of Error.
Definition Types.hh:89
std::shared_ptr< Element > ElementPtr
Definition Element.hh:53
namespace for Simulation Description Format parser
Definition Actor.hh:33
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:48