Fawkes API  Fawkes Development Version
openprs_manager_inifin.cpp
1 
2 /***************************************************************************
3  * openprs_manager_inifin.cpp - OpenPRSManagerAspect initializer/finalizer
4  *
5  * Created: Mon Aug 18 15:21:24 2014
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/openprs/aspect/openprs_manager_inifin.h>
25 #include <plugins/openprs/aspect/openprs_kernel_manager.h>
26 #include <core/threading/thread_finalizer.h>
27 
28 namespace fawkes {
29 #if 0 /* just to make Emacs auto-indent happy */
30 }
31 #endif
32 
33 /** @class OpenPRSManagerAspectIniFin <plugins/clips/aspect/clips_feature_inifin.h>
34  * OpenPRSManagerAspect initializer/finalizer.
35  * @author Tim Niemueller
36  */
37 
38 /** Constructor. */
40  : AspectIniFin("OpenPRSManagerAspect")
41 {
42 }
43 
44 /** Destructor. */
46 {
47 }
48 
49 
50 
51 void
53 {
54  OpenPRSManagerAspect *openprs_thread;
55  openprs_thread = dynamic_cast<OpenPRSManagerAspect *>(thread);
56  if (openprs_thread == NULL) {
57  throw CannotInitializeThreadException("Thread '%s' claims to have the "
58  "OpenPRSManagerAspect, but RTTI says it "
59  "has not. ", thread->name());
60  }
61 
62  openprs_thread->openprs_kernel_mgr = openprs_kernel_mgr_;
63 }
64 
65 
66 void
68 {
69  OpenPRSManagerAspect *openprs_thread;
70  openprs_thread = dynamic_cast<OpenPRSManagerAspect *>(thread);
71  if (openprs_thread == NULL) {
72  throw CannotFinalizeThreadException("Thread '%s' claims to have the "
73  "OpenPRSManagerAspect, but RTTI says it "
74  "has not. ", thread->name());
75  }
76 
77  openprs_thread->openprs_kernel_mgr.clear();
78 }
79 
80 
81 
82 /** Set OpenPRS environment manger.
83  * @param openprs_kernel_mgr OpenPRS kernel manager
84  */
85 void
87 {
88  openprs_kernel_mgr_ = openprs_kernel_mgr;
89 }
90 
91 } // end namespace fawkes
virtual void init(Thread *thread)
Initialize thread.
Fawkes library namespace.
virtual void finalize(Thread *thread)
Finalize thread.
void set_manager(LockPtr< OpenPRSKernelManager > &clips_kernel_mgr)
Set OpenPRS environment manger.
Thread class encapsulation of pthreads.
Definition: thread.h:42
LockPtr<> is a reference-counting shared lockable smartpointer.
Definition: lockptr.h:57
Thread cannot be initialized.
const char * name() const
Get name of thread.
Definition: thread.h:95
Thread aspect access the OpenPRS kernel manager.
LockPtr< OpenPRSKernelManager > openprs_kernel_mgr
OpenPRS kenerl manager.
Thread cannot be finalized.
Aspect initializer/finalizer base class.
Definition: inifin.h:36