Fawkes API Fawkes Development Version
finalize_nettler_thread.cpp
1
2/***************************************************************************
3 * finalize_nettler_thread.cpp - Fawkes Example Plugin Finalize Nettler Thread
4 *
5 * Created: Thu May 24 00:35:06 2007
6 * Copyright 2006-2008 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.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Library General Public License for more details.
19 *
20 * Read the full text in the LICENSE.GPL file in the doc directory.
21 */
22
23#include <plugins/examples/basics/finalize_nettler_thread.h>
24
25#include <unistd.h>
26
27using namespace fawkes;
28
29/** @class ExampleFinalizeNettlerThread plugins/examples/basics/finalize_nettler_thread.h
30 * Thread of example plugin.
31 * This thread does nothing but nagging once on finalize. On the first call to
32 * prepare finalize it returns false that it cannot be finalized,
33 * on the second time it allows finalization.
34 * @author Tim Niemueller
35 */
36
37/** Constructor.
38 * @param name thread name
39 */
41: Thread(name, Thread::OPMODE_WAITFORWAKEUP)
42{
43 nagged = false;
44}
45
46/** Destructor. */
48{
49}
50
51/** Thread loop.
52 * If num iterations module modc is 0 print out messaege, otherwise do nothing.
53 */
54void
56{
57}
58
59void
61{
62 logger->log_info("ExampleFinalizeNettlerThread", "init() called");
63}
64
65void
67{
68 logger->log_info("ExampleFinalizeNettlerThread", "finalize() called");
69}
70
71bool
73{
74 if (nagged) {
75 logger->log_warn("ExampleFinalizeNettlerThread", "Allowing Finalization");
76 return true;
77 } else {
78 logger->log_warn("ExampleFinalizeNettlerThread", "NOT allowing Finalization");
79 nagged = true;
80 return false;
81 }
82}
virtual void init()
Initialize the thread.
virtual ~ExampleFinalizeNettlerThread()
Destructor.
ExampleFinalizeNettlerThread(const char *name)
Constructor.
virtual void loop()
Thread loop.
virtual bool prepare_finalize_user()
Prepare finalization user implementation.
virtual void finalize()
Finalize the thread.
virtual void log_warn(const char *component, const char *format,...)=0
Log warning message.
virtual void log_info(const char *component, const char *format,...)=0
Log informational message.
Logger * logger
This is the Logger member used to access the logger.
Definition: logging.h:41
Thread class encapsulation of pthreads.
Definition: thread.h:46
Fawkes library namespace.