From c2ba231741af9ecdb4aea968c7dfc832aa36b7be Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Fri, 29 Jul 2016 17:24:18 +0300 Subject: [PATCH] ReceivedDataStructure<> made noncopyable --- libuavcan/include/uavcan/node/generic_subscriber.hpp | 7 ++++++- libuavcan/test/protocol/helpers.hpp | 10 ++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libuavcan/include/uavcan/node/generic_subscriber.hpp b/libuavcan/include/uavcan/node/generic_subscriber.hpp index c4f06a2cce..8d58027cb0 100644 --- a/libuavcan/include/uavcan/node/generic_subscriber.hpp +++ b/libuavcan/include/uavcan/node/generic_subscriber.hpp @@ -29,9 +29,14 @@ namespace uavcan * void first(const ReceivedDataStructure& msg); * void second(const Foo& msg); * In the latter case, an implicit cast will happen before the callback is invoked. + * + * This class is not copyable because it holds a reference to a stack-allocated transfer descriptor object. + * You can slice cast it to the underlying data type though, which would be copyable: + * DataType dt = rds; // where rds is of type ReceivedDataStructure + * // dt is now copyable */ template -class UAVCAN_EXPORT ReceivedDataStructure : public DataType_ +class UAVCAN_EXPORT ReceivedDataStructure : public DataType_, Noncopyable { const IncomingTransfer* const _transfer_; ///< Such weird name is necessary to avoid clashing with DataType fields diff --git a/libuavcan/test/protocol/helpers.hpp b/libuavcan/test/protocol/helpers.hpp index dc57f21c63..b1d2f97157 100644 --- a/libuavcan/test/protocol/helpers.hpp +++ b/libuavcan/test/protocol/helpers.hpp @@ -14,18 +14,16 @@ template class SubscriptionCollector : uavcan::Noncopyable { - typedef uavcan::ReceivedDataStructure ReceivedDataStructType; - - void handler(const ReceivedDataStructType& msg) + void handler(const DataType& msg) { - this->msg.reset(new ReceivedDataStructType(msg)); + this->msg.reset(new DataType(msg)); } public: - std::auto_ptr msg; + std::auto_ptr msg; typedef uavcan::MethodBinder Binder; + void (SubscriptionCollector::*)(const DataType&)> Binder; Binder bind() { return Binder(this, &SubscriptionCollector::handler); } };