#include <unistd.h>
+#include <boost/any.hpp>
#include <boost/lockfree/queue.hpp>
#include <boost/filesystem/path.hpp>
#include "config.hpp"
namespace monazilla { namespace GikoMona { namespace core {
-
+
class model {
public:
typedef model self_type;
+ typedef std::tuple<mona_string, boost::any> inserted_query_type;
+ typedef inserted_query_type *inserted_query_triv_copyable_type;
model() noexcept {
instance = this;
return instance;
}
- bool push_query_in_queue(const query& src) {
- return query_queue.push(src);
+ template <typename ...ValueType>
+ bool insert(const mona_string& into,
+ const std::tuple<ValueType...>& values) {
+ return inserted_query_queue.push(new inserted_query_type(into, boost::any(values)));
}
- template <typename ResultType>
- ResultType pop_query() {
- exec_all_query();
- }
+ template <typename T>
+ T select() {}
- bool load_file(const boost::filesystem::path& file_path);
+ void exec_inserted_query();
+ bool load_file(const boost::filesystem::path& file_path,
+ const mona_string& loaded_table_name);
bool save_to_file(const boost::filesystem::path& file_path,
const mona_string& saved_table_name);
private:
static self_type *instance;
- database db;
+ database history_db;
config app_config;
- boost::lockfree::queue<query> query_queue;
-
- void exec_all_query() {
- query val("");
- while(!query_queue.empty()) {
- if(!query_queue.pop(val)) { continue; }
- // valの処理
- }
- }
+ boost::lockfree::queue<inserted_query_triv_copyable_type> inserted_query_queue;
};
-void post_query_to_model(const query& src) {
- model *obj = model::get_instance();
- while(!obj->push_query_in_queue(src)) {
- ::sleep(10);
- }
+template <>
+struct is_satisfied_with_query_concept<model> : public boost::mpl::true_ {};
+
+void exec_insert_query() {
+ model::get_instance()->exec_insert_query();
}
} } }