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();
82 void clips_bson_array_finish(
void *bson, std::string field_name,
void *array);
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);
107 CLIPS::Value clips_robotmemory_dump_collection(std::string collection, std::string directory);
108 CLIPS::Value clips_robotmemory_restore_collection(std::string collection,
109 std::string directory,
110 std::string target_collection);
112 CLIPS::Value clips_robotmemory_mutex_create(std::string
name);
113 CLIPS::Value clips_robotmemory_mutex_destroy(std::string
name);
114 CLIPS::Value clips_robotmemory_mutex_try_lock(std::string
name, std::string identity);
115 CLIPS::Value clips_robotmemory_mutex_renew_lock(std::string
name, std::string identity);
116 CLIPS::Value clips_robotmemory_mutex_force_lock(std::string
name, std::string identity);
117 CLIPS::Value clips_robotmemory_mutex_unlock(std::string
name, std::string identity);
118 CLIPS::Value clips_robotmemory_mutex_setup_ttl(
float max_age_sec);
119 CLIPS::Value clips_robotmemory_mutex_expire_locks(
float max_age_sec);
121 CLIPS::Values clips_robotmemory_mutex_create_async(std::string
name);
122 CLIPS::Values clips_robotmemory_mutex_destroy_async(std::string
name);
123 CLIPS::Values clips_robotmemory_mutex_try_lock_async(std::string env_name,
125 std::string identity);
126 CLIPS::Values clips_robotmemory_mutex_renew_lock_async(std::string env_name,
128 std::string identity);
129 CLIPS::Values clips_robotmemory_mutex_force_lock_async(std::string
name, std::string identity);
130 CLIPS::Values clips_robotmemory_mutex_unlock_async(std::string
name, std::string identity);
131 CLIPS::Value clips_robotmemory_mutex_expire_locks_async(std::string env_name,
float max_age_sec);
133 CLIPS::Value clips_robotmemory_register_trigger(std::string env_name,
134 std::string collection,
136 std::string assert_name);
137 void clips_robotmemory_destroy_trigger(
void *trigger);
139 bool mutex_future_ready(
const std::string &
name);
142 std::list<ClipsRmTrigger *> clips_triggers_;
144 std::map<std::string, std::future<bool>> mutex_futures_;
145 std::future<bool> mutex_expire_future_;
CLIPS feature to access the robot memory.
virtual void loop()
Code to execute in the thread.
virtual void finalize()
Finalize the thread.
virtual void clips_context_destroyed(const std::string &env_name)
Notification that a CLIPS environment has been destroyed.
virtual void init()
Initialize the thread.
virtual void clips_context_init(const std::string &env_name, fawkes::LockPtr< CLIPS::Environment > &clips)
Initialize a CLIPS context to use the provided feature.
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread aspect to provide a feature to CLIPS environments.
CLIPS feature maintainer.
Thread aspect to access configuration data.
Thread aspect to log output.
Mutex mutual exclusion lock.
Thread aspect to get access to a the RobotMemory.
Thread class encapsulation of pthreads.
const char * name() const
Get name of thread.
Fawkes library namespace.