VisualizationFactory.cpp
Go to the documentation of this file.
1 /*
2  * VisualizationFactory.cpp
3  *
4  * Created on: Mar 20, 2015
5  * Author: Péter Fankhauser
6  * Institute: ETH Zurich, ANYbotics
7  */
8 
16 
17 // STL
18 #include <algorithm>
19 
20 namespace grid_map_visualization {
21 
23  : nodeHandle_(nodeHandle)
24 {
25  types_.push_back("point_cloud");
26  types_.push_back("flat_point_cloud");
27  types_.push_back("vectors");
28  types_.push_back("occupancy_grid");
29  types_.push_back("grid_cells");
30  types_.push_back("map_region");
31 }
32 
34 {
35 }
36 
37 bool VisualizationFactory::isValidType(const std::string& type)
38 {
39  return end(types_) != std::find(begin(types_), end(types_), type);
40 }
41 
42 std::shared_ptr<VisualizationBase> VisualizationFactory::getInstance(const std::string& type,
43  const std::string& name)
44 {
45  // TODO: Make this nicer: http://stackoverflow.com/questions/9975672/c-automatic-factory-registration-of-derived-types
46  if (type == "point_cloud") return std::shared_ptr<VisualizationBase>(new PointCloudVisualization(nodeHandle_, name));
47  if (type == "flat_point_cloud") return std::shared_ptr<VisualizationBase>(new FlatPointCloudVisualization(nodeHandle_, name));
48  if (type == "vectors") return std::shared_ptr<VisualizationBase>(new VectorVisualization(nodeHandle_, name));
49  if (type == "occupancy_grid") return std::shared_ptr<VisualizationBase>(new OccupancyGridVisualization(nodeHandle_, name));
50  if (type == "grid_cells") return std::shared_ptr<VisualizationBase>(new GridCellsVisualization(nodeHandle_, name));
51  if (type == "map_region") return std::shared_ptr<VisualizationBase>(new MapRegionVisualization(nodeHandle_, name));
52  return std::shared_ptr<VisualizationBase>();
53 }
54 
55 } /* namespace grid_map_visualization */
std::shared_ptr< VisualizationBase > getInstance(const std::string &type, const std::string &name)


grid_map_visualization
Author(s): Péter Fankhauser
autogenerated on Tue Jun 1 2021 02:13:51