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 
26 #include <clipsmm.h>
27 
28 namespace fawkes {
29 
30 /** @class CLIPSFeature <plugins/clips/aspect/clips_feature.h>
31  * CLIPS feature maintainer.
32  * Instances of this class are called to initialize or finalize CLIPS
33  * feature requests.
34  *
35  * @author Tim Niemueller
36  */
37 
38 /** Constructor.
39  * @param feature_name name of the feature
40  */
41 CLIPSFeature::CLIPSFeature(const char *feature_name) : clips_feature_name(feature_name)
42 {
43 }
44 
45 /** Virtual empty constructor. */
47 {
48 }
49 
50 /** @fn void CLIPSFeature::clips_context_init(const std::string &env_name, fawkes::LockPtr<CLIPS::Environment> &clips) = 0
51  * Initialize a CLIPS context to use the provided feature.
52  * This method must be implemented by threads with the
53  * CLIPSFeatureAspect. It is called to initialize a particular CLIPS
54  * environment that requests to use the provided feature.
55  * @param env_name name of CLIPS environment to initialized.
56  * @param clips CLIPS environment to initialize
57  */
58 
59 /** @fn void CLIPSFeature::clips_context_destroyed(const std::string &env_name) = 0
60  * Notification that a CLIPS environment has been destroyed.
61  * At this time the CLIPS environment can no longer be accessed. But the
62  * event can be used to free internal resources that were associated with
63  * the environment.
64  * @param env_name name of destroyed CLIPS environment
65  */
66 
67 /** @class CLIPSFeatureAspect <plugins/clips/aspect/clips_feature.h>
68  * Thread aspect to provide a feature to CLIPS environments.
69  * Give this aspect to your thread if you want to provide a CLIPS
70  * feature (library) to other threads which have the CLIPSAspect.
71  *
72  * @ingroup Aspects
73  * @author Tim Niemueller
74  */
75 
76 /** Constructor.
77  * @param feature CLIPS feature maintainer
78  */
80 {
81  add_aspect("CLIPSFeatureAspect");
82  clips_features_.push_back(feature);
83 }
84 
85 /** Constructor for multiple features.
86  * @param features CLIPS feature maintainers
87  */
88 CLIPSFeatureAspect::CLIPSFeatureAspect(const std::list<CLIPSFeature *> features)
89 {
90  add_aspect("CLIPSFeatureAspect");
91  clips_features_ = features;
92 }
93 
94 /** Virtual empty destructor. */
96 {
97  clips_features_.clear();
98 }
99 
100 } // end namespace fawkes
void add_aspect(const char *name)
Add an aspect to a thread.
Definition: aspect.cpp:49
CLIPSFeatureAspect(CLIPSFeature *feature)
Constructor.
virtual ~CLIPSFeatureAspect()
Virtual empty destructor.
CLIPS feature maintainer.
Definition: clips_feature.h:42
CLIPSFeature(const char *feature_name)
Constructor.
virtual ~CLIPSFeature()
Virtual empty constructor.
Fawkes library namespace.