Ignition Gazebo

API Reference

6.9.0
ServerConfig.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 IGNITION_GAZEBO_SERVERCONFIG_HH_
18 #define IGNITION_GAZEBO_SERVERCONFIG_HH_
19 
20 #include <chrono>
21 #include <list>
22 #include <memory>
23 #include <optional> // NOLINT(*)
24 #include <string>
25 #include <vector>
26 #include <sdf/Element.hh>
27 #include <sdf/Root.hh>
28 #include <ignition/gazebo/config.hh>
29 #include <ignition/gazebo/Export.hh>
30 
31 namespace ignition
32 {
33  namespace gazebo
34  {
35  // Inline bracket to help doxygen filtering.
36  inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
37  // Forward declarations.
38  class ServerConfigPrivate;
39 
44  class IGNITION_GAZEBO_VISIBLE ServerConfig
45  {
47  public: enum class SourceType
48  {
49  // No source specified.
50  kNone,
51 
52  // The source is an SDF Root object.
53  kSdfRoot,
54 
55  // The source is an SDF file.
56  kSdfFile,
57 
58  // The source is an SDF string.
59  kSdfString,
60  };
61 
62 
63  class PluginInfoPrivate;
70  public: class IGNITION_GAZEBO_VISIBLE PluginInfo
71  {
73  public: PluginInfo();
74 
76  public: ~PluginInfo();
77 
89  public: PluginInfo(const std::string &_entityName,
90  const std::string &_entityType,
91  const std::string &_filename,
92  const std::string &_name,
93  const sdf::ElementPtr &_sdf);
94 
97  public: PluginInfo(const PluginInfo &_info);
98 
102  public: PluginInfo &operator=(const PluginInfo &_info);
103 
108  public: const std::string &EntityName() const;
109 
114  public: void SetEntityName(const std::string &_entityName);
115 
120  public: const std::string &EntityType() const;
121 
126  public: void SetEntityType(const std::string &_entityType);
127 
130  public: const std::string &Filename() const;
131 
136  public: void SetFilename(const std::string &_filename);
137 
141  public: const std::string &Name() const;
142 
146  public: void SetName(const std::string &_name);
147 
150  public: const sdf::ElementPtr &Sdf() const;
151 
154  public: void SetSdf(const sdf::ElementPtr &_sdf);
155 
158  };
159 
161  public: ServerConfig();
162 
165  public: ServerConfig(const ServerConfig &_config);
166 
168  public: ~ServerConfig();
169 
176  public: bool SetSdfFile(const std::string &_file);
177 
181  public: std::string SdfFile() const;
182 
189  public: bool SetSdfString(const std::string &_sdfString);
190 
194  public: std::string SdfString() const;
195 
200  public: void SetSdfRoot(const sdf::Root &_root) const;
201 
205  public: std::optional<sdf::Root> &SdfRoot() const;
206 
209  public: void SetUpdateRate(const double &_hz);
210 
214  public: std::optional<double> UpdateRate() const;
215 
218  public: bool UseLevels() const;
219 
222  public: void SetUseLevels(const bool _levels);
223 
228  public: bool UseDistributedSimulation() const;
229 
236  public: void SetNetworkSecondaries(unsigned int _secondaries);
237 
242  public: unsigned int NetworkSecondaries() const;
243 
251  public: void SetNetworkRole(const std::string &_role);
252 
258  public: std::string NetworkRole() const;
259 
262  public: bool UseLogRecord() const;
263 
266  public: void SetUseLogRecord(const bool _record);
267 
270  public: const std::string LogRecordPath() const;
271 
274  public: void SetLogRecordPath(const std::string &_recordPath);
275 
278  public: void AddLogRecordTopic(const std::string &_topic);
279 
282  public: void ClearLogRecordTopics();
283 
287  public: const std::vector<std::string> &LogRecordTopics() const;
288 
291  public: const std::string LogPlaybackPath() const;
292 
295  public: void SetLogPlaybackPath(const std::string &_playbackPath);
296 
299  public: bool LogRecordResources() const;
300 
303  public: void SetLogRecordResources(bool _recordResources);
304 
307  public: std::string LogRecordCompressPath() const;
308 
311  public: void SetLogRecordCompressPath(const std::string &_path);
312 
315  public: unsigned int Seed() const;
316 
319  public: void SetSeed(unsigned int _seed);
320 
324  public: std::optional<std::chrono::steady_clock::duration>
325  UpdatePeriod() const;
326 
332  public: const std::string &ResourceCache() const;
333 
339  public: void SetResourceCache(const std::string &_path);
340 
343  public: const std::string &PhysicsEngine() const;
344 
347  public: void SetPhysicsEngine(const std::string &_physicsEngine);
348 
351  public: const std::string &RenderEngineServer() const;
352 
355  public: const std::string &RenderEngineGui() const;
356 
359  public: void SetHeadlessRendering(const bool _headless);
360 
363  public: bool HeadlessRendering() const;
364 
367  public: void SetRenderEngineServer(
368  const std::string &_renderEngineServer);
369 
372  public: void SetRenderEngineGui(const std::string &_renderEngineGui);
373 
377  public: void AddPlugin(const PluginInfo &_info);
378 
381  public: void AddPlugins(const std::list<PluginInfo> &_plugins);
382 
390  public: PluginInfo LogRecordPlugin() const;
391 
395  public: PluginInfo LogPlaybackPlugin() const;
396 
400  public: const std::list<PluginInfo> &Plugins() const;
401 
405  public: ServerConfig &operator=(const ServerConfig &_cfg);
406 
413  Timestamp() const;
414 
417  public: SourceType Source() const;
418 
420  private: std::unique_ptr<ServerConfigPrivate> dataPtr;
421  };
422 
427  IGNITION_GAZEBO_VISIBLE
428  parsePluginsFromFile(const std::string &_fname);
429 
434  IGNITION_GAZEBO_VISIBLE
435  parsePluginsFromString(const std::string &_str);
436 
453  //
456  //
459  IGNITION_GAZEBO_VISIBLE
460  loadPluginInfo(bool _isPlayback = false);
461  }
462  }
463 }
464 
465 #endif
std::list< ServerConfig::PluginInfo > loadPluginInfo(bool _isPlayback=false)
Load plugin information, following ordering.
Configuration parameters for a Server. An instance of this object can be used to construct a Server w...
Definition: ServerConfig.hh:44
STL class.
std::list< ServerConfig::PluginInfo > parsePluginsFromFile(const std::string &_fname)
Parse plugins from XML configuration file.
std::list< ServerConfig::PluginInfo > parsePluginsFromString(const std::string &_str)
Parse plugins from XML configuration string.
Component< std::string, class NameTag, serializers::StringSerializer > Name
This component holds an entity&#39;s name. The component has no concept of scoped names nor does it care ...
Definition: Name.hh:37
SourceType
Type of SDF source.
Definition: ServerConfig.hh:47
STL class.
STL class.
std::chrono::steady_clock::time_point Timestamp
Information about a plugin that should be loaded by the server.
Definition: ServerConfig.hh:70
This library is part of the Ignition Robotics project.