Main Page
Namespaces
Classes
Files
File List
File Members
src
rtt_rostopic_ros_publish_activity.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
tag: Ruben Smits Tue Nov 16 09:19:02 CET 2010 ros_publish_activity.cpp
3
4
ros_publish_activity.cpp - description
5
-------------------
6
begin : Tue November 16 2010
7
copyright : (C) 2010 Ruben Smits
8
email : first.last@mech.kuleuven.be
9
10
***************************************************************************
11
* This library is free software; you can redistribute it and/or *
12
* modify it under the terms of the GNU Lesser General Public *
13
* License as published by the Free Software Foundation; either *
14
* version 2.1 of the License, or (at your option) any later version. *
15
* *
16
* This library 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 GNU *
19
* Lesser General Public License for more details. *
20
* *
21
* You should have received a copy of the GNU Lesser General Public *
22
* License along with this library; if not, write to the Free Software *
23
* Foundation, Inc., 59 Temple Place, *
24
* Suite 330, Boston, MA 02111-1307 USA *
25
* *
26
***************************************************************************/
27
28
29
30
#include <
rtt_roscomm/rtt_rostopic_ros_publish_activity.hpp
>
31
32
namespace
rtt_roscomm
{
33
34
using namespace
RTT
;
35
36
RosPublishActivity::weak_ptr
RosPublishActivity::ros_pub_act
;
37
38
RosPublishActivity::RosPublishActivity
(
const
std::string& name)
39
:
Activity
(
ORO_SCHED_OTHER
,
RTT
::os::
LowestPriority
, 0.0, 0, name)
40
{
41
Logger::In in(
"RosPublishActivity"
);
42
log(
Debug
)<<
"Creating RosPublishActivity"
<<endlog();
43
}
44
45
void
RosPublishActivity::loop
(){
46
os::MutexLock
lock(
publishers_lock
);
47
for
(
iterator
it =
publishers
.begin(); it !=
publishers
.end(); ++it) {
48
(*it)->publish();
49
}
50
}
51
52
RosPublishActivity::shared_ptr
RosPublishActivity::Instance
() {
53
shared_ptr
ret =
ros_pub_act
.lock();
54
if
( !ret ) {
55
ret.reset(
new
RosPublishActivity
(
"RosPublishActivity"
));
56
ros_pub_act
= ret;
57
ret->start();
58
}
59
return
ret;
60
}
61
62
void
RosPublishActivity::addPublisher
(
RosPublisher
* pub) {
63
os::MutexLock
lock(
publishers_lock
);
64
publishers
.insert(pub);
65
}
66
67
void
RosPublishActivity::removePublisher
(
RosPublisher
* pub) {
68
os::MutexLock
lock(
publishers_lock
);
69
publishers
.erase(pub);
70
}
71
72
RosPublishActivity::~RosPublishActivity
() {
73
Logger::In in(
"RosPublishActivity"
);
74
log(
Info
) <<
"RosPublishActivity cleans up: no more work."
<<endlog();
75
stop
();
76
}
77
78
}
rtt_roscomm::RosPublishActivity::ros_pub_act
static weak_ptr ros_pub_act
This pointer may not be refcounted since it would prevent cleanup.
Definition:
rtt_rostopic_ros_publish_activity.hpp:73
RTT::Activity::stop
virtual bool stop()
rtt_roscomm::RosPublishActivity::~RosPublishActivity
~RosPublishActivity()
Definition:
rtt_rostopic_ros_publish_activity.cpp:72
rtt_roscomm::RosPublishActivity::iterator
Publishers::iterator iterator
Definition:
rtt_rostopic_ros_publish_activity.hpp:79
rtt_roscomm::RosPublishActivity::publishers_lock
RTT::os::Mutex publishers_lock
Definition:
rtt_rostopic_ros_publish_activity.hpp:81
rtt_roscomm::RosPublishActivity::weak_ptr
boost::weak_ptr< RosPublishActivity > weak_ptr
Definition:
rtt_rostopic_ros_publish_activity.hpp:71
rtt_roscomm::RosPublishActivity::removePublisher
void removePublisher(RosPublisher *pub)
Definition:
rtt_rostopic_ros_publish_activity.cpp:67
boost::shared_ptr< RosPublishActivity >
rtt_roscomm::RosPublisher
Definition:
rtt_rostopic_ros_publish_activity.hpp:48
rtt_roscomm::RosPublishActivity::publishers
Publishers publishers
Definition:
rtt_rostopic_ros_publish_activity.hpp:80
rtt_roscomm::RosPublishActivity::RosPublishActivity
RosPublishActivity(const std::string &name)
Definition:
rtt_rostopic_ros_publish_activity.cpp:38
RTT::Debug
Debug
RTT::Activity
rtt_rostopic_ros_publish_activity.hpp
rtt_roscomm::RosPublishActivity::loop
void loop()
Definition:
rtt_rostopic_ros_publish_activity.cpp:45
RTT::Info
Info
rtt_roscomm::RosPublishActivity::addPublisher
void addPublisher(RosPublisher *pub)
Definition:
rtt_rostopic_ros_publish_activity.cpp:62
LowestPriority
const int LowestPriority
RTT
rtt_roscomm
Definition:
rosservice.h:7
ORO_SCHED_OTHER
#define ORO_SCHED_OTHER
RTT::os::MutexLock
rtt_roscomm::RosPublishActivity::Instance
static shared_ptr Instance()
Definition:
rtt_rostopic_ros_publish_activity.cpp:52
rtt_roscomm
Author(s): Ruben Smits, Jonathan Bohren
autogenerated on Sat Jun 8 2019 18:05:17