Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * inifin.cpp - Fawkes Aspect initializer/finalizer base class 00004 * 00005 * Created: Tue Nov 23 23:01:23 2010 00006 * Copyright 2006-2010 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #include <aspect/inifins/inifin.h> 00025 00026 namespace fawkes { 00027 #if 0 /* just to make Emacs auto-indent happy */ 00028 } 00029 #endif 00030 00031 /** @class AspectIniFin <aspect/inifins/inifin.h> 00032 * Aspect initializer/finalizer base class. 00033 * This class must be derived for each aspect that is added to the system, 00034 * either standard or custom aspects. 00035 * @author Tim Niemueller 00036 * 00037 * @fn void AspectIniFin::init(Thread *thread) 00038 * Initialize thread. 00039 * The aspect for the given thread must be initialized. Use dynamic_cast 00040 * to cast the thread into the expected aspect class. An exception must 00041 * be thrown if this fails. If anything fails during initialization of 00042 * the aspect an Exception must be thrown. 00043 * @param thread thread to initialize 00044 * 00045 * @fn void AspectIniFin::finalize(Thread *thread) 00046 * Finalize thread. 00047 * The aspect for the given thread must be initialized. Use dynamic_cast 00048 * to cast the thread into the expected aspect class. An exception must 00049 * be thrown if this fails. If anything fails during initialization of 00050 * the aspect an Exception must be thrown. This will not prevent the 00051 * thread from being removed. Use prepare_finalize() to report problems 00052 * that should prevent the thread from being unloaded. 00053 * @param thread thread to finalize 00054 */ 00055 00056 /** Constructor. 00057 * @param aspect_name name of the aspect the aspect initializer/finalizer 00058 * subclass is used for. It must exist for the whole lifetime of the 00059 * initializer/finalizer. 00060 */ 00061 AspectIniFin::AspectIniFin(const char *aspect_name) 00062 { 00063 __aspect_name = aspect_name; 00064 } 00065 00066 /** Virtual empty destructor. */ 00067 AspectIniFin::~AspectIniFin() 00068 { 00069 } 00070 00071 /** Default finalize preparation. 00072 * This is a default implementation that assumes that finalization is 00073 * always safe. Override it if you need to make more fine-grained 00074 * decisions. 00075 * @param thread thread to prepare for finalization 00076 * @return always true 00077 */ 00078 bool 00079 AspectIniFin::prepare_finalize(Thread *thread) 00080 { 00081 return true; 00082 } 00083 00084 /** Get aspect name. 00085 * @return name of the aspect this initializer/finalizer is used for 00086 */ 00087 const char * 00088 AspectIniFin::get_aspect_name() const 00089 { 00090 return __aspect_name; 00091 } 00092 00093 } // end namespace fawkes