Fawkes API  Fawkes Development Version
clips_env_manager.h
1 
2 /***************************************************************************
3  * clips_env_manager.h - CLIPS environment manager
4  *
5  * Created: Thu Aug 15 18:55:32 2013
6  * Copyright 2006-2014 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version. A runtime exception applies to
13  * this software (see LICENSE.GPL_WRE file mentioned below for details).
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_WRE file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_CLIPS_ASPECT_CLIPS_ENV_MANAGER_H_
24 #define __PLUGINS_CLIPS_ASPECT_CLIPS_ENV_MANAGER_H_
25 
26 #include <core/utils/lockptr.h>
27 #include <string>
28 #include <map>
29 #include <list>
30 
31 #include <clipsmm.h>
32 
33 namespace fawkes {
34 #if 0 /* just to make Emacs auto-indent happy */
35 }
36 #endif
37 
38 class Logger;
39 class Clock;
40 class CLIPSFeature;
41 
43 {
44  public:
45  CLIPSEnvManager(Logger *logger, Clock *clock, std::string &clips_dir);
46  virtual ~CLIPSEnvManager();
47 
49  create_env(const std::string &env_name, const std::string &log_component_name);
50  void destroy_env(const std::string &env_name);
51 
52  void add_features(const std::list<CLIPSFeature *> &features);
53  void remove_features(const std::list<CLIPSFeature *> &features);
54  void assert_can_remove_features(const std::list<CLIPSFeature *> &features);
55 
56  std::map<std::string, LockPtr<CLIPS::Environment>> environments() const;
57 
58  private:
59  LockPtr<CLIPS::Environment> new_env(const std::string &log_component_name);
60  void assert_features(LockPtr<CLIPS::Environment> &clips, bool immediate_assert);
61  void add_functions(const std::string &env_name, LockPtr<CLIPS::Environment> &clips);
62  CLIPS::Value clips_request_feature(std::string env_name, std::string feature_name);
63  CLIPS::Values clips_now();
64  void guarded_load(const std::string &env_name, const std::string &filename);
65 
66 
67  private:
68  Logger *logger_;
69  Clock *clock_;
70 
71  std::string clips_dir_;
72 
73  /// @cond INTERNAL
74  typedef struct {
76  std::list<std::string> req_feat;
77  } ClipsEnvData;
78  /// @endcond
79 
80  std::map<std::string, ClipsEnvData > envs_;
81  std::map<std::string, CLIPSFeature * > features_;
82 };
83 
84 } // end namespace fawkes
85 
86 #endif
void remove_features(const std::list< CLIPSFeature *> &features)
Remove a feature by name.
virtual ~CLIPSEnvManager()
Destructor.
Fawkes library namespace.
CLIPSEnvManager(Logger *logger, Clock *clock, std::string &clips_dir)
Constructor.
This is supposed to be the central clock in Fawkes.
Definition: clock.h:34
void destroy_env(const std::string &env_name)
Destroy the named environment.
void add_features(const std::list< CLIPSFeature *> &features)
Add a feature by name.
void assert_can_remove_features(const std::list< CLIPSFeature *> &features)
Assert that a feature can be removed.
LockPtr< CLIPS::Environment > create_env(const std::string &env_name, const std::string &log_component_name)
Create a new environment.
std::map< std::string, LockPtr< CLIPS::Environment > > environments() const
Get map of environments.
CLIPS environment manager.
Interface for logging.
Definition: logger.h:34