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> 71 std::map<std::string, fawkes::LockPtr<CLIPS::Environment>> envs_;
73 CLIPS::Value clips_bson_create();
74 CLIPS::Value clips_bson_parse(std::string document);
75 void clips_bson_destroy(
void *bson);
76 void clips_bson_append(
void *bson, std::string field_name, CLIPS::Value value);
77 void clips_bson_append_array(
void *bson, std::string field_name, CLIPS::Values values);
78 void clips_bson_append_time(
void *bson, std::string field_name, CLIPS::Values time);
79 CLIPS::Value clips_bson_array_start(
void *bson, std::string field_name);
80 void clips_bson_array_finish(
void *barr);
81 void clips_bson_array_append(
void *barr, CLIPS::Value value);
82 std::string clips_bson_tostring(
void *bson);
83 CLIPS::Values clips_bson_field_names(
void *bson);
84 CLIPS::Value clips_bson_has_field(
void *bson, std::string field_name);
85 CLIPS::Value clips_bson_get(
void *bson, std::string field_name);
86 CLIPS::Values clips_bson_get_array(
void *bson, std::string field_name);
87 CLIPS::Values clips_bson_get_time(
void *bson, std::string field_name);
89 void clips_robotmemory_upsert(std::string collection,
void *bson, CLIPS::Value query);
90 void clips_robotmemory_update(std::string collection,
void *bson, CLIPS::Value query);
91 void clips_robotmemory_replace(std::string collection,
void *bson, CLIPS::Value query);
92 void clips_robotmemory_insert(std::string collection,
void *bson);
93 void clips_robotmemory_create_index(std::string collection,
void *bson);
94 void clips_robotmemory_create_unique_index(std::string collection,
void *bson);
96 robotmemory_update(std::string &collection, mongo::BSONObj obj, CLIPS::Value &query,
bool upsert);
97 CLIPS::Value clips_robotmemory_query_sort(std::string collection,
void *bson,
void *bson_sort);
98 CLIPS::Value clips_robotmemory_query(
const std::string &collection,
void *bson);
99 void clips_robotmemory_remove(std::string collection,
void *bson);
100 CLIPS::Value clips_robotmemory_cursor_more(
void *cursor);
101 CLIPS::Value clips_robotmemory_cursor_next(
void *cursor);
102 void clips_robotmemory_cursor_destroy(
void *cursor);
104 CLIPS::Value clips_robotmemory_mutex_create(std::string
name);
105 CLIPS::Value clips_robotmemory_mutex_destroy(std::string
name);
106 CLIPS::Value clips_robotmemory_mutex_try_lock(std::string
name, std::string identity);
107 CLIPS::Value clips_robotmemory_mutex_renew_lock(std::string
name, std::string identity);
108 CLIPS::Value clips_robotmemory_mutex_force_lock(std::string
name, std::string identity);
109 CLIPS::Value clips_robotmemory_mutex_unlock(std::string
name, std::string identity);
110 CLIPS::Value clips_robotmemory_mutex_setup_ttl(
float max_age_sec);
111 CLIPS::Value clips_robotmemory_mutex_expire_locks(
float max_age_sec);
113 CLIPS::Values clips_robotmemory_mutex_create_async(std::string
name);
114 CLIPS::Values clips_robotmemory_mutex_destroy_async(std::string
name);
115 CLIPS::Values clips_robotmemory_mutex_try_lock_async(std::string env_name,
117 std::string identity);
118 CLIPS::Values clips_robotmemory_mutex_renew_lock_async(std::string env_name,
120 std::string identity);
121 CLIPS::Values clips_robotmemory_mutex_force_lock_async(std::string
name, std::string identity);
122 CLIPS::Values clips_robotmemory_mutex_unlock_async(std::string
name, std::string identity);
123 CLIPS::Value clips_robotmemory_mutex_expire_locks_async(std::string env_name,
float max_age_sec);
125 CLIPS::Value clips_robotmemory_register_trigger(std::string env_name,
126 std::string collection,
128 std::string assert_name);
129 void clips_robotmemory_destroy_trigger(
void *trigger);
131 bool mutex_future_ready(
const std::string &
name);
134 std::list<ClipsRmTrigger *> clips_triggers_;
135 std::map<std::string, std::future<bool>> mutex_futures_;
136 std::future<bool> mutex_expire_future_;
Thread aspect to provide a feature to CLIPS environments.
Thread aspect to get access to a the RobotMemory.
virtual void finalize()
Finalize the thread.
Fawkes library namespace.
virtual void loop()
Code to execute in the thread.
Thread class encapsulation of pthreads.
CLIPS feature to access the robot memory.
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.
CLIPS feature maintainer.
const char * name() const
Get name of thread.
Thread aspect to log output.
Thread aspect to access configuration data.
virtual void clips_context_destroyed(const std::string &env_name)
Notification that a CLIPS environment has been destroyed.
virtual void init()
Initialize the thread.