Fawkes API  Fawkes Development Version
inifin.cpp
1 
2 /***************************************************************************
3  * inifin.cpp - Fawkes Aspect initializer/finalizer base class
4  *
5  * Created: Tue Nov 23 23:01:23 2010
6  * Copyright 2006-2010 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 <aspect/inifins/inifin.h>
25 
26 namespace fawkes {
27 #if 0 /* just to make Emacs auto-indent happy */
28 }
29 #endif
30 
31 /** @class AspectIniFin <aspect/inifins/inifin.h>
32  * Aspect initializer/finalizer base class.
33  * This class must be derived for each aspect that is added to the system,
34  * either standard or custom aspects.
35  * @author Tim Niemueller
36  *
37  * @fn void AspectIniFin::init(Thread *thread)
38  * Initialize thread.
39  * The aspect for the given thread must be initialized. Use dynamic_cast
40  * to cast the thread into the expected aspect class. An exception must
41  * be thrown if this fails. If anything fails during initialization of
42  * the aspect an Exception must be thrown.
43  * @param thread thread to initialize
44  *
45  * @fn void AspectIniFin::finalize(Thread *thread)
46  * Finalize thread.
47  * The aspect for the given thread must be initialized. Use dynamic_cast
48  * to cast the thread into the expected aspect class. An exception must
49  * be thrown if this fails. If anything fails during initialization of
50  * the aspect an Exception must be thrown. This will not prevent the
51  * thread from being removed. Use prepare_finalize() to report problems
52  * that should prevent the thread from being unloaded.
53  * @param thread thread to finalize
54  */
55 
56 /** Constructor.
57  * @param aspect_name name of the aspect the aspect initializer/finalizer
58  * subclass is used for. It must exist for the whole lifetime of the
59  * initializer/finalizer.
60  */
61 AspectIniFin::AspectIniFin(const char *aspect_name)
62 {
63  __aspect_name = aspect_name;
64 }
65 
66 /** Virtual empty destructor. */
68 {
69 }
70 
71 /** Default finalize preparation.
72  * This is a default implementation that assumes that finalization is
73  * always safe. Override it if you need to make more fine-grained
74  * decisions.
75  * @param thread thread to prepare for finalization
76  * @return always true
77  */
78 bool
80 {
81  return true;
82 }
83 
84 /** Get aspect name.
85  * @return name of the aspect this initializer/finalizer is used for
86  */
87 const char *
89 {
90  return __aspect_name;
91 }
92 
93 } // end namespace fawkes
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
virtual ~AspectIniFin()
Virtual empty destructor.
Definition: inifin.cpp:67
virtual bool prepare_finalize(Thread *thread)
Default finalize preparation.
Definition: inifin.cpp:79
const char * get_aspect_name() const
Get aspect name.
Definition: inifin.cpp:88
AspectIniFin(const char *aspect_name) __attribute__((nonnull))
Constructor.
Definition: inifin.cpp:61