Class
List
Hierarchy
Modules
Common
Events
Math
Messages
Physics
Rendering
Sensors
Transport
Links
Gazebo Website
Wiki
Tutorials
Download
Report Documentation Issues
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
gazebo
sensors
SensorFactory.hh
Go to the documentation of this file.
1
/*
2
* Copyright 2012 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 sensors
19
* Author: Andrew Howard
20
* Date: 18 May 2003
21
*/
22
23
#ifndef _SENSORFACTORY_HH_
24
#define _SENSORFACTORY_HH_
25
26
#include <string>
27
#include <map>
28
#include <vector>
29
30
#include "
gazebo/sensors/SensorTypes.hh
"
31
32
namespace
gazebo
33
{
36
namespace
sensors
37
{
40
typedef
Sensor
* (*SensorFactoryFn) ();
41
46
class
SensorFactory
47
{
58
public
:
static
void
RegisterAll
();
59
63
public
:
static
void
RegisterSensor
(
const
std::string &_className,
64
SensorFactoryFn
_factoryfn);
65
70
public
:
static
SensorPtr
NewSensor
(
const
std::string &_className);
71
75
public
:
static
void
GetSensorTypes
(std::vector<std::string> &_types);
76
78
private
:
static
std::map<std::string, SensorFactoryFn> sensorMap;
79
};
80
81
87
#define GZ_REGISTER_STATIC_SENSOR(name, classname) \
88
Sensor *New##classname() \
89
{ \
90
return new gazebo::sensors::classname(); \
91
} \
92
void Register##classname() \
93
{\
94
SensorFactory::RegisterSensor(name, New##classname);\
95
}
96
97
}
98
}
99
100
#endif
101
102