Fawkes API  Fawkes Development Version
syncpoint.cpp
1 /***************************************************************************
2  * syncpoint.cpp - SyncPoint Aspect initializer/finalizer
3  *
4  * Created: Thu Feb 19 14:39:42 2015
5  * Copyright 2015 Till Hofmann
6  *
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #include <aspect/inifins/syncpoint.h>
23 #include <aspect/syncpoint.h>
24 #include <syncpoint/syncpoint_manager.h>
25 
26 namespace fawkes {
27 
28 /** @class SyncPointAspectIniFin <aspect/inifins/syncpoint.h>
29  * Initializer/finalizer for the SyncPointAspect
30  * @author Till Hofmann
31  */
32 
33 /** Constructor.
34  * @param syncpoint_manager SyncPointManager instance to pass to threads
35  */
36 SyncPointAspectIniFin::SyncPointAspectIniFin(SyncPointManager *syncpoint_manager)
37 : AspectIniFin("SyncPointAspect")
38 {
39  syncpoint_manager_ = syncpoint_manager;
40 }
41 
42 void
44 {
45  SyncPointAspect *syncpoint_thread;
46  syncpoint_thread = dynamic_cast<SyncPointAspect *>(thread);
47  if (syncpoint_thread == NULL) {
48  throw CannotInitializeThreadException("Thread '%s' claims to have the "
49  "SyncPointManagerAspect, but RTTI says it "
50  "has not. ",
51  thread->name());
52  }
53 
54  syncpoint_thread->init_SyncPointAspect(thread, syncpoint_manager_);
55 }
56 
57 void
58 SyncPointAspectIniFin::finalize(Thread *thread)
59 {
60  SyncPointAspect *syncpoint_thread;
61  syncpoint_thread = dynamic_cast<SyncPointAspect *>(thread);
62  if (syncpoint_thread == NULL) {
63  throw CannotInitializeThreadException("Thread '%s' claims to have the "
64  "SyncPointManagerAspect, but RTTI says it "
65  "has not. ",
66  thread->name());
67  }
68 
69  syncpoint_thread->finalize_SyncPointAspect(thread, syncpoint_manager_);
70 }
71 
72 } // end namespace fawkes
fawkes::SyncPointAspectIniFin::init
virtual void init(Thread *thread)
Definition: syncpoint.cpp:47
fawkes::CannotInitializeThreadException
Definition: thread_initializer.h:37
fawkes::Thread::name
const char * name() const
Definition: thread.h:99
fawkes::SyncPointAspectIniFin::finalize
virtual void finalize(Thread *thread)
Definition: syncpoint.cpp:62
fawkes
fawkes::SyncPointAspectIniFin::SyncPointAspectIniFin
SyncPointAspectIniFin(SyncPointManager *syncpoint_manager)
Constructor.
Definition: syncpoint.cpp:40
fawkes::Thread
Definition: thread.h:44
fawkes::SyncPointAspect::init_SyncPointAspect
void init_SyncPointAspect(Thread *thread, SyncPointManager *syncpoint_manager)
Init SyncPoint aspect.
Definition: syncpoint.cpp:91
fawkes::SyncPointAspect
Definition: syncpoint.h:38