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
28#include <clipsmm.h>
29#include <list>
30#include <map>
31#include <string>
32
33namespace fawkes {
34
35class Logger;
36class Clock;
37class CLIPSFeature;
38
40{
41public:
42 CLIPSEnvManager(Logger *logger, Clock *clock, std::string &clips_dir);
43 virtual ~CLIPSEnvManager();
44
45 LockPtr<CLIPS::Environment> create_env(const std::string &env_name,
46 const std::string &log_component_name);
47 void destroy_env(const std::string &env_name);
48
49 void add_features(const std::list<CLIPSFeature *> &features);
50 void remove_features(const std::list<CLIPSFeature *> &features);
51 void assert_can_remove_features(const std::list<CLIPSFeature *> &features);
52
53 std::map<std::string, LockPtr<CLIPS::Environment>> environments() const;
54
55private:
56 LockPtr<CLIPS::Environment> new_env(const std::string &log_component_name);
57 void assert_features(LockPtr<CLIPS::Environment> &clips, bool immediate_assert);
58 void add_functions(const std::string &env_name, LockPtr<CLIPS::Environment> &clips);
59 CLIPS::Value clips_request_feature(std::string env_name, std::string feature_name);
60 CLIPS::Values clips_now();
61 CLIPS::Values clips_now_systime();
62 void guarded_load(const std::string &env_name, const std::string &filename);
63 void quit();
64
65private:
66 Logger *logger_;
67 Clock * clock_;
68
69 std::string clips_dir_;
70
71 /// @cond INTERNAL
72 typedef struct
73 {
75 std::list<std::string> req_feat;
76 } ClipsEnvData;
77 /// @endcond
78
79 std::map<std::string, ClipsEnvData> envs_;
80 std::map<std::string, CLIPSFeature *> features_;
81};
82
83} // end namespace fawkes
84
85#endif
CLIPS environment manager.
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.
virtual ~CLIPSEnvManager()
Destructor.
void destroy_env(const std::string &env_name)
Destroy the named environment.
CLIPSEnvManager(Logger *logger, Clock *clock, std::string &clips_dir)
Constructor.
void add_features(const std::list< CLIPSFeature * > &features)
Add a feature by name.
void remove_features(const std::list< CLIPSFeature * > &features)
Remove a feature by name.
void assert_can_remove_features(const std::list< CLIPSFeature * > &features)
Assert that a feature can be removed.
This is supposed to be the central clock in Fawkes.
Definition: clock.h:35
Interface for logging.
Definition: logger.h:42
Fawkes library namespace.