Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
ros_inifin.cpp
1
2
/***************************************************************************
3
* ros_inifin.cpp - Fawkes ROSAspect initializer/finalizer
4
*
5
* Created: Thu May 05 16:03:34 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 <plugins/ros/aspect/ros_inifin.h>
25
#include <core/threading/thread_finalizer.h>
26
#include <ros/node_handle.h>
27
28
namespace
fawkes {
29
#if 0
/* just to make Emacs auto-indent happy */
30
}
31
#endif
32
33
/** @class ROSAspectIniFin <plugins/ros/aspect/ros_inifin.h>
34
* ROSAspect initializer/finalizer.
35
* This initializer/finalizer will provide the ROS node handle to
36
* threads with the ROSAspect.
37
* @author Tim Niemueller
38
*/
39
40
/** Constructor. */
41
ROSAspectIniFin::ROSAspectIniFin()
42
:
AspectIniFin
(
"ROSAspect"
)
43
{
44
}
45
46
void
47
ROSAspectIniFin::init
(
Thread
*thread)
48
{
49
ROSAspect
*ros_thread;
50
ros_thread =
dynamic_cast<
ROSAspect
*
>
(thread);
51
if
(ros_thread == NULL) {
52
throw
CannotInitializeThreadException
(
"Thread '%s' claims to have the "
53
"ROSAspect, but RTTI says it "
54
"has not. "
, thread->
name
());
55
}
56
if
(! __rosnode) {
57
throw
CannotInitializeThreadException
(
"ROS node handle has not been set."
);
58
}
59
60
ros_thread->init_ROSAspect(__rosnode);
61
}
62
63
void
64
ROSAspectIniFin::finalize
(
Thread
*thread)
65
{
66
ROSAspect
*ros_thread;
67
ros_thread =
dynamic_cast<
ROSAspect
*
>
(thread);
68
if
(ros_thread == NULL) {
69
throw
CannotFinalizeThreadException
(
"Thread '%s' claims to have the "
70
"ROSAspect, but RTTI says it "
71
"has not. "
, thread->
name
());
72
}
73
ros_thread->finalize_ROSAspect();
74
}
75
76
77
/** Set the ROS node handle to use for aspect initialization.
78
* @param rosnode ROS node handle to pass to threads with ROSAspect.
79
*/
80
void
81
ROSAspectIniFin::set_rosnode
(
LockPtr<ros::NodeHandle>
rosnode)
82
{
83
__rosnode = rosnode;
84
}
85
86
}
// end namespace fawkes
src
plugins
ros
aspect
ros_inifin.cpp
Generated by
1.8.3.1