Fawkes API  Fawkes Development Version
tf.cpp
1 
2 /***************************************************************************
3  * tf.cpp - Fawkes TransformAspect initializer/finalizer
4  *
5  * Created: Tue Oct 25 22:32:59 2011
6  * Copyright 2006-2011 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/inifins/tf.h>
25 #include <aspect/tf.h>
26 
27 namespace fawkes {
28 
29  namespace tf {
30  class Transformer;
31  }
32 
33 #if 0 /* just to make Emacs auto-indent happy */
34 }
35 #endif
36 
37 /** @class TransformAspectIniFin <aspect/inifins/tf.h>
38  * Initializer/finalizer for the TransformAspect.
39  * @author Tim Niemueller
40  */
41 
42 /** Constructor.
43  * @param blackboard blackboard instance to pass to threads
44  * @param transformer system-wide shared transformer to pass to threads
45  */
47  tf::Transformer *transformer)
48  : AspectIniFin("TransformAspect")
49 {
50  __blackboard = blackboard;
51  __transformer = transformer;
52 }
53 
54 void
56 {
57  TransformAspect *transform_thread;
58  transform_thread = dynamic_cast<TransformAspect *>(thread);
59  if (transform_thread == NULL) {
60  throw CannotInitializeThreadException("Thread '%s' claims to have the "
61  "TransformAspect, but RTTI says it "
62  "has not. ", thread->name());
63  }
64 
65  transform_thread->init_TransformAspect(__blackboard, __transformer, thread->name());
66 }
67 
68 void
70 {
71  TransformAspect *transform_thread;
72  transform_thread = dynamic_cast<TransformAspect *>(thread);
73  if (transform_thread == NULL) {
74  throw CannotFinalizeThreadException("Thread '%s' claims to have the "
75  "TransformAspect, but RTTI says it "
76  "has not. ", thread->name());
77  }
78 
79  transform_thread->finalize_TransformAspect();
80 }
81 
82 
83 } // end namespace fawkes
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
Thread aspect to access the transform system.
Definition: tf.h:42
Thread cannot be initialized.
const char * name() const
Get name of thread.
Definition: thread.h:95
TransformAspectIniFin(BlackBoard *blackboard, tf::Transformer *transformer)
Constructor.
Definition: tf.cpp:46
Thread cannot be finalized.
void finalize_TransformAspect()
Finalize transform aspect.
Definition: tf.cpp:227
void init_TransformAspect(BlackBoard *blackboard, tf::Transformer *transformer, const char *thread_name)
Init transform aspect.
Definition: tf.cpp:108
virtual void init(Thread *thread)
Initialize thread.
Definition: tf.cpp:55
virtual void finalize(Thread *thread)
Finalize thread.
Definition: tf.cpp:69
The BlackBoard abstract class.
Definition: blackboard.h:48
Coordinate transforms between any two frames in a system.
Definition: transformer.h:68
Aspect initializer/finalizer base class.
Definition: inifin.h:36