Fawkes API  Fawkes Development Version
clips_feature.cpp
1 
2 /***************************************************************************
3  * clips_feature.cpp - CLIPS feature aspect for Fawkes
4  *
5  * Created: Thu Jul 25 17:37:58 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. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <plugins/clips/aspect/clips_feature.h>
25 #include <clipsmm.h>
26 
27 namespace fawkes {
28 #if 0 /* just to make Emacs auto-indent happy */
29 }
30 #endif
31 
32 
33 /** @class CLIPSFeature <plugins/clips/aspect/clips_feature.h>
34  * CLIPS feature maintainer.
35  * Instances of this class are called to initialize or finalize CLIPS
36  * feature requests.
37  *
38  * @author Tim Niemueller
39  */
40 
41 /** Constructor.
42  * @param feature_name name of the feature
43  */
44 CLIPSFeature::CLIPSFeature(const char *feature_name)
45  : clips_feature_name(feature_name)
46 {
47 }
48 
49 
50 /** Virtual empty constructor. */
52 {
53 }
54 
55 /** @fn void CLIPSFeature::clips_context_init(const std::string &env_name, fawkes::LockPtr<CLIPS::Environment> &clips) = 0
56  * Initialize a CLIPS context to use the provided feature.
57  * This method must be implemented by threads with the
58  * CLIPSFeatureAspect. It is called to initialize a particular CLIPS
59  * environment that requests to use the provided feature.
60  * @param env_name name of CLIPS environment to initialized.
61  * @param clips CLIPS environment to initialize
62  */
63 
64 /** @fn void CLIPSFeature::clips_context_destroyed(const std::string &env_name) = 0
65  * Notification that a CLIPS environment has been destroyed.
66  * At this time the CLIPS environment can no longer be accessed. But the
67  * event can be used to free internal resources that were associated with
68  * the environment.
69  * @param env_name name of destroyed CLIPS environment
70  */
71 
72 
73 /** @class CLIPSFeatureAspect <plugins/clips/aspect/clips_feature.h>
74  * Thread aspect to provide a feature to CLIPS environments.
75  * Give this aspect to your thread if you want to provide a CLIPS
76  * feature (library) to other threads which have the CLIPSAspect.
77  *
78  * @ingroup Aspects
79  * @author Tim Niemueller
80  */
81 
82 /** Constructor.
83  * @param feature CLIPS feature maintainer
84  */
86 {
87  add_aspect("CLIPSFeatureAspect");
88  clips_features_.push_back(feature);
89 }
90 
91 /** Constructor for multiple features.
92  * @param features CLIPS feature maintainers
93  */
94 CLIPSFeatureAspect::CLIPSFeatureAspect(const std::list<CLIPSFeature *> features)
95 {
96  add_aspect("CLIPSFeatureAspect");
97  clips_features_ = features;
98 }
99 
100 
101 /** Virtual empty destructor. */
103 {
104  clips_features_.clear();
105 }
106 
107 } // end namespace fawkes
Fawkes library namespace.
CLIPSFeatureAspect(CLIPSFeature *feature)
Constructor.
virtual ~CLIPSFeatureAspect()
Virtual empty destructor.
CLIPS feature maintainer.
Definition: clips_feature.h:41
virtual ~CLIPSFeature()
Virtual empty constructor.
CLIPSFeature(const char *feature_name)
Constructor.