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