mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 02:33:40 +08:00
Explicit constructors
This commit is contained in:
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
DataTypeID() : value_(0xFFFF) { }
|
||||
|
||||
DataTypeID(uint16_t id)
|
||||
DataTypeID(uint16_t id) // Implicit
|
||||
: value_(id)
|
||||
{
|
||||
assert(isValid());
|
||||
|
||||
@@ -164,7 +164,7 @@ public:
|
||||
#if !UAVCAN_TINY
|
||||
|
||||
// This instantiation will not be valid in UAVCAN_TINY mode
|
||||
Map(IPoolAllocator& allocator)
|
||||
explicit Map(IPoolAllocator& allocator)
|
||||
: MapBase<Key, Value>(static_, NumStaticEntries, allocator)
|
||||
{ }
|
||||
|
||||
@@ -178,7 +178,7 @@ template <typename Key, typename Value>
|
||||
class UAVCAN_EXPORT Map<Key, Value, 0> : public MapBase<Key, Value>
|
||||
{
|
||||
public:
|
||||
Map(IPoolAllocator& allocator)
|
||||
explicit Map(IPoolAllocator& allocator)
|
||||
#if UAVCAN_TINY
|
||||
: MapBase<Key, Value>(allocator)
|
||||
#else
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
ResultOk = 1
|
||||
};
|
||||
|
||||
BitStream(ITransferBuffer& buf)
|
||||
explicit BitStream(ITransferBuffer& buf)
|
||||
: buf_(buf)
|
||||
, bit_offset_(0)
|
||||
, byte_cache_(0)
|
||||
|
||||
@@ -68,7 +68,7 @@ class UAVCAN_EXPORT CharArrayFormatter
|
||||
public:
|
||||
typedef ArrayType_ ArrayType;
|
||||
|
||||
CharArrayFormatter(ArrayType& array)
|
||||
explicit CharArrayFormatter(ArrayType& array)
|
||||
: array_(array)
|
||||
{ }
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class UAVCAN_EXPORT ScalarCodec
|
||||
int decodeBytesImpl(uint8_t* bytes, unsigned bitlen);
|
||||
|
||||
public:
|
||||
ScalarCodec(BitStream& stream)
|
||||
explicit ScalarCodec(BitStream& stream)
|
||||
: stream_(stream)
|
||||
{ }
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ protected:
|
||||
INode& node_;
|
||||
uint32_t failure_count_;
|
||||
|
||||
GenericSubscriberBase(INode& node)
|
||||
explicit GenericSubscriberBase(INode& node)
|
||||
: node_(node)
|
||||
, failure_count_(0)
|
||||
{ }
|
||||
|
||||
@@ -37,7 +37,7 @@ class UAVCAN_EXPORT GlobalDataTypeRegistry : Noncopyable
|
||||
struct EntryInsertionComparator
|
||||
{
|
||||
const DataTypeID id;
|
||||
EntryInsertionComparator(Entry* dtd) : id(dtd->descriptor.getID()) { }
|
||||
explicit EntryInsertionComparator(Entry* dtd) : id(dtd->descriptor.getID()) { }
|
||||
bool operator()(const Entry* entry) const
|
||||
{
|
||||
assert(entry);
|
||||
|
||||
@@ -75,7 +75,7 @@ protected:
|
||||
MonotonicDuration request_timeout_;
|
||||
bool pending_;
|
||||
|
||||
ServiceClientBase(INode& node)
|
||||
explicit ServiceClientBase(INode& node)
|
||||
: DeadlineHandler(node.getScheduler())
|
||||
, request_timeout_(getDefaultRequestTimeout())
|
||||
, pending_(false)
|
||||
|
||||
@@ -59,7 +59,7 @@ class UAVCAN_EXPORT NetworkCompatibilityChecker : Noncopyable
|
||||
int checkNodes();
|
||||
|
||||
public:
|
||||
NetworkCompatibilityChecker(INode& node)
|
||||
explicit NetworkCompatibilityChecker(INode& node)
|
||||
: ns_sub_(node)
|
||||
, cats_cln_(node)
|
||||
, checking_dtkind_(DataTypeKindService)
|
||||
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
{
|
||||
const CanFrame& frm_;
|
||||
public:
|
||||
PriorityInsertionComparator(const CanFrame& frm) : frm_(frm) { }
|
||||
explicit PriorityInsertionComparator(const CanFrame& frm) : frm_(frm) { }
|
||||
bool operator()(const Entry* entry)
|
||||
{
|
||||
assert(entry);
|
||||
|
||||
@@ -24,7 +24,7 @@ class UAVCAN_EXPORT LoopbackFrameListenerBase : public LinkedListNode<LoopbackFr
|
||||
Dispatcher& dispatcher_;
|
||||
|
||||
protected:
|
||||
LoopbackFrameListenerBase(Dispatcher& dispatcher)
|
||||
explicit LoopbackFrameListenerBase(Dispatcher& dispatcher)
|
||||
: dispatcher_(dispatcher)
|
||||
{ }
|
||||
|
||||
@@ -70,7 +70,7 @@ class UAVCAN_EXPORT Dispatcher : Noncopyable
|
||||
{
|
||||
const DataTypeID id_;
|
||||
public:
|
||||
DataTypeIDInsertionComparator(DataTypeID id) : id_(id) { }
|
||||
explicit DataTypeIDInsertionComparator(DataTypeID id) : id_(id) { }
|
||||
bool operator()(const TransferListenerBase* listener) const
|
||||
{
|
||||
assert(listener);
|
||||
|
||||
@@ -84,7 +84,7 @@ class UAVCAN_EXPORT OutgoingTransferRegistry : public IOutgoingTransferRegistry,
|
||||
const MonotonicTime ts_;
|
||||
|
||||
public:
|
||||
DeadlineExpiredPredicate(MonotonicTime ts)
|
||||
explicit DeadlineExpiredPredicate(MonotonicTime ts)
|
||||
: ts_(ts)
|
||||
{ }
|
||||
|
||||
@@ -122,7 +122,7 @@ class UAVCAN_EXPORT OutgoingTransferRegistry : public IOutgoingTransferRegistry,
|
||||
Map<OutgoingTransferRegistryKey, Value, NumStaticEntries> map_;
|
||||
|
||||
public:
|
||||
OutgoingTransferRegistry(IPoolAllocator& allocator)
|
||||
explicit OutgoingTransferRegistry(IPoolAllocator& allocator)
|
||||
: map_(allocator)
|
||||
{ }
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
|
||||
NodeID() : value_(ValueInvalid) { }
|
||||
|
||||
NodeID(uint8_t value)
|
||||
NodeID(uint8_t value) // Implicit
|
||||
: value_(value)
|
||||
{
|
||||
assert(isValid());
|
||||
|
||||
@@ -79,7 +79,7 @@ protected:
|
||||
public:
|
||||
TransferBufferManagerEntry() { }
|
||||
|
||||
TransferBufferManagerEntry(const TransferBufferManagerKey& key)
|
||||
explicit TransferBufferManagerEntry(const TransferBufferManagerKey& key)
|
||||
: key_(key)
|
||||
{ }
|
||||
|
||||
@@ -298,7 +298,7 @@ class UAVCAN_EXPORT TransferBufferManager : public TransferBufferManagerImpl
|
||||
}
|
||||
|
||||
public:
|
||||
TransferBufferManager(IPoolAllocator& allocator)
|
||||
explicit TransferBufferManager(IPoolAllocator& allocator)
|
||||
: TransferBufferManagerImpl(MaxBufSize, allocator)
|
||||
{
|
||||
#if UAVCAN_TINY
|
||||
@@ -317,7 +317,7 @@ class UAVCAN_EXPORT TransferBufferManager<MaxBufSize, 0> : public TransferBuffer
|
||||
}
|
||||
|
||||
public:
|
||||
TransferBufferManager(IPoolAllocator& allocator)
|
||||
explicit TransferBufferManager(IPoolAllocator& allocator)
|
||||
: TransferBufferManagerImpl(MaxBufSize, allocator)
|
||||
{
|
||||
StaticAssert<(MaxBufSize > 0)>::check();
|
||||
|
||||
@@ -66,7 +66,7 @@ class UAVCAN_EXPORT SingleFrameIncomingTransfer : public IncomingTransfer
|
||||
const uint8_t* const payload_;
|
||||
const uint8_t payload_len_;
|
||||
public:
|
||||
SingleFrameIncomingTransfer(const RxFrame& frm);
|
||||
explicit SingleFrameIncomingTransfer(const RxFrame& frm);
|
||||
int read(unsigned offset, uint8_t* data, unsigned len) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
std::fill(data_.pool, data_.pool + sizeof(T), 0);
|
||||
}
|
||||
|
||||
LazyConstructor(const LazyConstructor<T>& rhs)
|
||||
LazyConstructor(const LazyConstructor<T>& rhs) // Implicit
|
||||
: ptr_(NULL)
|
||||
{
|
||||
std::fill(data_.pool, data_.pool + sizeof(T), 0);
|
||||
|
||||
@@ -40,7 +40,7 @@ bool DeadlineHandler::isRunning() const
|
||||
struct MonotonicDeadlineHandlerInsertionComparator
|
||||
{
|
||||
const MonotonicTime ts;
|
||||
MonotonicDeadlineHandlerInsertionComparator(MonotonicTime ts) : ts(ts) { }
|
||||
explicit MonotonicDeadlineHandlerInsertionComparator(MonotonicTime ts) : ts(ts) { }
|
||||
bool operator()(const DeadlineHandler* t) const
|
||||
{
|
||||
return t->getDeadline() > ts;
|
||||
|
||||
@@ -61,7 +61,7 @@ class SystemClock : public uavcan::ISystemClock
|
||||
}
|
||||
|
||||
public:
|
||||
SystemClock(ClockAdjustmentMode adj_mode = detectPreferredClockAdjustmentMode())
|
||||
explicit SystemClock(ClockAdjustmentMode adj_mode = detectPreferredClockAdjustmentMode())
|
||||
: gradual_adj_limit_(uavcan::UtcDuration::fromMSec(4000))
|
||||
, adj_mode_(adj_mode)
|
||||
, step_adj_cnt_(0)
|
||||
|
||||
@@ -15,7 +15,7 @@ class Exception : public std::runtime_error
|
||||
const int errno_;
|
||||
|
||||
public:
|
||||
Exception(const std::string& descr)
|
||||
explicit Exception(const std::string& descr)
|
||||
: std::runtime_error(descr)
|
||||
, errno_(errno)
|
||||
{ }
|
||||
|
||||
@@ -34,7 +34,7 @@ struct DriverPack
|
||||
SystemClock clock;
|
||||
SocketCanDriver can;
|
||||
|
||||
DriverPack(ClockAdjustmentMode clock_adjustment_mode)
|
||||
explicit DriverPack(ClockAdjustmentMode clock_adjustment_mode)
|
||||
: clock(clock_adjustment_mode)
|
||||
, can(clock)
|
||||
{ }
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
/**
|
||||
* Takes ownership of the driver container.
|
||||
*/
|
||||
Node(DriverPackPtr driver_pack)
|
||||
explicit Node(DriverPackPtr driver_pack)
|
||||
: uavcan::Node<NodeMemPoolSize>(driver_pack->can, driver_pack->clock)
|
||||
, driver_pack_(driver_pack)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user