PresetManager.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 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
18#ifndef _GAZEBO_PHYSICS_PRESETMANAGER_HH_
19#define _GAZEBO_PHYSICS_PRESETMANAGER_HH_
20
21#include <boost/any.hpp>
22#include <string>
23#include <vector>
24#include <sdf/sdf.hh>
25
27
28namespace gazebo
29{
30 namespace physics
31 {
32 class PresetPrivate;
33
36 class GZ_PHYSICS_VISIBLE Preset
37 {
39 public: Preset();
40
43 // cppcheck-suppress noExplicitConstructor
44 public: Preset(const std::string & _name);
45
47 public: ~Preset();
48
51 public: std::string Name() const;
52
59 public: bool GetParam(const std::string &_key, boost::any &_value) const;
60
64 public: bool SetParam(const std::string &_key, const boost::any &_value);
65
69 public: bool HasParam(const std::string &_key) const;
70
75 public: bool SetAllPhysicsParameters(PhysicsEnginePtr _physicsEngine)
76 const;
77
82 public: bool SetAllParamsFromSDF(const sdf::ElementPtr _elem);
83
88 private: bool SetAllParamsHelper(const sdf::ElementPtr _elem);
89
92 public: sdf::ElementPtr SDF() const;
93
97 public: bool SDF(const sdf::ElementPtr _sdfElement);
98
100 private: PresetPrivate *dataPtr;
101 };
102
103 class PresetManagerPrivate;
104
107 class GZ_PHYSICS_VISIBLE PresetManager
108 {
112 public: PresetManager(PhysicsEnginePtr _physicsEngine,
113 const sdf::ElementPtr _sdf);
114
116 public: ~PresetManager();
117
121 public: bool CurrentProfile(const std::string &_name);
122
125 public: std::string CurrentProfile() const;
126
129 public: std::vector<std::string> AllProfiles() const;
130
136 public: bool SetProfileParam(const std::string &_profileName,
137 const std::string &_key, const boost::any &_value);
138
147 public: bool GetProfileParam(const std::string &_name,
148 const std::string &_key, boost::any &_value) const;
149
154 public: bool SetCurrentProfileParam(const std::string &_key,
155 const boost::any &_value);
156
164 public: bool GetCurrentProfileParam(const std::string &_key,
165 boost::any &_value);
166
171 public: bool CreateProfile(const std::string &_name);
172
178 public: std::string CreateProfile(const sdf::ElementPtr _sdf);
179
182 public: void RemoveProfile(const std::string &_name);
183
187 public: bool HasProfile(const std::string &_name) const;
188
193 public: sdf::ElementPtr ProfileSDF(const std::string &_name) const;
194
199 public: bool ProfileSDF(const std::string &_name,
200 const sdf::ElementPtr _sdf);
201
205 public: void GenerateSDFFromPreset(const std::string &_name,
206 sdf::ElementPtr &_elem) const;
207
211 private: void GenerateSDFHelper(const Preset &_preset,
212 sdf::ElementPtr &_elem) const;
213
217 private: void GeneratePresetFromSDF(const sdf::ElementPtr _elem,
218 Preset &_preset) const;
219
222 private: Preset *CurrentPreset() const;
223
225 private: PresetManagerPrivate *dataPtr;
226 };
227 }
228}
229
230#endif
default namespace for gazebo
Class to manage preset physics profiles.
Definition PresetManager.hh:108
bool CurrentProfile(const std::string &_name)
Set the current profile.
bool ProfileSDF(const std::string &_name, const sdf::ElementPtr _sdf)
Set the SDF for a profile.
sdf::ElementPtr ProfileSDF(const std::string &_name) const
Get the SDF for a profile.
bool CreateProfile(const std::string &_name)
Create a new profile.
std::string CurrentProfile() const
Get the name of the current profile.
bool SetProfileParam(const std::string &_profileName, const std::string &_key, const boost::any &_value)
Set a parameter for a certain profile.
void RemoveProfile(const std::string &_name)
Remove a profile.
std::string CreateProfile(const sdf::ElementPtr _sdf)
Create a new profile from SDF.
PresetManager(PhysicsEnginePtr _physicsEngine, const sdf::ElementPtr _sdf)
Constructor.
bool SetCurrentProfileParam(const std::string &_key, const boost::any &_value)
Set a parameter for the current profile.
bool GetCurrentProfileParam(const std::string &_key, boost::any &_value)
Get a parameter for the current profile.
bool HasProfile(const std::string &_name) const
Determine if we have a profile.
bool GetProfileParam(const std::string &_name, const std::string &_key, boost::any &_value) const
Get a parameter for a certain profile.
void GenerateSDFFromPreset(const std::string &_name, sdf::ElementPtr &_elem) const
Generate an SDF element from an Preset object.
std::vector< std::string > AllProfiles() const
Get the name of all profiles.
Representation of a preset physics profile.
Definition PresetManager.hh:37
std::string Name() const
Get the profile name.
bool SetAllParamsFromSDF(const sdf::ElementPtr _elem)
Set all parameters of this preset based on the key/value pairs in the given SDF element.
bool GetParam(const std::string &_key, boost::any &_value) const
Get a profile parameter.
bool SetParam(const std::string &_key, const boost::any &_value)
Set a profile parameter.
sdf::ElementPtr SDF() const
Get this preset profile's SDF.
Preset(const std::string &_name)
Constructor.
bool SDF(const sdf::ElementPtr _sdfElement)
Set this preset profile's SDF.
bool SetAllPhysicsParameters(PhysicsEnginePtr _physicsEngine) const
Set all parameters of this preset in the physics engine.
bool HasParam(const std::string &_key) const
Check if profile parameter is set.
boost::shared_ptr< PhysicsEngine > PhysicsEnginePtr
Definition PhysicsTypes.hh:126
Forward declarations for the common classes.
Definition Animation.hh:27