mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 15:53:34 +08:00
Using std::function<> for callbacks with C++11
This commit is contained in:
@@ -4,15 +4,29 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <uavcan/impl_constants.hpp>
|
||||
#include <uavcan/node/generic_publisher.hpp>
|
||||
#include <uavcan/node/generic_subscriber.hpp>
|
||||
|
||||
#if !defined(UAVCAN_CPP_VERSION) || !defined(UAVCAN_CPP11)
|
||||
# error UAVCAN_CPP_VERSION
|
||||
#endif
|
||||
|
||||
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
|
||||
# include <functional>
|
||||
#endif
|
||||
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
template <typename DataType_,
|
||||
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
|
||||
typename Callback = std::function<void (const ReceivedDataStructure<typename DataType_::Request>&,
|
||||
typename DataType_::Response&)>,
|
||||
#else
|
||||
typename Callback = void (*)(const ReceivedDataStructure<typename DataType_::Request>&,
|
||||
typename DataType_::Response&),
|
||||
#endif
|
||||
unsigned int NumStaticReceivers = 2,
|
||||
unsigned int NumStaticBufs = 1>
|
||||
class ServiceServer : public GenericSubscriber<DataType_, typename DataType_::Request,
|
||||
|
||||
Reference in New Issue
Block a user