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
27
using 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
*/
40
ExampleFinalizeNettlerThread::ExampleFinalizeNettlerThread
(
const
char
*name)
41
:
Thread
(name,
Thread
::OPMODE_WAITFORWAKEUP)
42
{
43
nagged =
false
;
44
}
45
46
/** Destructor. */
47
ExampleFinalizeNettlerThread::~ExampleFinalizeNettlerThread
()
48
{
49
}
50
51
/** Thread loop.
52
* If num iterations module modc is 0 print out messaege, otherwise do nothing.
53
*/
54
void
55
ExampleFinalizeNettlerThread::loop
()
56
{
57
}
58
59
void
60
ExampleFinalizeNettlerThread::init
()
61
{
62
logger
->
log_info
(
"ExampleFinalizeNettlerThread"
,
"init() called"
);
63
}
64
65
void
66
ExampleFinalizeNettlerThread::finalize
()
67
{
68
logger
->
log_info
(
"ExampleFinalizeNettlerThread"
,
"finalize() called"
);
69
}
70
71
bool
72
ExampleFinalizeNettlerThread::prepare_finalize_user
()
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
}
fawkes::Logger::log_info
virtual void log_info(const char *component, const char *format,...)=0
ExampleFinalizeNettlerThread::init
virtual void init()
Initialize the thread.
Definition:
finalize_nettler_thread.cpp:59
fawkes::LoggingAspect::logger
Logger * logger
Definition:
logging.h:50
fawkes
fawkes::Logger::log_warn
virtual void log_warn(const char *component, const char *format,...)=0
ExampleFinalizeNettlerThread::~ExampleFinalizeNettlerThread
virtual ~ExampleFinalizeNettlerThread()
Destructor.
Definition:
finalize_nettler_thread.cpp:46
ExampleFinalizeNettlerThread::finalize
virtual void finalize()
Finalize the thread.
Definition:
finalize_nettler_thread.cpp:65
fawkes::Thread
Definition:
thread.h:44
ExampleFinalizeNettlerThread::prepare_finalize_user
virtual bool prepare_finalize_user()
Prepare finalization user implementation.
Definition:
finalize_nettler_thread.cpp:71
ExampleFinalizeNettlerThread::ExampleFinalizeNettlerThread
ExampleFinalizeNettlerThread(const char *name)
Constructor.
Definition:
finalize_nettler_thread.cpp:39
ExampleFinalizeNettlerThread::loop
virtual void loop()
Thread loop.
Definition:
finalize_nettler_thread.cpp:54
src
plugins
examples
basics
finalize_nettler_thread.cpp
Generated by
1.8.16