AtmosphereFactory.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 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 GAZEBO_PHYSICS_ATMOSPHEREFACTORY_HH_
18 #define GAZEBO_PHYSICS_ATMOSPHEREFACTORY_HH_
19 
20 #include <string>
21 #include <map>
22 
24 #include "gazebo/util/system.hh"
25 
26 namespace gazebo
27 {
28  namespace physics
29  {
32 
35  typedef std::unique_ptr<Atmosphere> (*AtmosphereFactoryFn) (World &world);
36 
39  class GZ_PHYSICS_VISIBLE AtmosphereFactory
40  {
42  public: static void RegisterAll();
43 
48  public: static void RegisterAtmosphere(const std::string &_className,
49  AtmosphereFactoryFn _factoryfn);
50 
55  public: static std::unique_ptr<Atmosphere> NewAtmosphere(
56  const std::string &_className, World &_world);
57 
61  public: static bool IsRegistered(const std::string &_name);
62 
64  private: static std::map<std::string, AtmosphereFactoryFn> models;
65  };
66 
72  #define GZ_REGISTER_ATMOSPHERE_MODEL(_name, _classname) \
73  GZ_PHYSICS_VISIBLE std::unique_ptr<Atmosphere> \
74  New##_classname(World &_world) \
75  { \
76  return std::unique_ptr<Atmosphere>( \
77  new gazebo::physics::_classname(_world)); \
78  } \
79  GZ_PHYSICS_VISIBLE \
80  void Register##_classname() \
81  {\
82  AtmosphereFactory::RegisterAtmosphere(_name, New##_classname);\
83  }
84  }
86 }
87 #endif
default namespace for gazebo
The world provides access to all other object within a simulated environment.
Definition: World.hh:68
std::unique_ptr< Atmosphere >(* AtmosphereFactoryFn)(World &world)
Definition: AtmosphereFactory.hh:35
The atmosphere factory instantiates different atmosphere models.
Definition: AtmosphereFactory.hh:39