Go to the documentation of this file.00001
00012 #ifndef OBSERVATION_FACTORY_HPP_
00013 #define OBSERVATION_FACTORY_HPP_
00014
00015
00016 #include "rtslam/sensorAbstract.hpp"
00017 #include "rtslam/landmarkAbstract.hpp"
00018 #include "rtslam/featurePoint.hpp"
00019
00020 #include "rtslam/descriptorImagePoint.hpp"
00021
00022 namespace jafar {
00023 namespace rtslam {
00024
00025
00026
00027
00028
00029
00030
00031
00032 class ObservationMakerAbstract
00033 {
00034 protected:
00035 typedef std::pair<SensorAbstract::type_enum, LandmarkAbstract::type_enum> SenLmk;
00036 SenLmk type;
00037 friend class ObservationFactory;
00038
00039 public:
00040 ObservationMakerAbstract(SensorAbstract::type_enum sensor_type, LandmarkAbstract::type_enum landmark_type):
00041 type(sensor_type, landmark_type) {}
00042
00043 virtual observation_ptr_t create(const sensor_ptr_t &senPtr, const landmark_ptr_t &lmkPtr) = 0;
00044
00045
00046
00047 };
00048
00049 typedef boost::shared_ptr<ObservationMakerAbstract> observation_maker_ptr_t;
00050
00051
00052
00053 class ObservationFactory
00054 {
00055 private:
00056 typedef std::pair<SensorAbstract::type_enum, LandmarkAbstract::type_enum> SenLmk;
00057 typedef std::map<SenLmk, observation_maker_ptr_t> CreatorsMap;
00058 CreatorsMap creators;
00059
00060 observation_maker_ptr_t getMaker(SenLmk senLmk)
00061 {
00062 CreatorsMap::iterator it = creators.find(senLmk);
00063 if (it == creators.end())
00064 JFR_ERROR(RtslamException, RtslamException::UNKNOWN_TYPES_FOR_FACTORY,
00065 "ObservationFactory: do not know how to create an observation from sensor type "
00066 << senLmk.first << " and landmark type " << senLmk.second);
00067 return it->second;
00068 }
00069
00070 public:
00071 void addMaker(const observation_maker_ptr_t &maker)
00072 {
00073 creators[maker->type] = maker;
00074 }
00075
00076 observation_ptr_t create(const sensor_ptr_t &senPtr, const landmark_ptr_t &lmkPtr)
00077 {
00078 observation_maker_ptr_t maker = getMaker(SenLmk(senPtr->type,lmkPtr->type));
00079 return maker->create(senPtr, lmkPtr);
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 };
00095
00096
00097
00099
00100
00101
00102
00103 }}
00104
00105 #endif
00106