RobotsIO
Loading...
Searching...
No Matches
src
RobotsIO
include
RobotsIO
Utils
YarpBottleProbe.hpp
1
/*
2
* Copyright (C) 2019 Istituto Italiano di Tecnologia (IIT)
3
*
4
* This software may be modified and distributed under the terms of the
5
* BSD 3-Clause license. See the accompanying LICENSE file for details.
6
*/
7
8
#ifndef ROBOTSIO_YARPBOTTLEPROBE_H
9
#define ROBOTSIO_YARPBOTTLEPROBE_H
10
11
#include <RobotsIO/Utils/Parameters.h>
12
#include <RobotsIO/Utils/Probe.h>
13
#include <RobotsIO/Utils/YarpBufferedPort.hpp>
14
15
#include <yarp/os/Bottle.h>
16
17
#include <string>
18
19
namespace
RobotsIO
{
20
namespace
Utils {
21
template
<
class
T = yarp::os::Bottle>
22
class
YarpBottleProbe;
23
}
24
}
25
26
27
template
<
class
T>
28
class
RobotsIO::Utils::YarpBottleProbe
:
public
RobotsIO::Utils::YarpBufferedPort
<yarp::os::Bottle>,
29
public
RobotsIO::Utils::Probe
30
{
31
public
:
32
YarpBottleProbe
(
const
std::string& port_name);
33
34
virtual
~YarpBottleProbe
();
35
36
protected
:
37
void
on_new_data()
override
;
38
39
private
:
40
yarp::os::Bottle convert_from(
const
T& data);
41
42
yarp::os::Bottle data_;
43
44
const
std::string log_name_ =
"YarpBottleProbe"
;
45
};
46
47
48
template
<
class
T>
49
RobotsIO::Utils::YarpBottleProbe<T>::YarpBottleProbe
(
const
std::string& port_name) :
50
YarpBufferedPort
<yarp::os::Bottle>(port_name)
51
{}
52
53
54
template
<
class
T>
55
RobotsIO::Utils::YarpBottleProbe<T>::~YarpBottleProbe
()
56
{}
57
58
59
template
<
class
T>
60
void
RobotsIO::Utils::YarpBottleProbe<T>::on_new_data
()
61
{
62
data_ = convert_from(RobotsIO::Utils::any_cast<T>(get_data()));
63
64
this->send_data(data_);
65
}
66
67
68
template
<
class
T>
69
yarp::os::Bottle
RobotsIO::Utils::YarpBottleProbe<T>::convert_from
(
const
T& data)
70
{
71
return
data;
72
}
73
74
75
template
<>
76
void
RobotsIO::Utils::YarpBottleProbe<RobotsIO::Utils::Parameters>::on_new_data
();
77
78
79
template
<>
80
yarp::os::Bottle
RobotsIO::Utils::YarpBottleProbe<RobotsIO::Utils::Parameters>::convert_from
(
const
RobotsIO::Utils::Parameters
& data);
81
82
83
#endif
/* ROBOTSIO_YARPBOTTLEPROBE_H */
RobotsIO::Utils::Parameters
Definition:
Parameters.h:186
RobotsIO::Utils::Probe
Definition:
Probe.h:22
RobotsIO::Utils::YarpBottleProbe
Definition:
YarpBottleProbe.hpp:30
RobotsIO::Utils::YarpBufferedPort
Definition:
YarpBufferedPort.hpp:28
RobotsIO
Definition:
Camera.h:24
Generated by
1.9.6