Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * finalize_nettler_thread.cpp - Fawkes Example Plugin Finalize Nettler Thread 00004 * 00005 * Created: Thu May 24 00:35:06 2007 00006 * Copyright 2006-2008 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. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #include <plugins/examples/basics/finalize_nettler_thread.h> 00024 00025 #include <unistd.h> 00026 00027 using namespace fawkes; 00028 00029 /** @class ExampleFinalizeNettlerThread plugins/examples/basics/finalize_nettler_thread.h 00030 * Thread of example plugin. 00031 * This thread does nothing but nagging once on finalize. On the first call to 00032 * prepare finalize it returns false that it cannot be finalized, 00033 * on the second time it allows finalization. 00034 * @author Tim Niemueller 00035 */ 00036 00037 /** Constructor. 00038 * @param name thread name 00039 */ 00040 ExampleFinalizeNettlerThread::ExampleFinalizeNettlerThread(const char *name) 00041 : Thread(name, Thread::OPMODE_WAITFORWAKEUP) 00042 { 00043 nagged = false; 00044 } 00045 00046 00047 /** Destructor. */ 00048 ExampleFinalizeNettlerThread::~ExampleFinalizeNettlerThread() 00049 { 00050 } 00051 00052 00053 /** Thread loop. 00054 * If num iterations module modc is 0 print out messaege, otherwise do nothing. 00055 */ 00056 void 00057 ExampleFinalizeNettlerThread::loop() 00058 { 00059 } 00060 00061 00062 void 00063 ExampleFinalizeNettlerThread::init() 00064 { 00065 logger->log_info("ExampleFinalizeNettlerThread", "init() called"); 00066 } 00067 00068 00069 void 00070 ExampleFinalizeNettlerThread::finalize() 00071 { 00072 logger->log_info("ExampleFinalizeNettlerThread", "finalize() called"); 00073 } 00074 00075 00076 bool 00077 ExampleFinalizeNettlerThread::prepare_finalize_user() 00078 { 00079 if ( nagged ) { 00080 logger->log_warn("ExampleFinalizeNettlerThread", "Allowing Finalization"); 00081 return true; 00082 } else { 00083 logger->log_warn("ExampleFinalizeNettlerThread", "NOT allowing Finalization"); 00084 nagged = true; 00085 return false; 00086 } 00087 }