Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UAVCAN UAVCAN_Subscriber
sub_node.hpp
00001 /* 00002 * Copyright (C) 2015 Pavel Kirienko <pavel.kirienko@gmail.com> 00003 */ 00004 00005 #ifndef UAVCAN_SUB_NODE_NODE_HPP_INCLUDED 00006 #define UAVCAN_SUB_NODE_NODE_HPP_INCLUDED 00007 00008 #include <cassert> 00009 #include <uavcan/build_config.hpp> 00010 #include <uavcan/node/abstract_node.hpp> 00011 00012 #if UAVCAN_TINY 00013 # error "This functionality is not available in tiny mode" 00014 #endif 00015 00016 namespace uavcan 00017 { 00018 /** 00019 * This node object can be used in multiprocess UAVCAN nodes. 00020 * Please refer to the @ref Node<> for documentation concerning the template arguments; refer to the tutorials 00021 * to lean how to use libuavcan in multiprocess applications. 00022 */ 00023 template <std::size_t MemPoolSize = 0> 00024 class UAVCAN_EXPORT SubNode : public INode 00025 { 00026 typedef typename 00027 Select<(MemPoolSize > 0), 00028 PoolAllocator<MemPoolSize, MemPoolBlockSize>, // If pool size is specified, use default allocator 00029 IPoolAllocator& // Otherwise use reference to user-provided allocator 00030 >::Result Allocator; 00031 00032 Allocator pool_allocator_; 00033 Scheduler scheduler_; 00034 00035 uint64_t internal_failure_cnt_; 00036 00037 protected: 00038 virtual void registerInternalFailure(const char* msg) 00039 { 00040 internal_failure_cnt_++; 00041 UAVCAN_TRACE("Node", "Internal failure: %s", msg); 00042 (void)msg; 00043 } 00044 00045 public: 00046 /** 00047 * This overload is only valid if MemPoolSize > 0. 00048 */ 00049 SubNode(ICanDriver& can_driver, 00050 ISystemClock& system_clock) : 00051 scheduler_(can_driver, pool_allocator_, system_clock), 00052 internal_failure_cnt_(0) 00053 { } 00054 00055 /** 00056 * This overload is only valid if MemPoolSize == 0. 00057 */ 00058 SubNode(ICanDriver& can_driver, 00059 ISystemClock& system_clock, 00060 IPoolAllocator& allocator) : 00061 pool_allocator_(allocator), 00062 scheduler_(can_driver, pool_allocator_, system_clock), 00063 internal_failure_cnt_(0) 00064 { } 00065 00066 virtual typename RemoveReference<Allocator>::Type& getAllocator() { return pool_allocator_; } 00067 00068 virtual Scheduler& getScheduler() { return scheduler_; } 00069 virtual const Scheduler& getScheduler() const { return scheduler_; } 00070 00071 uint64_t getInternalFailureCount() const { return internal_failure_cnt_; } 00072 }; 00073 00074 } 00075 00076 #endif // Include guard
Generated on Tue Jul 12 2022 17:17:34 by
