YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Test_numbers1.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026-2026 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include "Test_numbers1.h"
8#include <yarp/os/Value.h>
9#include <vector>
10
11using namespace yarp::os;
12
13namespace {
14YARP_LOG_COMPONENT(TEST_NUMBERS, "Test_numbers")
15
16} //anonymous namespace
17
19{
20 yCDebug(TEST_NUMBERS, "created!\n");
21 yCDebug(TEST_NUMBERS, "I am attached to the %s\n",
22 (options.find("sender_side").asBool()) ? "sender side" : "receiver side");
23
24 //parse the user parameters
26 yCDebug(TEST_NUMBERS) << "user params:" << options.toString();
27
28 m_valueoperation = options.find("value").asInt64();
29
30 return true;
31}
32
36
38{
39 if (params.check("increment")) {
40 m_increment = params.find("increment").asInt32();
41 }
42 return true;
43}
44
46{
47 params.put("increment", m_increment);
48 return true;
49}
50
52{
54 if (s == NULL)
55 {
56 yCWarning(TEST_NUMBERS, "expected type `yarp::os::Value(int)` but got wrong data type!\n");
57 return false;
58 }
59
60 return true;
61}
62
64{
65 //get data to process
67 if (s == NULL)
68 {
69 yCWarning(TEST_NUMBERS, "expected type `yarp::os::Value(int)` but got wrong data type!\n");
70 return thing;
71 }
72
73 int v = s->asInt64() + m_increment;
74 *s = yarp::os::Value(v);
75
76 //send data
77 m_th.setPortWriter(s);
78
79 return m_th;
80}
81
83{
84}
bool accept(yarp::os::Things &thing) override
This will be called when the data reach the portmonitor object.
void trig() override
This will be called when one of the peer connections to the same import port receives data.
bool setparam(const yarp::os::Property &params) override
This will be called when the portmonitor carrier parameters are set via YARP admin port.
yarp::os::Things & update(yarp::os::Things &thing) override
After data get accpeted in the accept() callback, an instance of that is given to the update function...
bool create(const yarp::os::Property &options) override
This will be called when the dll is properly loaded by the portmonitor carrier.
bool getparam(yarp::os::Property &params) override
This will be called when the portmonitor carrier parameters are requested via YARP admin port.
void destroy() override
This will be called when the portmonitor object destroyes.
A mini-server for performing network communication in the background.
A class for storing options and configuration information.
Definition Property.h:32
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
std::string toString() const override
Return a standard text representation of the content of the object.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Definition Property.cpp:980
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Base class for generic things.
Definition Things.h:18
T * cast_as()
Definition Things.h:53
void setPortWriter(yarp::os::PortWriter *writer)
Set the reference to a PortWriter object.
Definition Things.cpp:26
A single value (typically within a Bottle).
Definition Value.h:44
virtual std::int64_t asInt64() const
Get 64-bit integer value.
Definition Value.cpp:210
virtual bool asBool() const
Get boolean value.
Definition Value.cpp:186
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition Value.cpp:204
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface to the operating system, including Port based communication.