RobotsIO
Loading...
Searching...
No Matches
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
19namespace RobotsIO {
20 namespace Utils {
21 template <class T = yarp::os::Bottle>
22 class YarpBottleProbe;
23 }
24}
25
26
27template <class T>
30{
31public:
32 YarpBottleProbe(const std::string& port_name);
33
34 virtual ~YarpBottleProbe();
35
36protected:
37 void on_new_data() override;
38
39private:
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
48template <class T>
49RobotsIO::Utils::YarpBottleProbe<T>::YarpBottleProbe(const std::string& port_name) :
50 YarpBufferedPort<yarp::os::Bottle>(port_name)
51{}
52
53
54template <class T>
56{}
57
58
59template <class T>
61{
62 data_ = convert_from(RobotsIO::Utils::any_cast<T>(get_data()));
63
64 this->send_data(data_);
65}
66
67
68template <class T>
69yarp::os::Bottle RobotsIO::Utils::YarpBottleProbe<T>::convert_from(const T& data)
70{
71 return data;
72}
73
74
75template <>
77
78
79template <>
81
82
83#endif /* ROBOTSIO_YARPBOTTLEPROBE_H */