Fawkes API  Fawkes Development Version
clips.cpp
1 
2 /***************************************************************************
3  * clips.cpp - CLIPS aspect for Fawkes
4  *
5  * Created: Sat Jun 16 14:30:44 2012
6  * Copyright 2006-2012 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.h>
25 #include <clipsmm.h>
26 
27 namespace fawkes {
28 #if 0 /* just to make Emacs auto-indent happy */
29 }
30 #endif
31 
32 /** @class CLIPSAspect <plugins/clips/aspect/clips.h>
33  * Thread aspect to get access to a CLIPS environment.
34  * Give this aspect to your thread to get a CLIPS environment for exclusive
35  * usage.
36  *
37  * @ingroup Aspects
38  * @author Tim Niemueller
39  */
40 
41 /** @var fawkes:LockPtr<CLIPS::Environment> CLIPSAspect::clips
42  * CLIPS environment for exclusive usage.
43  */
44 
45 /** @var const std::string CLIPSAspect::clips_env_name
46  * CLIPS environment name.
47  */
48 
49 /** Constructor.
50  * @param env_name CLIPS environment name, the environment name is
51  * unique, if you request an environment already occupied by another
52  * the @p exclusive parameter defines whether an error is thrown or if
53  * the environment is shared
54  * @param log_component_name a component name that is shown in log
55  * messages. It is strongly recommended to set this to something
56  * unique. If left out will be set to "CLIPS[env_name]".
57  */
58 CLIPSAspect::CLIPSAspect(const char *env_name, const char *log_component_name)
59  : clips_env_name(env_name),
60  CLIPSAspect_log_component_name_(log_component_name)
61 {
62  add_aspect("CLIPSAspect");
63 }
64 
65 
66 /** Virtual empty destructor. */
68 {
69 }
70 
71 
72 /** Init CLIPS aspect.
73  * This set the CLIPS environment.
74  * It is guaranteed that this is called for a CLIPS Thread before start
75  * is called (when running regularly inside Fawkes).
76  * @param clips CLIPS environment
77  */
78 void
79 CLIPSAspect::init_CLIPSAspect(LockPtr<CLIPS::Environment> clips)
80 {
81  this->clips = clips;
82 }
83 
84 /** Finalize CLIPS aspect.
85  * This clears the CLIPS environment.
86  */
87 void
88 CLIPSAspect::finalize_CLIPSAspect()
89 {
90  clips.clear();
91 }
92 
93 
94 } // end namespace fawkes
Fawkes library namespace.
virtual ~CLIPSAspect()
Virtual empty destructor.
Definition: clips.cpp:67
void add_aspect(const char *name)
Add an aspect to a thread.
Definition: aspect.cpp:52
CLIPSAspect(const char *env_name, const char *log_component_name=0)
Constructor.
Definition: clips.cpp:58
LockPtr< CLIPS::Environment > clips
CLIPS environment for exclusive usage.
Definition: clips.h:51
void clear()
Set underlying instance to 0, decrementing reference count of existing instance appropriately.
Definition: lockptr.h:492