25 #ifndef _PLUGINS_CLIPS_ROBOT_MEMORYTHREAD_H_
26 #define _PLUGINS_CLIPS_ROBOT_MEMORYTHREAD_H_
28 #include "clips_rm_trigger.h"
30 #include <aspect/configurable.h>
31 #include <aspect/logging.h>
32 #include <core/threading/thread.h>
33 #include <plugins/clips/aspect/clips_feature.h>
34 #include <plugins/robot-memory/aspect/robot_memory_aspect.h>
36 #include <bsoncxx/document/view.hpp>
72 std::map<std::string, fawkes::LockPtr<CLIPS::Environment>> envs_;
74 CLIPS::Value clips_bson_create();
75 CLIPS::Value clips_bson_parse(std::string document);
76 void clips_bson_destroy(
void *bson);
77 void clips_bson_append(
void *bson, std::string field_name, CLIPS::Value value);
78 void clips_bson_append_regex(
void *bson, std::string field_name, CLIPS::Value regex_string);
79 void clips_bson_append_array(
void *bson, std::string field_name, CLIPS::Values values);
80 void clips_bson_append_time(
void *bson, std::string field_name, CLIPS::Values time);
81 CLIPS::Value clips_bson_array_start(
void *bson, std::string field_name);
82 void clips_bson_array_finish(
void *barr);
83 void clips_bson_array_append(
void *barr, CLIPS::Value value);
84 std::string clips_bson_tostring(
void *bson);
85 CLIPS::Values clips_bson_field_names(
void *bson);
86 CLIPS::Value clips_bson_has_field(
void *bson, std::string field_name);
87 CLIPS::Value clips_bson_get(
void *bson, std::string field_name);
88 CLIPS::Values clips_bson_get_array(
void *bson, std::string field_name);
89 CLIPS::Values clips_bson_get_time(
void *bson, std::string field_name);
91 void clips_robotmemory_upsert(std::string collection,
void *bson, CLIPS::Value query);
92 void clips_robotmemory_update(std::string collection,
void *bson, CLIPS::Value query);
93 void clips_robotmemory_replace(std::string collection,
void *bson, CLIPS::Value query);
94 void clips_robotmemory_insert(std::string collection,
void *bson);
95 void clips_robotmemory_create_index(std::string collection,
void *bson);
96 void clips_robotmemory_create_unique_index(std::string collection,
void *bson);
97 void robotmemory_update(std::string & collection,
98 const bsoncxx::document::view &obj,
101 CLIPS::Value clips_robotmemory_query_sort(std::string collection,
void *bson,
void *bson_sort);
102 CLIPS::Value clips_robotmemory_query(
const std::string &collection,
void *bson);
103 void clips_robotmemory_remove(std::string collection,
void *bson);
104 CLIPS::Value clips_robotmemory_cursor_more(
void *cursor);
105 CLIPS::Value clips_robotmemory_cursor_next(
void *cursor);
106 void clips_robotmemory_cursor_destroy(
void *cursor);
108 CLIPS::Value clips_robotmemory_mutex_create(std::string
name);
109 CLIPS::Value clips_robotmemory_mutex_destroy(std::string
name);
110 CLIPS::Value clips_robotmemory_mutex_try_lock(std::string
name, std::string identity);
111 CLIPS::Value clips_robotmemory_mutex_renew_lock(std::string
name, std::string identity);
112 CLIPS::Value clips_robotmemory_mutex_force_lock(std::string
name, std::string identity);
113 CLIPS::Value clips_robotmemory_mutex_unlock(std::string
name, std::string identity);
114 CLIPS::Value clips_robotmemory_mutex_setup_ttl(
float max_age_sec);
115 CLIPS::Value clips_robotmemory_mutex_expire_locks(
float max_age_sec);
117 CLIPS::Values clips_robotmemory_mutex_create_async(std::string
name);
118 CLIPS::Values clips_robotmemory_mutex_destroy_async(std::string
name);
119 CLIPS::Values clips_robotmemory_mutex_try_lock_async(std::string env_name,
121 std::string identity);
122 CLIPS::Values clips_robotmemory_mutex_renew_lock_async(std::string env_name,
124 std::string identity);
125 CLIPS::Values clips_robotmemory_mutex_force_lock_async(std::string
name, std::string identity);
126 CLIPS::Values clips_robotmemory_mutex_unlock_async(std::string
name, std::string identity);
127 CLIPS::Value clips_robotmemory_mutex_expire_locks_async(std::string env_name,
float max_age_sec);
129 CLIPS::Value clips_robotmemory_register_trigger(std::string env_name,
130 std::string collection,
132 std::string assert_name);
133 void clips_robotmemory_destroy_trigger(
void *trigger);
135 bool mutex_future_ready(
const std::string &
name);
138 std::list<ClipsRmTrigger *> clips_triggers_;
140 std::map<std::string, std::future<bool>> mutex_futures_;
141 std::future<bool> mutex_expire_future_;