##

PhysicsFactory.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/*
* Desc: Factory for creating physics engine
* Author: Nate Koenig
* Date: 21 May 2009
*/
#ifndef _PHYSICSFACTORY_HH_
#define _PHYSICSFACTORY_HH_
#include <string>
#include <map>
#include "gazebo/physics/PhysicsTypes.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace physics
{
typedef PhysicsEnginePtr (*PhysicsFactoryFn) (WorldPtr world);
class GZ_PHYSICS_VISIBLE PhysicsFactory
{
public: static void RegisterAll();
public: static void RegisterPhysicsEngine(std::string _className,
PhysicsFactoryFn _factoryfn);
public: static PhysicsEnginePtr NewPhysicsEngine(
const std::string &_className, WorldPtr _world);
public: static bool IsRegistered(const std::string &_name);
private: static std::map<std::string, PhysicsFactoryFn> engines;
};
#define GZ_REGISTER_PHYSICS_ENGINE(name, classname) \
PhysicsEnginePtr New##classname(WorldPtr _world) \
{ \
return PhysicsEnginePtr(new gazebo::physics::classname(_world)); \
} \
void Register##classname() \
{\
PhysicsFactory::RegisterPhysicsEngine(name, New##classname);\
}
}
}
#endif
gazebo::physics::PhysicsFactoryFn
PhysicsEnginePtr(* PhysicsFactoryFn)(WorldPtr world)
Definition: PhysicsFactory.hh:41
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::physics::PhysicsFactory
The physics factory instantiates different physics engines.
Definition: PhysicsFactory.hh:45
system.hh
gazebo::physics::PhysicsFactory::RegisterAll
static void RegisterAll()
Register everything.
PhysicsTypes.hh
default namespace for gazebo
gazebo::physics::PhysicsFactory::IsRegistered
static bool IsRegistered(const std::string &_name)
Check if a physics engine is registered.
gazebo::physics::PhysicsFactory::NewPhysicsEngine
static PhysicsEnginePtr NewPhysicsEngine(const std::string &_className, WorldPtr _world)
Create a new instance of a physics engine.
gazebo::physics::PhysicsFactory::RegisterPhysicsEngine
static void RegisterPhysicsEngine(std::string _className, PhysicsFactoryFn _factoryfn)
Register a physics class.
gazebo::physics::PhysicsEnginePtr
boost::shared_ptr< PhysicsEngine > PhysicsEnginePtr
Definition: PhysicsTypes.hh:125
gazebo::physics::WorldPtr
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:89