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