/* * ShapeRegistry.hpp * * Created on: Sep 13, 2012 * Author: ankele */ #ifndef SHAPEREGISTRY_HPP_ #define SHAPEREGISTRY_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include "CodePatterns/Observer/Observable.hpp" #include "CodePatterns/Registry.hpp" #include "CodePatterns/Singleton.hpp" #include "Shape.hpp" class ShapeRegistry : public Singleton, public Registry, public Observable { friend class Singleton; public: void addShape(Shape s); void removeShape(const std::string &name); std::string getDefaultNameForShape(const std::string &baseName) const; enum NotificationType { ShapeInserted, ShapeRemoved, SelectionChanged, NotificationType_MAX }; void selectShape(const std::string &name); void selectShape(Shape *s); void unselectShape(const std::string &name); void unselectShape(Shape *s); void selectAllShapes(); void unselectAllShapes(); void invertShapeSelection(); bool isSelected(const std::string &name) const; bool isSelected(Shape *s) const; int countSelectedShapes() const; std::vector getSelectedShapes() const; Shape *lastChanged() const { return _lastchanged; } private: // private constructor and destructor due to singleton ShapeRegistry(); virtual ~ShapeRegistry(); std::map selectedShapes; Shape *_lastchanged; }; #endif /* SHAPEREGISTRY_HPP_ */