22 #include "clips-protobuf-thread.h" 24 #include <protobuf_clips/communicator.h> 27 using namespace protobuf_clips;
36 :
Thread(
"ClipsProtobufThread",
Thread::OPMODE_WAITFORWAKEUP),
50 cfg_proto_dirs_.clear();
53 for (
size_t i = 0; i < cfg_proto_dirs_.size(); ++i) {
54 std::string::size_type pos;
55 if ((pos = cfg_proto_dirs_[i].find(
"@BASEDIR@")) != std::string::npos) {
56 cfg_proto_dirs_[i].replace(pos, 9, BASEDIR);
58 if ((pos = cfg_proto_dirs_[i].find(
"@FAWKES_BASEDIR@")) != std::string::npos) {
59 cfg_proto_dirs_[i].replace(pos, 16, FAWKES_BASEDIR);
61 if ((pos = cfg_proto_dirs_[i].find(
"@RESDIR@")) != std::string::npos) {
62 cfg_proto_dirs_[i].replace(pos, 8, RESDIR);
64 if ((pos = cfg_proto_dirs_[i].find(
"@CONFDIR@")) != std::string::npos) {
65 cfg_proto_dirs_[i].replace(pos, 9, CONFDIR);
67 if (cfg_proto_dirs_[i][cfg_proto_dirs_.size() - 1] !=
'/') {
68 cfg_proto_dirs_[i] +=
"/";
81 for (
auto pb_comm : pb_comms_) {
82 delete pb_comm.second;
94 clips->batch_evaluate(SRCDIR
"/clips/protobuf.clp");
101 if (pb_comms_.find(env_name) != pb_comms_.end()) {
102 delete pb_comms_[env_name];
103 pb_comms_.erase(env_name);
virtual void loop()
Code to execute in the thread.
Thread aspect to provide a feature to CLIPS environments.
virtual void log_info(const char *component, const char *format,...)=0
Log informational message.
virtual ~ClipsProtobufThread()
Destructor.
Fawkes library namespace.
Thread class encapsulation of pthreads.
ClipsProtobufThread()
Constructor.
Logger * logger
This is the Logger member used to access the logger.
virtual void clips_context_init(const std::string &env_name, fawkes::LockPtr< CLIPS::Environment > &clips)
Initialize a CLIPS context to use the provided feature.
Base class for exceptions in Fawkes.
Mutex * objmutex_ptr() const
Get object mutex.
virtual void init()
Initialize the thread.
CLIPS feature maintainer.
const char * name() const
Get name of thread.
virtual void log_warn(const char *component, const char *format,...)=0
Log warning message.
virtual std::vector< std::string > get_strings(const char *path)=0
Get list of values from configuration which is of type string.
virtual void clips_context_destroyed(const std::string &env_name)
Notification that a CLIPS environment has been destroyed.
Configuration * config
This is the Configuration member used to access the configuration.
virtual void finalize()
Finalize the thread.
CLIPS protobuf integration class.