##

SensorFactory.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 sensors
* Author: Andrew Howard
* Date: 18 May 2003
*/
#ifndef _SENSORFACTORY_HH_
#define _SENSORFACTORY_HH_
#include <string>
#include <map>
#include <vector>
#include "gazebo/sensors/SensorTypes.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace sensors
{
typedef Sensor* (*SensorFactoryFn) ();
class SensorFactory
{
public: GZ_SENSORS_VISIBLE static void RegisterAll();
public: GZ_SENSORS_VISIBLE static void RegisterSensor(
const std::string &_className, SensorFactoryFn _factoryfn);
public: GZ_SENSORS_VISIBLE static SensorPtr NewSensor(
const std::string &_className);
public: GZ_SENSORS_VISIBLE static void GetSensorTypes(
std::vector<std::string> &_types);
private: static std::map<std::string, SensorFactoryFn> sensorMap;
};
#define GZ_REGISTER_STATIC_SENSOR(name, classname) \
Sensor *New##classname() \
{ \
return new gazebo::sensors::classname(); \
} \
\
void Register##classname() \
{\
SensorFactory::RegisterSensor(name, New##classname);\
}
}
}
#endif
gazebo::sensors::SensorFactory::RegisterAll
static void RegisterAll()
Register all known sensors.
gazebo::sensors::SensorPtr
std::shared_ptr< Sensor > SensorPtr
Definition: SensorTypes.hh:64
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
sensors
sensors
Definition: SensorManager.hh:35
SensorTypes.hh
Forward declarations and typedefs for sensors.
gazebo::sensors::SensorFactoryFn
Sensor *(* SensorFactoryFn)()
Definition: SensorFactory.hh:41
system.hh
gazebo::sensors::SensorFactory::NewSensor
static SensorPtr NewSensor(const std::string &_className)
Create a new instance of a sensor.
gazebo::sensors::SensorFactory
Definition: SensorFactory.hh:47
gazebo::sensors::SensorFactory::GetSensorTypes
static void GetSensorTypes(std::vector< std::string > &_types)
Get all the sensor types.
gazebo::sensors::Sensor
Base class for sensors.
Definition: Sensor.hh:51
gazebo::sensors::SensorFactory::RegisterSensor
static void RegisterSensor(const std::string &_className, SensorFactoryFn _factoryfn)
Register a sensor class (called by sensor registration function).