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
27namespace fawkes {
28
29namespace tf {
30class Transformer;
31}
32
33/** @class TransformAspectIniFin <aspect/inifins/tf.h>
34 * Initializer/finalizer for the TransformAspect.
35 * @author Tim Niemueller
36 */
37
38/** Constructor.
39 * @param blackboard blackboard instance to pass to threads
40 * @param transformer system-wide shared transformer to pass to threads
41 */
43: AspectIniFin("TransformAspect")
44{
45 blackboard_ = blackboard;
46 transformer_ = transformer;
47}
48
49void
51{
52 TransformAspect *transform_thread;
53 transform_thread = dynamic_cast<TransformAspect *>(thread);
54 if (transform_thread == NULL) {
55 throw CannotInitializeThreadException("Thread '%s' claims to have the "
56 "TransformAspect, but RTTI says it "
57 "has not. ",
58 thread->name());
59 }
60
61 transform_thread->init_TransformAspect(blackboard_, transformer_, thread->name());
62}
63
64void
66{
67 TransformAspect *transform_thread;
68 transform_thread = dynamic_cast<TransformAspect *>(thread);
69 if (transform_thread == NULL) {
70 throw CannotFinalizeThreadException("Thread '%s' claims to have the "
71 "TransformAspect, but RTTI says it "
72 "has not. ",
73 thread->name());
74 }
75
76 transform_thread->finalize_TransformAspect();
77}
78
79} // end namespace fawkes
Aspect initializer/finalizer base class.
Definition: inifin.h:34
The BlackBoard abstract class.
Definition: blackboard.h:46
Thread cannot be finalized.
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
virtual void init(Thread *thread)
Initialize thread.
Definition: tf.cpp:50
TransformAspectIniFin(BlackBoard *blackboard, tf::Transformer *transformer)
Constructor.
Definition: tf.cpp:42
virtual void finalize(Thread *thread)
Finalize thread.
Definition: tf.cpp:65
Thread aspect to access the transform system.
Definition: tf.h:39
void init_TransformAspect(BlackBoard *blackboard, tf::Transformer *transformer, const char *thread_name)
Init transform aspect.
Definition: tf.cpp:101
void finalize_TransformAspect()
Finalize transform aspect.
Definition: tf.cpp:214
Coordinate transforms between any two frames in a system.
Definition: transformer.h:65
Fawkes library namespace.