OSDN Git Service

[core] :
authorcaprice <caprice@users.sourceforge.jp>
Tue, 23 Jul 2013 13:03:22 +0000 (22:03 +0900)
committercaprice <caprice@users.sourceforge.jp>
Tue, 23 Jul 2013 13:03:22 +0000 (22:03 +0900)
色々考えあぐねた結果、query_conceptを満たすクラスがinsert()とselect()というメンバ関数を持つ事にして決着させた。
query_conceptの要件について追加。

core/include/query.hpp

index 1b5b1bb..1f0c415 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef GIKOMONA_CORE_QUERY_HPP_INCLUDED
 #define GIKOMONA_CORE_QUERY_HPP_INCLUDED
 
+#include <tuple>
 #include <vector>
 
 #include <boost/mpl/bool.hpp>
 
 namespace monazilla { namespace GikoMona { namespace core {
    
+template <typename T>
+struct is_satisfied_with_query_concept : public boost::mpl::false_ {};
+
 /**
- * @note このクラスは boost::lockfree::queue<> の制約から
- *       trivially copyable の要件を満たす必要がある。
- *       (参考:http://d.hatena.ne.jp/faith_and_brave/20130213/1360737911 )
+ *  @brief このクラスでは query_concept が満たすべき用件が記述されている。
  */
-
-class query final {
+class query_concept final {
 public:
-    // query order
-    class select_ final {
-        friend class query;
-        select_() {}
-        ~select_() {}
-    public:
-        struct select_all_column {} all_columnes;
+    /// query_concept を満たすクラスは自分自身の型を self_type として表明しなければならない。
+    typedef query_concept self_type;
     
-        select_& distinct() {}
-        select_& group_by() {}
-        select_& where() {}
-        select_& having() {}
-    };
-
-public:
-    typedef std::vector<mona_string> column_name_list;
+    /// query_concept を満たすクラスは外部から構築可能でなければならない。
+    query_concept() {}
+    /// query_concept を満たすクラスは外部から解体可能でなければならない。
+    ~query_concept() {}
     
-    query(mona_string) {}
-    ~query() = default;
+    /**
+     *  @breif query_concept を満たすクラスはこの関数と同じ型、名前を持つ関数を持っていなければならない。
+     *  @retval true insert 操作が成功した
+     *          false insert 操作に失敗した
+     *  @param[in] into どのテーブルのどの要素に対し insertion query を実行するかを記述する。
+     *                  記述の仕方は次の通り:(テーブル名)/[(サブテーブル名)/]*(要素名)
+     *  @param[in] value テーブルに対して代入する値を記述する。
+     *  @note さらに、最大限 multi-threading な環境を考慮しなければならない。
+     */
+    template <typename ...ValueType,
+              typename ArgType = std::tuple<ValueType...>>
+    bool insert(const mona_string& into, const Argtype& value) {}
     
-    query& define() { return (*this); }
-    select_ select(const column_name_list& columnes,
-                    const mona_string& from) {
-        return select_();
-    }
-    select_ select(typename select_::select_all_column dummy,
-                    const mona_string& from) {
-        return select_();
-    }
-    query& insert(const mona_string& into) {}
-
-private:
-
+    /**
+     *  @brief query_concept を満たすクラスはこの関数と同じ型、名前を持つ関数を持っていなければならない。
+     *  @return 引数で指定したテーブルの要素から、テンプレートで指定した方に変換された値が返される。
+     */
+    template <typename T>
+    T select() const noexcept {}
 };
 
-template <typename T>
-struct is_responsible_to_query : public boost::mpl::false_ {};
-
 } } }
 
 #endif
\ No newline at end of file