RobotsIO
Loading...
Searching...
No Matches
Parameters2YarpBottle.cpp
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#include <RobotsIO/Utils/Parameters2YarpBottle.h>
9
10using namespace RobotsIO::Utils;
11using namespace yarp::os;
12
13
14Parameters2YarpBottle::Parameters2YarpBottle(const Parameters& parameters) :
15 ParametersExtractor(parameters)
16{}
17
18
19Parameters2YarpBottle::~Parameters2YarpBottle()
20{}
21
22
23Bottle Parameters2YarpBottle::extract_to_bottle()
24{
25 extract_fields();
26
27 return bottle_;
28}
29
30
31void Parameters2YarpBottle::extract_field(const std::string& key, const std::string& value)
32{
33 bottle_.addString(key);
34 bottle_.addString(value);
35}
36
37
38void Parameters2YarpBottle::extract_field(const std::string& key, const std::size_t& value)
39{
40 bottle_.addString(key);
41 bottle_.addInt32(value);
42}
43
44
45void Parameters2YarpBottle::extract_field(const std::string& key, const int& value)
46{
47 bottle_.addString(key);
48 bottle_.addInt32(value);
49}
50
51
52void Parameters2YarpBottle::extract_field(const std::string& key, const double& value)
53{
54 bottle_.addString(key);
55 bottle_.addFloat64(value);
56}
57
58
59void Parameters2YarpBottle::extract_field(const std::string& key, const bool& value)
60{
61 bottle_.addString(key);
62 bottle_.addInt32(value ? 1 : 0);
63}