Last active
August 29, 2015 14:26
-
-
Save ubnt-intrepid/bb2928ceb95f95ae801a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "Collector.hpp" | |
| class GraphCollector : private Collector | |
| { | |
| private: | |
| void push_impl(object && data) override | |
| { | |
| // send to graph | |
| } | |
| }; | |
| class FileCollector : private Collector | |
| { | |
| public: | |
| FileCollector(std::string const& rootpath) | |
| { | |
| // ファイルを開く | |
| } | |
| ~FileCollector() | |
| { | |
| // save | |
| } | |
| private: | |
| void push_impl(object && data) override | |
| { | |
| // 結果を受け取る | |
| } | |
| }; | |
| std::unique_ptr<Collector> make_graph_collector() | |
| { | |
| return std::unique_ptr<Collector>(new GraphCollector); | |
| } | |
| std::unique_ptr<Collector> make_file_collector() | |
| { | |
| return std::unique_ptr<Collector>(new FileCollector); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #include <array> | |
| #include <memory> | |
| using binary = std::vector<uint8_t>; | |
| // 各時刻におけるシミュレーション結果を集計し,出力 or 保存する | |
| class Collector | |
| { | |
| public: | |
| // 時刻 time における計算結果 (data) を登録する | |
| template <class Serializable> | |
| void push(TimeIndex time, Serializable const& data) { | |
| this->push_impl(time, serialize(data)); | |
| } | |
| virtual ~Collector() {} | |
| private: | |
| virtual void push_impl(binary && data) = 0; | |
| }; | |
| std::unique_ptr<Collector> make_graph_collector(); | |
| std::unique_ptr<Collector> make_file_collector(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment