Fawkes API  Fawkes Development Version
clips_manager_inifin.cpp
1 
2 /***************************************************************************
3  * clips_manager_inifin.cpp - CLIPSManagerAspect initializer/finalizer
4  *
5  * Created: Fri Aug 16 16:06:45 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_manager_inifin.h>
25 #include <plugins/clips/aspect/clips_env_manager.h>
26 #include <core/threading/thread_finalizer.h>
27 
28 #include <clipsmm.h>
29 
30 namespace fawkes {
31 #if 0 /* just to make Emacs auto-indent happy */
32 }
33 #endif
34 
35 /** @class CLIPSManagerAspectIniFin <plugins/clips/aspect/clips_feature_inifin.h>
36  * CLIPSManagerAspect initializer/finalizer.
37  * @author Tim Niemueller
38  */
39 
40 /** Constructor. */
42  : AspectIniFin("CLIPSManagerAspect")
43 {
44 }
45 
46 /** Destructor. */
48 {
49 }
50 
51 
52 
53 void
55 {
56  CLIPSManagerAspect *clips_thread;
57  clips_thread = dynamic_cast<CLIPSManagerAspect *>(thread);
58  if (clips_thread == NULL) {
59  throw CannotInitializeThreadException("Thread '%s' claims to have the "
60  "CLIPSManagerAspect, but RTTI says it "
61  "has not. ", thread->name());
62  }
63 
64  clips_thread->clips_env_mgr = clips_env_mgr_;
65 }
66 
67 
68 void
70 {
71  CLIPSManagerAspect *clips_thread;
72  clips_thread = dynamic_cast<CLIPSManagerAspect *>(thread);
73  if (clips_thread == NULL) {
74  throw CannotFinalizeThreadException("Thread '%s' claims to have the "
75  "CLIPSManagerAspect, but RTTI says it "
76  "has not. ", thread->name());
77  }
78 
79  clips_thread->clips_env_mgr.clear();
80 }
81 
82 
83 
84 /** Set CLIPS environment manger.
85  * @param clips_env_mgr CLIPS environment manager
86  */
87 void
89 {
90  clips_env_mgr_ = clips_env_mgr;
91 }
92 
93 } // end namespace fawkes
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
virtual void init(Thread *thread)
Initialize thread.
LockPtr<> is a reference-counting shared lockable smartpointer.
Definition: lockptr.h:57
Thread aspect access the CLIPS environment manager.
Definition: clips_manager.h:36
Thread cannot be initialized.
virtual void finalize(Thread *thread)
Finalize thread.
const char * name() const
Get name of thread.
Definition: thread.h:95
void set_manager(LockPtr< CLIPSEnvManager > &clips_env_mgr)
Set CLIPS environment manger.
LockPtr< CLIPSEnvManager > clips_env_mgr
CLIPS environment manager.
Definition: clips_manager.h:45
Thread cannot be finalized.
Aspect initializer/finalizer base class.
Definition: inifin.h:36