#ifndef COMPONENT_H #define COMPONENT_H #include class View; class Controller; class Component { public: Component(std::shared_ptr view, std::shared_ptr controller); ~Component(); template ControllerType* getController() const; template ViewType* getView() const; private: const std::shared_ptr m_controller; const std::shared_ptr m_view; }; template ControllerType* Component::getController() const { return dynamic_cast(m_controller.get()); } template ViewType* Component::getView() const { return dynamic_cast(m_view.get()); } #endif // COMPONENT_H