CloningFactory.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. Author: Juan Rada-Vilela, Ph.D.
  3. Copyright (C) 2010-2014 FuzzyLite Limited
  4. All rights reserved
  5. This file is part of fuzzylite.
  6. fuzzylite is free software: you can redistribute it and/or modify it under
  7. the terms of the GNU Lesser General Public License as published by the Free
  8. Software Foundation, either version 3 of the License, or (at your option)
  9. any later version.
  10. fuzzylite is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
  13. for more details.
  14. You should have received a copy of the GNU Lesser General Public License
  15. along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
  16. fuzzylite™ is a trademark of FuzzyLite Limited.
  17. */
  18. #ifndef FL_CLONINGFACTORY_H
  19. #define FL_CLONINGFACTORY_H
  20. #include "fl/fuzzylite.h"
  21. #include <map>
  22. #include <string>
  23. #include <vector>
  24. namespace fl {
  25. template <typename T>
  26. class FL_API CloningFactory {
  27. protected:
  28. std::string _name;
  29. std::map<std::string, T> _objects;
  30. public:
  31. CloningFactory(const std::string& name = "");
  32. CloningFactory(const CloningFactory& other);
  33. CloningFactory& operator=(const CloningFactory& other);
  34. virtual ~CloningFactory();
  35. FL_DEFAULT_MOVE(CloningFactory)
  36. virtual std::string name() const;
  37. virtual void registerObject(const std::string& key, T object);
  38. virtual void deregisterObject(const std::string& key);
  39. virtual bool hasObject(const std::string& key) const;
  40. virtual T getObject(const std::string& key) const;
  41. virtual T cloneObject(const std::string& key) const;
  42. virtual std::vector<std::string> available() const;
  43. };
  44. }
  45. #endif /* FL_CLONINGFACTORY_H */