diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2014-05-15 14:52:31 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2014-05-15 14:52:31 +0200 |
| commit | 2f6c50d2764138583dcf89d86b13440a23f217cf (patch) | |
| tree | 08cc78ff875c1501375f7a28401da3b3fd327d82 /main.cpp | |
| parent | 6a1e6120c4efc46f1d192b0e5fabc06b780113cc (diff) | |
| download | generic-gui-2f6c50d2764138583dcf89d86b13440a23f217cf.tar.gz generic-gui-2f6c50d2764138583dcf89d86b13440a23f217cf.tar.bz2 generic-gui-2f6c50d2764138583dcf89d86b13440a23f217cf.zip | |
3 major changes.
Renamed fusion_model to FusionModel to follow the naming convention.
Added observers so models can be shared over views and update properly.
Constness in datastructure now makes the data uneditable.
Diffstat (limited to 'main.cpp')
| -rw-r--r-- | main.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -10,33 +10,35 @@ #include <iostream> struct Data { - std::string name; + const std::string name; uint32_t number; - double ratio1; - float ratio2; + const double ratio1; + double ratio2; bool boolean; }; BOOST_FUSION_ADAPT_STRUCT( Data, - (std::string, name) + (const std::string, name) (uint32_t, number) - (double, ratio1) - (float,ratio2) + (const double, ratio1) + (double,ratio2) (bool, boolean) ) -struct DataModel : public fusion_model<std::vector<Data>> { - +struct DataModel : public FusionModel<std::vector<Data>> { void add_data(Data d) { data.push_back(d); } + }; -struct DataMapping :public fusion_model<std::map<std::string, Data>> { +struct DataMapping :public FusionModel<std::map<std::string, Data>> { void add_data(std::string key, Data value) { + call_on_observers(&FusionModelObserver::append_row_begin); data.emplace(key, value); + call_on_observers(&FusionModelObserver::append_row_end); } }; |
