Fawkes API Fawkes Development Version
feature_blackboard.h
1
2/***************************************************************************
3 * feature_blackboard.h - CLIPS blackboard feature
4 *
5 * Created: Thu Oct 03 11:46:20 2013
6 * Copyright 2006-2013 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Library General Public License for more details.
19 *
20 * Read the full text in the LICENSE.GPL file in the doc directory.
21 */
22
23#ifndef _PLUGINS_CLIPS_FEATURE_BLACKBOARD_H_
24#define _PLUGINS_CLIPS_FEATURE_BLACKBOARD_H_
25
26#include <clipsmm/value.h>
27#include <plugins/clips/aspect/clips_feature.h>
28
29#include <list>
30#include <map>
31#include <string>
32
33namespace CLIPS {
34class Environment;
35}
36
37namespace fawkes {
38class BlackBoard;
39class Logger;
40class Interface;
41class Message;
42class InterfaceFieldIterator;
43} // namespace fawkes
44
46{
47public:
49 fawkes::BlackBoard *blackboard,
50 bool retract_early);
52
53 // for CLIPSFeature
54 virtual void clips_context_init(const std::string & env_name,
56 virtual void clips_context_destroyed(const std::string &env_name);
57
58private: // members
59 fawkes::Logger * logger_;
60 fawkes::BlackBoard *blackboard_;
61 bool cfg_retract_early_;
62
63 typedef std::map<std::string, std::list<fawkes::Interface *>> InterfaceMap;
64 typedef struct
65 {
66 InterfaceMap reading;
67 InterfaceMap writing;
68 } Interfaces;
69 std::map<std::string, Interfaces> interfaces_;
70 std::map<std::string, fawkes::LockPtr<CLIPS::Environment>> envs_;
71 //which created message belongs to which interface
72 std::map<fawkes::Message *, fawkes::Interface *> interface_of_msg_;
73
74private: // methods
75 void clips_blackboard_open_interface(const std::string &env_name,
76 const std::string &type,
77 const std::string &id,
78 bool writing);
79 void clips_blackboard_open_interface_reading(const std::string &env_name,
80 const std::string &type,
81 const std::string &id);
82 void clips_blackboard_open_interface_writing(const std::string &env_name,
83 const std::string &type,
84 const std::string &id);
85 void clips_blackboard_close_interface(const std::string &env_name,
86 const std::string &type,
87 const std::string &id);
88 void clips_blackboard_read(const std::string &env_name);
89 void clips_blackboard_write(const std::string &env_name, const std::string &uid);
90
91 void clips_blackboard_enable_time_read(const std::string &env_name);
92 void clips_blackboard_get_info(const std::string &env_name);
93 bool clips_assert_interface_type(const std::string &env_name,
94 const std::string &log_name,
95 fawkes::Interface *iface,
96 const std::string &type);
97 void clips_blackboard_preload(const std::string &env_name, const std::string &type);
98 void clips_blackboard_set(const std::string &env_name,
99 const std::string &uid,
100 const std::string &field,
101 CLIPS::Value value);
102 void clips_blackboard_set_multifield(const std::string &env_name,
103 const std::string &uid,
104 const std::string &field,
105 CLIPS::Values values);
106 CLIPS::Value clips_blackboard_create_msg(const std::string &env_name,
107 const std::string &uid,
108 const std::string &msg_type);
109 CLIPS::Values clips_blackboard_list_msg_fields(const std::string &env_name, void *msgptr);
110
111 void clips_blackboard_set_msg_field(const std::string &env_name,
112 void * msgptr,
113 const std::string &field_name,
114 CLIPS::Value value);
115 void clips_blackboard_set_msg_multifield(const std::string &env_name,
116 void * msgptr,
117 const std::string &field_name,
118 CLIPS::Values values);
119 CLIPS::Value clips_blackboard_send_msg(const std::string &env_name, void *msgptr);
120
121 //helper
122 bool set_field(fawkes::InterfaceFieldIterator fit_begin,
124 const std::string & env_name,
125 const std::string & field,
126 CLIPS::Value value,
127 int index = 0);
128 bool set_multifield(fawkes::InterfaceFieldIterator fit_begin,
130 const std::string & env_name,
131 const std::string & field,
132 CLIPS::Values values);
133};
134
135#endif
CLIPS blackboard feature.
virtual void clips_context_destroyed(const std::string &env_name)
Notification that a CLIPS environment has been destroyed.
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 ~BlackboardCLIPSFeature()
Destructor.
BlackboardCLIPSFeature(fawkes::Logger *logger, fawkes::BlackBoard *blackboard, bool retract_early)
Constructor.
Environment representation for JSON transfer.
Definition: Environment.h:28
The BlackBoard abstract class.
Definition: blackboard.h:46
CLIPS feature maintainer.
Definition: clips_feature.h:42
Interface field iterator.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
Interface for logging.
Definition: logger.h:42
Fawkes library namespace.