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
* (C) 2010, Ruben Smits, ruben.smits@mech.kuleuven.be
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
6
* are met:
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
* 3. Neither the name of the copyright holder nor the names of its contributors
13
* may be used to endorse or promote products derived from this software
14
* without specific prior written permission.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
* POSSIBILITY OF SUCH DAMAGE.
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:74
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:80
rtt_roscomm::RosPublishActivity::publishers_lock
RTT::os::Mutex publishers_lock
Definition:
rtt_rostopic_ros_publish_activity.hpp:82
rtt_roscomm::RosPublishActivity::weak_ptr
boost::weak_ptr< RosPublishActivity > weak_ptr
Definition:
rtt_rostopic_ros_publish_activity.hpp:72
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:49
rtt_roscomm::RosPublishActivity::publishers
Publishers publishers
Definition:
rtt_rostopic_ros_publish_activity.hpp:81
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 Mon May 10 2021 02:45:04