Gazebo Sim

API Reference

9.0.0
Server.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 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 GZ_SIM_SERVER_HH_
18#define GZ_SIM_SERVER_HH_
19
20#include <cstdint>
21#include <memory>
22#include <optional>
23#include <string>
24#include <gz/sim/config.hh>
26#include <gz/sim/Export.hh>
29#include <sdf/Element.hh>
30#include <sdf/Plugin.hh>
31
32namespace gz
33{
34 namespace sim
35 {
36 // Inline bracket to help doxygen filtering.
37 inline namespace GZ_SIM_VERSION_NAMESPACE {
38 // Forware declarations
39 class ServerPrivate;
40
116 class GZ_SIM_VISIBLE Server
117 {
122 public: explicit Server(const ServerConfig &_config = ServerConfig());
123
125 public: ~Server();
126
133 public: void SetUpdatePeriod(
134 const std::chrono::steady_clock::duration &_updatePeriod,
135 const unsigned int _worldIndex = 0);
136
152 public: bool Run(const bool _blocking = false,
153 const uint64_t _iterations = 0,
154 const bool _paused = true);
155
163 public: bool RunOnce(const bool _paused = true);
164
170 public: bool Running() const;
171
180 public: std::optional<bool> Running(const unsigned int _worldIndex) const;
181
189 public: bool SetPaused(const bool _paused,
190 const unsigned int _worldIndex = 0) const;
191
198 public: std::optional<bool> Paused(
199 const unsigned int _worldIndex = 0) const;
200
205 public: std::optional<uint64_t> IterationCount(
206 const unsigned int _worldIndex = 0) const;
207
211 public: std::optional<size_t> EntityCount(
212 const unsigned int _worldIndex = 0) const;
213
217 public: std::optional<size_t> SystemCount(
218 const unsigned int _worldIndex = 0) const;
219
226 public: std::optional<bool> AddSystem(
227 const SystemPluginPtr &_system,
228 const unsigned int _worldIndex = 0);
229
240 public: std::optional<bool> AddSystem(
241 const SystemPluginPtr &_system,
242 std::optional<Entity> _entity,
243 std::optional<std::shared_ptr<const sdf::Element>> _sdf,
244 const unsigned int _worldIndex = 0);
245
255 public: std::optional<bool> AddSystem(
256 const sdf::Plugin &_plugin,
257 std::optional<Entity> _entity,
258 const unsigned int _worldIndex = 0);
259
266 public: std::optional<bool> AddSystem(
267 const std::shared_ptr<System> &_system,
268 const unsigned int _worldIndex = 0);
269
280 public: std::optional<bool> AddSystem(
281 const std::shared_ptr<System> &_system,
282 std::optional<Entity> _entity,
283 std::optional<std::shared_ptr<const sdf::Element>> _sdf,
284 const unsigned int _worldIndex = 0);
285
294 public: std::optional<Entity> EntityByName(const std::string &_name,
295 const unsigned int _worldIndex = 0) const;
296
303 public: bool HasEntity(const std::string &_name,
304 const unsigned int _worldIndex = 0) const;
305
319 public: bool RequestRemoveEntity(const std::string &_name,
320 bool _recursive = true,
321 const unsigned int _worldIndex = 0);
322
334 public: bool RequestRemoveEntity(const Entity _entity,
335 bool _recursive = true,
336 const unsigned int _worldIndex = 0);
337
339 public: void Stop();
340
342 private: std::unique_ptr<ServerPrivate> dataPtr;
343 };
344 }
345 }
346}
347
348#endif