X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=core%2Finclude%2Fmodel.hpp;h=432c6d2c782c3a0875c0baa7e7102b62440c4dd4;hb=HEAD;hp=647d54cc8928fac4948b4eac3d682980a53665bc;hpb=052f7126f8fc255aeac7ee445837f664ad61ba48;p=gikomona%2FGikoMona.git diff --git a/core/include/model.hpp b/core/include/model.hpp index 647d54c..432c6d2 100644 --- a/core/include/model.hpp +++ b/core/include/model.hpp @@ -3,8 +3,8 @@ #include #include -#include +#include #include #include #include @@ -16,11 +16,12 @@ namespace monazilla { namespace GikoMona { namespace core { -class model { +class model : public query { public: typedef model self_type; - typedef std::tuple inserted_query_type; - typedef inserted_query_type *inserted_query_triv_copyable_type; + typedef query base_type; + typedef boost::fusion::vector inserted_value_type; + typedef inserted_value_type *inserted_value_triv_copyable_type; model() noexcept; ~model(); @@ -29,25 +30,47 @@ public: model *get_instance() { return instance; } + + /** + * @breif query_concept を満たすクラスはこの関数と同じ型、名前を持つ関数を持っていなければならない。 + * @retval true insert 操作が成功した + * false insert 操作に失敗した + * @param[in] into どのテーブルのどの要素に対し insertion query を実行するかを記述する。 + * 記述の仕方は次の通り:(テーブル名)/[(サブテーブル名)/]*(要素名) + * @param[in] value テーブルに対して代入する値を記述する。 + * @note さらに、最大限 multi-threading な環境を考慮しなければならない。 + */ + template + bool insert(const mona_string& into, + const boost::fusion::vector& value) {} - template + template bool insert(const mona_string& into, - const std::tuple& values) { - /* - auto any_value = boost::any(values); - auto obj = std::make_tuple(into, any_value); - return inserted_query_queue.push(); - */ - } + const boost::fusion::vector& value) {} template + virtual + bool insert(const mona_string& into, + const boost::any& value, + base_type::enable_if_T_is_U*& = enabler) {} + + /** + * @brief query_concept を満たすクラスはこの関数と同じ型、名前を持つ関数を持っていなければならない。 + * @return 引数で指定したテーブルの要素から、テンプレートで指定した方に変換された値が返される。 + */ + template T select(const mona_string& column, const mona_string& from) const noexcept {} + template + boost::any select(const mona_string& column, + const mona_string& from, + base_type::enable_if_T_is_U*& = enabler) const noexcept {} + template - std::tuple + boost::fusion::vector select_all(const mona_string& from) const noexcept {} - + void exec_inserted_query(); bool load_file(const boost::filesystem::path& file_path, const mona_string& loaded_table_name); @@ -55,11 +78,15 @@ public: const mona_string& saved_table_name); private: + void get_object_expressing_into_path_in_query(const mona_string& src, + const boost::any& value); + void analyze_into_path_in_query(const mona_string& into_path_in_query); + static self_type *instance; struct model_pimpl; std::shared_ptr pimpl; - boost::lockfree::queue inserted_query_queue; + boost::lockfree::queue query_queue; }; template <>