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 <core/threading/thread_finalizer.h>
25 #include <plugins/openprs/aspect/openprs_kernel_manager.h>
26 #include <plugins/openprs/aspect/openprs_manager_inifin.h>
27 
28 namespace fawkes {
29 
30 /** @class OpenPRSManagerAspectIniFin <plugins/clips/aspect/clips_feature_inifin.h>
31  * OpenPRSManagerAspect initializer/finalizer.
32  * @author Tim Niemueller
33  */
34 
35 /** Constructor. */
37 {
38 }
39 
40 /** Destructor. */
42 {
43 }
44 
45 void
47 {
48  OpenPRSManagerAspect *openprs_thread;
49  openprs_thread = dynamic_cast<OpenPRSManagerAspect *>(thread);
50  if (openprs_thread == NULL) {
51  throw CannotInitializeThreadException("Thread '%s' claims to have the "
52  "OpenPRSManagerAspect, but RTTI says it "
53  "has not. ",
54  thread->name());
55  }
56 
57  openprs_thread->openprs_kernel_mgr = openprs_kernel_mgr_;
58 }
59 
60 void
62 {
63  OpenPRSManagerAspect *openprs_thread;
64  openprs_thread = dynamic_cast<OpenPRSManagerAspect *>(thread);
65  if (openprs_thread == NULL) {
66  throw CannotFinalizeThreadException("Thread '%s' claims to have the "
67  "OpenPRSManagerAspect, but RTTI says it "
68  "has not. ",
69  thread->name());
70  }
71 
72  openprs_thread->openprs_kernel_mgr.clear();
73 }
74 
75 /** Set OpenPRS environment manger.
76  * @param openprs_kernel_mgr OpenPRS kernel manager
77  */
78 void
80 {
81  openprs_kernel_mgr_ = openprs_kernel_mgr;
82 }
83 
84 } // 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:45
LockPtr<> is a reference-counting shared lockable smartpointer.
Definition: lockptr.h:54
const char * name() const
Get name of thread.
Definition: thread.h:100
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:33