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 <core/threading/thread_finalizer.h>
25#include <plugins/clips/aspect/clips_env_manager.h>
26#include <plugins/clips/aspect/clips_manager_inifin.h>
27
28#include <clipsmm.h>
29
30namespace fawkes {
31
32/** @class CLIPSManagerAspectIniFin <plugins/clips/aspect/clips_feature_inifin.h>
33 * CLIPSManagerAspect initializer/finalizer.
34 * @author Tim Niemueller
35 */
36
37/** Constructor. */
39{
40}
41
42/** Destructor. */
44{
45}
46
47void
49{
50 CLIPSManagerAspect *clips_thread;
51 clips_thread = dynamic_cast<CLIPSManagerAspect *>(thread);
52 if (clips_thread == NULL) {
53 throw CannotInitializeThreadException("Thread '%s' claims to have the "
54 "CLIPSManagerAspect, but RTTI says it "
55 "has not. ",
56 thread->name());
57 }
58
59 clips_thread->clips_env_mgr = clips_env_mgr_;
60}
61
62void
64{
65 CLIPSManagerAspect *clips_thread;
66 clips_thread = dynamic_cast<CLIPSManagerAspect *>(thread);
67 if (clips_thread == NULL) {
68 throw CannotFinalizeThreadException("Thread '%s' claims to have the "
69 "CLIPSManagerAspect, but RTTI says it "
70 "has not. ",
71 thread->name());
72 }
73
74 clips_thread->clips_env_mgr.clear();
75}
76
77/** Set CLIPS environment manger.
78 * @param clips_env_mgr CLIPS environment manager
79 */
80void
82{
83 clips_env_mgr_ = clips_env_mgr;
84}
85
86} // end namespace fawkes
Aspect initializer/finalizer base class.
Definition: inifin.h:34
virtual void init(Thread *thread)
Initialize thread.
virtual void finalize(Thread *thread)
Finalize thread.
void set_manager(LockPtr< CLIPSEnvManager > &clips_env_mgr)
Set CLIPS environment manger.
Thread aspect access the CLIPS environment manager.
Definition: clips_manager.h:36
LockPtr< CLIPSEnvManager > clips_env_mgr
CLIPS environment manager.
Definition: clips_manager.h:44
Thread cannot be finalized.
LockPtr<> is a reference-counting shared lockable smartpointer.
Definition: lockptr.h:55
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
Fawkes library namespace.