sub_node.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Pavel Kirienko <pavel.kirienko@gmail.com>
3  */
4 
5 #ifndef UAVCAN_SUB_NODE_NODE_HPP_INCLUDED
6 #define UAVCAN_SUB_NODE_NODE_HPP_INCLUDED
7 
8 #include <cassert>
11 
12 #if UAVCAN_TINY
13 # error "This functionality is not available in tiny mode"
14 #endif
15 
16 namespace uavcan
17 {
23 template <std::size_t MemPoolSize = 0>
24 class UAVCAN_EXPORT SubNode : public INode
25 {
26  typedef typename
27  Select<(MemPoolSize > 0),
28  PoolAllocator<MemPoolSize, MemPoolBlockSize>, // If pool size is specified, use default allocator
29  IPoolAllocator& // Otherwise use reference to user-provided allocator
30  >::Result Allocator;
31 
34 
36 
37 protected:
38  virtual void registerInternalFailure(const char* msg)
39  {
40  internal_failure_cnt_++;
41  UAVCAN_TRACE("Node", "Internal failure: %s", msg);
42  (void)msg;
43  }
44 
45 public:
49  SubNode(ICanDriver& can_driver,
50  ISystemClock& system_clock) :
51  scheduler_(can_driver, pool_allocator_, system_clock),
52  internal_failure_cnt_(0)
53  { }
54 
58  SubNode(ICanDriver& can_driver,
59  ISystemClock& system_clock,
60  IPoolAllocator& allocator) :
61  pool_allocator_(allocator),
62  scheduler_(can_driver, pool_allocator_, system_clock),
63  internal_failure_cnt_(0)
64  { }
65 
66  virtual typename RemoveReference<Allocator>::Type& getAllocator() { return pool_allocator_; }
67 
68  virtual Scheduler& getScheduler() { return scheduler_; }
69  virtual const Scheduler& getScheduler() const { return scheduler_; }
70 
71  uint64_t getInternalFailureCount() const { return internal_failure_cnt_; }
72 };
73 
74 }
75 
76 #endif // Include guard
SubNode(ICanDriver &can_driver, ISystemClock &system_clock, IPoolAllocator &allocator)
Definition: sub_node.hpp:58
virtual RemoveReference< Allocator >::Type & getAllocator()
Definition: sub_node.hpp:66
virtual const Scheduler & getScheduler() const
Definition: sub_node.hpp:69
Select<(MemPoolSize > 0), PoolAllocator< MemPoolSize, MemPoolBlockSize >, IPoolAllocator & >::Result Allocator
Definition: sub_node.hpp:30
virtual void registerInternalFailure(const char *msg)
Definition: sub_node.hpp:38
SubNode(ICanDriver &can_driver, ISystemClock &system_clock)
Definition: sub_node.hpp:49
std::uint64_t uint64_t
Definition: std.hpp:27
Scheduler scheduler_
Definition: sub_node.hpp:33
uint64_t getInternalFailureCount() const
Definition: sub_node.hpp:71
uint64_t internal_failure_cnt_
Definition: sub_node.hpp:35
virtual Scheduler & getScheduler()
Definition: sub_node.hpp:68
Allocator pool_allocator_
Definition: sub_node.hpp:32


uavcan_communicator
Author(s):
autogenerated on Wed Jan 11 2023 03:59:39