Created
May 10, 2019 06:58
-
-
Save drdanz/4634279a3c03e2def9b090061212ba00 to your computer and use it in GitHub Desktop.
test_thrift_return_vector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Bar.h" | |
bool Bar::configure(yarp::os::ResourceFinder &rf) | |
{ | |
if (!rpcService.open("/test_thrift_return_vector")) { | |
return false; | |
} | |
return this->yarp().attachAsServer(rpcService); | |
} | |
double Bar::getPeriod() | |
{ | |
return 1.0; | |
} | |
bool Bar::updateModule() | |
{ | |
return true; | |
} | |
bool Bar::close() | |
{ | |
if (rpcService.asPort().isOpen()) { | |
rpcService.close(); | |
} | |
return true; | |
} | |
yarp::sig::Vector Bar::foo() | |
{ | |
return {0.0, 1.0, 2.0, 3.0, 4.0}; | |
} | |
yarp::sig::VectorOf<int> Bar::foo_int() | |
{ | |
return {0, 1, 2, 3, 4}; | |
} | |
yarp::sig::VectorOf<double> Bar::foo_double() | |
{ | |
return {0.0, 1.0, 2.0, 3.0, 4.0}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Foo.h" | |
#include <yarp/os/RFModule.h> | |
#include <yarp/os/RpcServer.h> | |
#include <yarp/os/ResourceFinder.h> | |
class Bar : | |
public yarp::os::RFModule, | |
public Foo | |
{ | |
yarp::os::RpcServer rpcService; | |
public: | |
bool configure(yarp::os::ResourceFinder &rf) override; | |
double getPeriod() override; | |
bool updateModule() override; | |
bool close() override; | |
yarp::sig::Vector foo() override; | |
yarp::sig::VectorOf<int> foo_int() override; | |
yarp::sig::VectorOf<double> foo_double() override; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.5) | |
project(test_thrift_return_vector) | |
set(CMAKE_CXX_EXTENSIONS OFF) | |
set(CMAKE_CXX_STANDARD 11) | |
set(CMAKE_CXX_STANDARD_REQUIRED 11) | |
find_package(YARP 3.1 REQUIRED) | |
yarp_add_idl(IDL_GEN_FILES Foo.thrift) | |
add_executable(test_thrift_return_vector main.cpp Bar.cpp Bar.h Foo.thrift ${IDL_GEN_FILES}) | |
target_link_libraries(test_thrift_return_vector | |
YARP::YARP_OS | |
YARP::YARP_init | |
YARP::YARP_sig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Vector | |
{ | |
} ( | |
yarp.name = "yarp::sig::Vector" | |
yarp.includefile="yarp/sig/Vector.h" | |
) | |
struct Vector_int | |
{ | |
} ( | |
yarp.name = "yarp::sig::VectorOf<int>" | |
yarp.includefile="yarp/sig/Vector.h" | |
) | |
struct Vector_double | |
{ | |
} ( | |
yarp.name = "yarp::sig::VectorOf<double>" | |
yarp.includefile="yarp/sig/Vector.h" | |
) | |
service Foo | |
{ | |
Vector foo(); | |
Vector_int foo_int(); | |
Vector_double foo_double(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Bar.h" | |
#include <yarp/os/Network.h> | |
#include <yarp/os/ResourceFinder.h> | |
int main(int argc, char *argv[]) | |
{ | |
yarp::os::Network yarp; | |
yarp::os::ResourceFinder rf; | |
rf.configure(argc, argv); | |
Bar bar; | |
return bar.runModule(rf); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment