neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
model.hpp
Go to the documentation of this file.
1// model.hpp
2/*
3neogfx C++ App/Game Engine
4Copyright (c) 2020 Leigh Johnston. All Rights Reserved.
5
6This program is free software: you can redistribute it and / or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
23#include <neogfx/core/event.hpp>
25
26namespace neogfx::mvc
27{
28 template <typename AbstractModel = i_model>
29 class model : public AbstractModel
30 {
31 typedef AbstractModel base_type;
32 public:
33 typedef base_type abstract_type;
34 public:
35 define_declared_event(Modified, modified)
37 define_declared_event(ControllerRemoved, controller_removed, i_controller&)
38 public:
39 model() :
40 iDirty{ false }
41 {
42 }
43 public:
44 bool dirty() const override
45 {
46 return iDirty;
47 }
48 void set_dirty() override
49 {
50 if (!iDirty)
51 {
52 iDirty = true;
53 Modified.trigger();
54 }
55 }
56 void set_clean() override
57 {
58 if (iDirty)
59 iDirty = false;
60 }
61 void add_controller(i_controller& aController) override
62 {
63 ControllerAdded.trigger(aController);
64 // todo
65 }
66 void remove_controller(i_controller& aController) override
67 {
68 ControllerRemoved.trigger(aController);
69 // todo
70 }
71 private:
72 bool iDirty;
73 };
74}
void set_clean() override
Definition model.hpp:56
define_declared_event(Modified, modified) define_declared_event(ControllerAdded
void set_dirty() override
Definition model.hpp:48
void remove_controller(i_controller &aController) override
Definition model.hpp:66
void add_controller(i_controller &aController) override
Definition model.hpp:61
bool dirty() const override
Definition model.hpp:44
base_type abstract_type
Definition model.hpp:33
#define define_declared_event(name, declName,...)
Definition event.hpp:195