1818#include < string>
1919#include < utility>
2020
21- #include " hardware_interface/distributed_control_interface/state_publisher_description .hpp"
21+ #include " hardware_interface/distributed_control_interface/publisher_description .hpp"
2222#include " hardware_interface/macros.hpp"
2323#include " hardware_interface/visibility_control.h"
2424
@@ -151,41 +151,14 @@ class ReadOnlyHandle : public HandleInterface, ReadHandleInterface
151151 }
152152};
153153
154- class ReadWriteHandle : public HandleInterface , ReadHandleInterface, WriteHandleInterface
154+ class StateInterface : public ReadOnlyHandle
155155{
156156public:
157- ReadWriteHandle (
158- const std::string & prefix_name, const std::string & interface_name,
159- double * value_ptr = nullptr )
160- : HandleInterface(prefix_name, interface_name, value_ptr)
161- {
162- }
163-
164- explicit ReadWriteHandle (const std::string & interface_name) : HandleInterface(interface_name) {}
165-
166- explicit ReadWriteHandle (const char * interface_name) : HandleInterface(interface_name) {}
167-
168- ReadWriteHandle (const ReadWriteHandle & other) = default ;
169-
170- ReadWriteHandle (ReadWriteHandle && other) = default ;
171-
172- ReadWriteHandle & operator =(const ReadWriteHandle & other) = default ;
173-
174- ReadWriteHandle & operator =(ReadWriteHandle && other) = default ;
175-
176- virtual ~ReadWriteHandle () = default ;
157+ StateInterface (const StateInterface & other) = default ;
177158
178- double get_value () const override
179- {
180- THROW_ON_NULLPTR (value_ptr_);
181- return *value_ptr_;
182- }
159+ StateInterface (StateInterface && other) = default ;
183160
184- void set_value (double value) override
185- {
186- THROW_ON_NULLPTR (this ->value_ptr_ );
187- *this ->value_ptr_ = value;
188- }
161+ using ReadOnlyHandle::ReadOnlyHandle;
189162};
190163
191164class DistributedReadOnlyHandle : public ReadOnlyHandle
@@ -194,8 +167,7 @@ class DistributedReadOnlyHandle : public ReadOnlyHandle
194167 // TODO(Manuel): We should pass the initial value via service call, so that the value_ of ReadOnlyHandle
195168 // is initialized with a feasible value.
196169 DistributedReadOnlyHandle (
197- const distributed_control::StatePublisherDescription & description,
198- const std::string & ns = " /" )
170+ const distributed_control::PublisherDescription & description, const std::string & ns = " /" )
199171 : ReadOnlyHandle(description.prefix_name(), description.interface_name(), &value_),
200172 topic_name_ (description.topic_name()),
201173 namespace_(ns),
@@ -303,24 +275,51 @@ class DistributedReadOnlyHandle : public ReadOnlyHandle
303275 double value_;
304276};
305277
306- class StateInterface : public ReadOnlyHandle
278+ class DistributedStateInterface : public DistributedReadOnlyHandle
307279{
308280public:
309- StateInterface (const StateInterface & other) = default ;
281+ DistributedStateInterface (const DistributedStateInterface & other) = default ;
310282
311- StateInterface (StateInterface && other) = default ;
283+ DistributedStateInterface (DistributedStateInterface && other) = default ;
312284
313- using ReadOnlyHandle::ReadOnlyHandle ;
285+ using DistributedReadOnlyHandle::DistributedReadOnlyHandle ;
314286};
315287
316- class DistributedStateInterface : public DistributedReadOnlyHandle
288+ class ReadWriteHandle : public HandleInterface , ReadHandleInterface, WriteHandleInterface
317289{
318290public:
319- DistributedStateInterface (const DistributedStateInterface & other) = default ;
291+ ReadWriteHandle (
292+ const std::string & prefix_name, const std::string & interface_name,
293+ double * value_ptr = nullptr )
294+ : HandleInterface(prefix_name, interface_name, value_ptr)
295+ {
296+ }
320297
321- DistributedStateInterface (DistributedStateInterface && other) = default ;
298+ explicit ReadWriteHandle ( const std::string & interface_name) : HandleInterface(interface_name) {}
322299
323- using DistributedReadOnlyHandle::DistributedReadOnlyHandle;
300+ explicit ReadWriteHandle (const char * interface_name) : HandleInterface(interface_name) {}
301+
302+ ReadWriteHandle (const ReadWriteHandle & other) = default ;
303+
304+ ReadWriteHandle (ReadWriteHandle && other) = default ;
305+
306+ ReadWriteHandle & operator =(const ReadWriteHandle & other) = default ;
307+
308+ ReadWriteHandle & operator =(ReadWriteHandle && other) = default ;
309+
310+ virtual ~ReadWriteHandle () = default ;
311+
312+ double get_value () const override
313+ {
314+ THROW_ON_NULLPTR (value_ptr_);
315+ return *value_ptr_;
316+ }
317+
318+ void set_value (double value) override
319+ {
320+ THROW_ON_NULLPTR (this ->value_ptr_ );
321+ *this ->value_ptr_ = value;
322+ }
324323};
325324
326325class CommandInterface : public ReadWriteHandle
@@ -338,6 +337,65 @@ class CommandInterface : public ReadWriteHandle
338337
339338 using ReadWriteHandle::ReadWriteHandle;
340339};
340+
341+ class DistributedReadWriteHandle : public ReadWriteHandle
342+ {
343+ public:
344+ DistributedReadWriteHandle (
345+ const std::string & prefix_name, const std::string & interface_name,
346+ double * value_ptr = nullptr )
347+ : ReadWriteHandle(prefix_name, interface_name, value_ptr)
348+ {
349+ }
350+
351+ explicit DistributedReadWriteHandle (const std::string & interface_name)
352+ : ReadWriteHandle(interface_name)
353+ {
354+ }
355+
356+ explicit DistributedReadWriteHandle (const char * interface_name) : ReadWriteHandle(interface_name)
357+ {
358+ }
359+
360+ DistributedReadWriteHandle (const DistributedReadWriteHandle & other) = default ;
361+
362+ DistributedReadWriteHandle (DistributedReadWriteHandle && other) = default ;
363+
364+ DistributedReadWriteHandle & operator =(const DistributedReadWriteHandle & other) = default ;
365+
366+ DistributedReadWriteHandle & operator =(DistributedReadWriteHandle && other) = default ;
367+
368+ virtual ~DistributedReadWriteHandle () = default ;
369+
370+ double get_value () const override
371+ {
372+ THROW_ON_NULLPTR (value_ptr_);
373+ return *value_ptr_;
374+ }
375+
376+ void set_value (double value) override
377+ {
378+ THROW_ON_NULLPTR (this ->value_ptr_ );
379+ *this ->value_ptr_ = value;
380+ }
381+ };
382+
383+ class DistributedCommandInterface : public DistributedReadWriteHandle
384+ {
385+ public:
386+ // / CommandInterface copy constructor is actively deleted.
387+ /* *
388+ * Command interfaces are having a unique ownership and thus
389+ * can't be copied in order to avoid simultaneous writes to
390+ * the same resource.
391+ */
392+ DistributedCommandInterface (const DistributedCommandInterface & other) = delete ;
393+
394+ DistributedCommandInterface (DistributedCommandInterface && other) = default ;
395+
396+ using DistributedReadWriteHandle::DistributedReadWriteHandle;
397+ };
398+
341399} // namespace hardware_interface
342400
343401#endif // HARDWARE_INTERFACE__HANDLE_HPP_
0 commit comments