Fawkes API Fawkes Development Version
blocked_timing.cpp
1
2/***************************************************************************
3 * blocked_timing.cpp - Fawkes Blocked Timing Aspect initializer/finalizer
4 *
5 * Created: Tue Nov 23 23:25:45 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/blocked_timing.h>
25#include <aspect/inifins/blocked_timing.h>
26#include <core/macros.h>
27
28namespace fawkes {
29
30/** @class BlockedTimingAspectIniFin <aspect/inifins/blocked_timing.h>
31 * Initializer/finalizer for the BlockedTimingAspect.
32 * @author Tim Niemueller
33 */
34
35/** Constructor. */
37{
38}
39
40void
42{
43 BlockedTimingAspect *blocked_timing_thread;
44 blocked_timing_thread = dynamic_cast<BlockedTimingAspect *>(thread);
45
46 if (blocked_timing_thread == 0) {
47 throw CannotInitializeThreadException("Thread '%s' claims to have the "
48 "BlockedTimingAspect, but RTTI says it "
49 "has not. ",
50 thread->name());
51 }
52
53 if (thread->opmode() != Thread::OPMODE_WAITFORWAKEUP) {
54 throw CannotInitializeThreadException("Thread '%s' not in WAITFORWAKEUP mode"
55 " (required for BlockedTimingAspect)",
56 thread->name());
57 }
58
59 blocked_timing_thread->init_BlockedTimingAspect(thread);
60}
61
62void
64{
65 BlockedTimingAspect *blocked_timing_thread;
66 blocked_timing_thread = dynamic_cast<BlockedTimingAspect *>(thread);
67
68 if (blocked_timing_thread == 0) {
69 throw CannotInitializeThreadException("Thread '%s' claims to have the "
70 "BlockedTimingAspect, but RTTI says it "
71 "has not. ",
72 thread->name());
73 }
74
75 blocked_timing_thread->finalize_BlockedTimingAspect(thread);
76}
77
78} // end namespace fawkes
Aspect initializer/finalizer base class.
Definition: inifin.h:34
virtual void init(Thread *thread)
Initialize thread.
virtual void finalize(Thread *thread)
Finalize thread.
Thread aspect to use blocked timing.
void finalize_BlockedTimingAspect(Thread *thread)
Finalize BlockedTiming aspect.
void init_BlockedTimingAspect(Thread *thread)
Init BlockedTiming aspect.
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
OpMode opmode() const
Get operation mode.
Definition: thread.cpp:671
@ OPMODE_WAITFORWAKEUP
operate in wait-for-wakeup mode
Definition: thread.h:58
Fawkes library namespace.