#ifndef TARGETGENERATOR_HPP #define TARGETGENERATOR_HPP #include #include #include #include "ATarget.hpp" class TargetGenerator { private: TargetGenerator(TargetGenerator const & other); TargetGenerator & operator=(TargetGenerator const & other); std::map arr; public: TargetGenerator() {} ~TargetGenerator() { std::map::iterator it; for (it = arr.begin(); it != arr.end(); ++it) delete it->second; this->arr.clear(); } void learnTargetType(ATarget * atarget) { if (atarget) { arr.insert(std::pair ( atarget->getType(), atarget->clone() )); } } void forgetTargetType(std::string const & type) { std::map::iterator it; it = arr.find(type); if (it != arr.end()) { delete it->second; arr.erase(type); } } ATarget * createTarget(std::string const & type) { std::map::iterator it; it = arr.find(type); if (it != arr.end()) return arr[type]->clone(); return NULL; } }; #endif