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 
28 namespace fawkes {
29 
30 /** @class BlockedTimingAspectIniFin <aspect/inifins/blocked_timing.h>
31  * Initializer/finalizer for the BlockedTimingAspect.
32  * @author Tim Niemueller
33  */
34 
35 /** Constructor. */
36 BlockedTimingAspectIniFin::BlockedTimingAspectIniFin() : AspectIniFin("BlockedTimingAspect")
37 {
38 }
39 
40 void
41 BlockedTimingAspectIniFin::init(Thread *thread)
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 
62 void
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
fawkes::BlockedTimingAspect::init_BlockedTimingAspect
void init_BlockedTimingAspect(Thread *thread)
Init BlockedTiming aspect.
Definition: blocked_timing.cpp:79
fawkes::BlockedTimingAspectIniFin::init
virtual void init(Thread *thread)
Definition: blocked_timing.cpp:47
fawkes::BlockedTimingAspect
Definition: blocked_timing.h:56
fawkes::CannotInitializeThreadException
Definition: thread_initializer.h:39
fawkes::BlockedTimingAspectIniFin::BlockedTimingAspectIniFin
BlockedTimingAspectIniFin()
Constructor.
Definition: blocked_timing.cpp:42
fawkes::BlockedTimingAspectIniFin::finalize
virtual void finalize(Thread *thread)
Definition: blocked_timing.cpp:69
fawkes
fawkes::Thread::OPMODE_WAITFORWAKEUP
@ OPMODE_WAITFORWAKEUP
operate in wait-for-wakeup mode
Definition: thread.h:58