View.cpp 350 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "View.h"
  2. View::View()
  3. {
  4. ref = 1;
  5. }
  6. View::~View()
  7. {}
  8. View *View::getThis()
  9. {
  10. ref++;
  11. return this;
  12. }
  13. View *View::release()
  14. {
  15. if( !--ref )
  16. delete this;
  17. return 0;
  18. }
  19. ActionView::ActionView( std::function< void( Model * ) > f )
  20. : View()
  21. {
  22. this->f = f;
  23. }
  24. void ActionView::update( Model *m )
  25. {
  26. f( m );
  27. }