diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2014-04-18 18:30:52 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2014-04-18 18:30:52 +0200 |
| commit | d834eba65c2c65c1540d13c9c39ced51bd87cf83 (patch) | |
| tree | 68c0533b668545cbfb0b0d556ac7ebf9bf8d3e97 /fusion_model.hpp | |
| parent | 0969e7a24c0ae2a0cc9c5bd4be0d18c29bfe7f30 (diff) | |
| download | generic-gui-d834eba65c2c65c1540d13c9c39ced51bd87cf83.tar.gz generic-gui-d834eba65c2c65c1540d13c9c39ced51bd87cf83.tar.bz2 generic-gui-d834eba65c2c65c1540d13c9c39ced51bd87cf83.zip | |
First working prototype
Diffstat (limited to 'fusion_model.hpp')
| -rw-r--r-- | fusion_model.hpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/fusion_model.hpp b/fusion_model.hpp new file mode 100644 index 0000000..ace8f51 --- /dev/null +++ b/fusion_model.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include "fusion_static_dispatch.hpp" + +#include <boost/fusion/include/is_sequence.hpp> +#include <boost/fusion/include/size.hpp> + +#include <boost/any.hpp> + +#include <vector> +#include <map> + +template <typename T> +struct fusion_model { + +}; + +template <typename T> +struct fusion_model<std::vector<T>> +{ + static_assert(boost::fusion::traits::is_sequence<T>::type::value, "T is not a boost fusion sequence"); + + typedef std::vector<T> data_type; + + std::vector<T> data; + + size_t row_count() const + { + return data.size(); + } + + size_t column_count() const + { + return boost::fusion::result_of::size<T>::type::value; + } + + std::string horizontal_header_data(size_t section) const + { + return get_nth_name<T>(section); + } + + boost::any get_cell(size_t row, size_t column) const + { + return get_nth(data[row], column); + } +}; + +template <typename T, typename U> +struct fusion_model<std::map<T, U>> +{ + std::map<T, U> data; +};
\ No newline at end of file |
