summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2014-05-15 14:52:31 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2014-05-15 14:52:31 +0200
commit2f6c50d2764138583dcf89d86b13440a23f217cf (patch)
tree08cc78ff875c1501375f7a28401da3b3fd327d82 /main.cpp
parent6a1e6120c4efc46f1d192b0e5fabc06b780113cc (diff)
downloadgeneric-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.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/main.cpp b/main.cpp
index 3ff490e..d817367 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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);
}
};