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 <plugins/clips/aspect/clips_feature.h>
27 
28 #include <map>
29 #include <list>
30 #include <string>
31 
32 #include <clipsmm/value.h>
33 
34 namespace CLIPS {
35  class Environment;
36 }
37 
38 namespace fawkes {
39  class BlackBoard;
40  class Logger;
41  class Interface;
42  class Message;
43  class InterfaceFieldIterator;
44 }
45 
47 {
48  public:
50  virtual ~BlackboardCLIPSFeature();
51 
52  // for CLIPSFeature
53  virtual void clips_context_init(const std::string &env_name,
55  virtual void clips_context_destroyed(const std::string &env_name);
56 
57  private: // members
58  fawkes::Logger *logger_;
59  fawkes::BlackBoard *blackboard_;
60 
61  typedef std::map<std::string, std::list<fawkes::Interface *> > InterfaceMap;
62  typedef struct {
63  InterfaceMap reading;
64  InterfaceMap writing;
65  } Interfaces;
66  std::map<std::string, Interfaces > interfaces_;
67  std::map<std::string, fawkes::LockPtr<CLIPS::Environment> > envs_;
68  //which created message belongs to which interface
69  std::map<fawkes::Message*, fawkes::Interface*> interface_of_msg_;
70 
71  private: // methods
72  void clips_blackboard_open_interface(std::string env_name,
73  std::string type, std::string id,
74  bool writing);
75  void clips_blackboard_open_interface_reading(std::string env_name,
76  std::string type, std::string id);
77  void clips_blackboard_open_interface_writing(std::string env_name,
78  std::string type, std::string id);
79  void clips_blackboard_close_interface(std::string env_name,
80  std::string type, std::string id);
81  void clips_blackboard_read(std::string env_name);
82  void clips_blackboard_write(std::string env_name, std::string uid);
83 
84  void clips_blackboard_enable_time_read(std::string env_name);
85  void clips_blackboard_get_info(std::string env_name);
86  bool clips_assert_interface_type(std::string &env_name, std::string &log_name,
87  fawkes::Interface *iface, std::string &type);
88  void clips_blackboard_preload(std::string env_name, std::string type);
89  void clips_blackboard_set(std::string env_name, std::string uid,
90  std::string field, CLIPS::Value value);
91  void clips_blackboard_set_multifield(std::string env_name, std::string uid,
92  std::string field, CLIPS::Values values);
93  CLIPS::Value clips_blackboard_create_msg(std::string env_name, std::string uid,
94  std::string msg_type);
95  CLIPS::Values clips_blackboard_list_msg_fields(std::string env_name, void *msgptr);
96 
97  void clips_blackboard_set_msg_field(std::string env_name, void *msgptr,
98  std::string field_name, CLIPS::Value value);
99  void clips_blackboard_set_msg_multifield(std::string env_name, void *msgptr,
100  std::string field_name, CLIPS::Values values);
101  CLIPS::Value clips_blackboard_send_msg(std::string env_name, void *msgptr);
102 
103  //helper
104  bool set_field(fawkes::InterfaceFieldIterator fit_begin,
106  std::string env_name, std::string field, CLIPS::Value value,
107  int index = 0);
108  bool set_multifield(fawkes::InterfaceFieldIterator fit_begin,
110  std::string env_name, std::string field, CLIPS::Values values);
111 };
112 
113 #endif
Interface field iterator.
Fawkes library namespace.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
CLIPS blackboard feature.
CLIPS feature maintainer.
Definition: clips_feature.h:41
Definition: clips.h:32
The BlackBoard abstract class.
Definition: blackboard.h:48
Interface for logging.
Definition: logger.h:34