All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PhysicsFactory.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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  * Desc: Factory for creating physics engine
19  * Author: Nate Koenig
20  * Date: 21 May 2009
21  */
22 
23 #ifndef _PHYSICSFACTORY_HH_
24 #define _PHYSICSFACTORY_HH_
25 
26 #include <string>
27 #include <map>
28 
30 #include "gazebo/util/system.hh"
31 
32 namespace gazebo
33 {
34  namespace physics
35  {
38 
42 
46  {
48  public: static void RegisterAll();
49 
54  public: static void RegisterPhysicsEngine(std::string _className,
55  PhysicsFactoryFn _factoryfn);
56 
60  public: static PhysicsEnginePtr NewPhysicsEngine(
61  const std::string &_className, WorldPtr _world);
62 
66  public: static bool IsRegistered(const std::string &_name);
67 
69  private: static std::map<std::string, PhysicsFactoryFn> engines;
70  };
71 
77  #define GZ_REGISTER_PHYSICS_ENGINE(name, classname) \
78  GAZEBO_VISIBLE PhysicsEnginePtr New##classname(WorldPtr _world) \
79  { \
80  return PhysicsEnginePtr(new gazebo::physics::classname(_world)); \
81  } \
82  GAZEBO_VISIBLE \
83  void Register##classname() \
84  {\
85  PhysicsFactory::RegisterPhysicsEngine(name, New##classname);\
86  }
87  }
89 }
90 #endif
PhysicsEnginePtr(* PhysicsFactoryFn)(WorldPtr world)
Definition: PhysicsFactory.hh:41
The physics factory instantiates different physics engines.
Definition: PhysicsFactory.hh:45
default namespace for gazebo
boost::shared_ptr< PhysicsEngine > PhysicsEnginePtr
Definition: PhysicsTypes.hh:106
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:78
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48