Fixed type signedness through the entire codebase; driver interfaces do not use starndard types now

This commit is contained in:
Pavel Kirienko
2014-03-29 22:40:15 +04:00
parent bdec81bbfa
commit 74ecfe0cc8
43 changed files with 209 additions and 210 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ public:
}
}
void add(const uint8_t* bytes, unsigned int len)
void add(const uint8_t* bytes, unsigned len)
{
assert(bytes);
while (len--)
+9 -9
View File
@@ -37,7 +37,7 @@ struct CanFrame
std::fill(data, data + sizeof(data), 0);
}
CanFrame(uint32_t id, const uint8_t* data, unsigned int dlc)
CanFrame(uint32_t id, const uint8_t* data, uint8_t dlc)
: id(id)
, dlc(dlc)
{
@@ -113,7 +113,7 @@ public:
* If the frame wasn't transmitted upon TX deadline, the driver should discard it.
* @return 1 = one frame transmitted, 0 = TX buffer full, negative for error.
*/
virtual int send(const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags) = 0;
virtual int16_t send(const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags) = 0;
/**
* Non-blocking reception.
@@ -127,19 +127,19 @@ public:
* @param [out] out_ts_utc UTC timestamp, optional, zero if unknown.
* @return 1 = one frame received, 0 = RX buffer empty, negative for error.
*/
virtual int receive(CanFrame& out_frame, MonotonicTime& out_ts_monotonic, UtcTime& out_ts_utc,
CanIOFlags& out_flags) = 0;
virtual int16_t receive(CanFrame& out_frame, MonotonicTime& out_ts_monotonic, UtcTime& out_ts_utc,
CanIOFlags& out_flags) = 0;
/**
* Configure the hardware CAN filters. @ref CanFilterConfig.
* @return 0 = success, negative for error.
*/
virtual int configureFilters(const CanFilterConfig* filter_configs, int num_configs) = 0;
virtual int16_t configureFilters(const CanFilterConfig* filter_configs, uint16_t num_configs) = 0;
/**
* Number of available hardware filters.
*/
virtual int getNumFilters() const = 0;
virtual uint16_t getNumFilters() const = 0;
/**
* Continuously incrementing counter of hardware errors.
@@ -158,12 +158,12 @@ public:
/**
* Returns the interface by index, or null pointer if the index is out of range.
*/
virtual ICanIface* getIface(int iface_index) = 0;
virtual ICanIface* getIface(uint8_t iface_index) = 0;
/**
* Total number of available CAN interfaces.
*/
virtual int getNumIfaces() const = 0;
virtual uint8_t getNumIfaces() const = 0;
/**
* Block until the deadline, or one of the specified interfaces becomes available for read or write.
@@ -173,7 +173,7 @@ public:
* @param [in] blocking_deadline Zero means non-blocking operation.
* @return Positive number of ready interfaces or negative error code.
*/
virtual int select(CanSelectMasks& inout_masks, MonotonicTime blocking_deadline) = 0;
virtual int16_t select(CanSelectMasks& inout_masks, MonotonicTime blocking_deadline) = 0;
};
}
+2 -2
View File
@@ -48,10 +48,10 @@ public:
T* get() const { return root_; }
bool isEmpty() const { return get() == NULL; }
unsigned int getLength() const
unsigned getLength() const
{
T* node = root_;
unsigned int cnt = 0;
unsigned cnt = 0;
while (node)
{
cnt++;
+11 -11
View File
@@ -21,7 +21,7 @@ namespace uavcan
* Key's default constructor must initialize the object into invalid state.
* Size of Key + Value + padding must not exceed MemPoolBlockSize.
*/
template <typename Key, typename Value, unsigned int NumStaticEntries>
template <typename Key, typename Value, unsigned NumStaticEntries>
class Map : Noncopyable
{
UAVCAN_PACKED_BEGIN
@@ -88,7 +88,7 @@ class Map : Noncopyable
KVPair* find(const Key& key)
{
for (unsigned int i = 0; i < NumStaticEntries; i++)
for (unsigned i = 0; i < NumStaticEntries; i++)
{
if (static_[i].match(key))
{
@@ -115,7 +115,7 @@ class Map : Noncopyable
{
// Looking for first EMPTY static entry
KVPair* stat = NULL;
for (unsigned int i = 0; i < NumStaticEntries; i++)
for (unsigned i = 0; i < NumStaticEntries; i++)
{
if (static_[i].match(Key()))
{
@@ -252,9 +252,9 @@ public:
template <typename Predicate>
void removeWhere(Predicate predicate)
{
unsigned int num_removed = 0;
unsigned num_removed = 0;
for (unsigned int i = 0; i < NumStaticEntries; i++)
for (unsigned i = 0; i < NumStaticEntries; i++)
{
if (!static_[i].match(Key()))
{
@@ -294,7 +294,7 @@ public:
template <typename Predicate>
const Key* findFirstKey(Predicate predicate) const
{
for (unsigned int i = 0; i < NumStaticEntries; i++)
for (unsigned i = 0; i < NumStaticEntries; i++)
{
if (!static_[i].match(Key()))
{
@@ -332,10 +332,10 @@ public:
bool isEmpty() const { return (getNumStaticPairs() == 0) && (getNumDynamicPairs() == 0); }
/// For testing
unsigned int getNumStaticPairs() const
unsigned getNumStaticPairs() const
{
unsigned int num = 0;
for (unsigned int i = 0; i < NumStaticEntries; i++)
unsigned num = 0;
for (unsigned i = 0; i < NumStaticEntries; i++)
{
if (!static_[i].match(Key()))
{
@@ -346,9 +346,9 @@ public:
}
/// For testing
unsigned int getNumDynamicPairs() const
unsigned getNumDynamicPairs() const
{
unsigned int num = 0;
unsigned num = 0;
KVGroup* p = list_.get();
while (p)
{
+13 -13
View File
@@ -26,12 +26,12 @@ namespace uavcan
enum ArrayMode { ArrayModeStatic, ArrayModeDynamic };
template <unsigned int Size>
template <unsigned Size>
class StaticArrayBase
{
public:
enum { SizeBitLen = 0 };
typedef unsigned int SizeType;
typedef unsigned SizeType;
SizeType size() const { return Size; }
SizeType capacity() const { return Size; }
@@ -55,7 +55,7 @@ protected:
};
template <unsigned int MaxSize>
template <unsigned MaxSize>
class DynamicArrayBase
{
protected:
@@ -121,7 +121,7 @@ public:
/**
* Statically allocated array with optional dynamic-like behavior
*/
template <typename T, ArrayMode ArrayMode, unsigned int MaxSize>
template <typename T, ArrayMode ArrayMode, unsigned MaxSize>
class ArrayImpl : public Select<ArrayMode == ArrayModeDynamic,
DynamicArrayBase<MaxSize>, StaticArrayBase<MaxSize> >::Result
{
@@ -196,7 +196,7 @@ public:
/**
* Bit array specialization
*/
template <unsigned int MaxSize, ArrayMode ArrayMode, CastMode CastMode>
template <unsigned MaxSize, ArrayMode ArrayMode, CastMode CastMode>
class ArrayImpl<IntegerSpec<1, SignednessUnsigned, CastMode>, ArrayMode, MaxSize>
: public std::bitset<MaxSize>
, public Select<ArrayMode == ArrayModeDynamic, DynamicArrayBase<MaxSize>, StaticArrayBase<MaxSize> >::Result
@@ -226,7 +226,7 @@ public:
template <typename T, ArrayMode ArrayMode> class ArrayImpl<T, ArrayMode, 0>;
template <typename T, ArrayMode ArrayMode, unsigned int MaxSize_>
template <typename T, ArrayMode ArrayMode, unsigned MaxSize_>
class Array : public ArrayImpl<T, ArrayMode, MaxSize_>
{
typedef ArrayImpl<T, ArrayMode, MaxSize_> Base;
@@ -377,7 +377,7 @@ public:
{
if (new_size > size())
{
unsigned int cnt = new_size - size();
unsigned cnt = new_size - size();
while (cnt--)
{
push_back(filler);
@@ -385,7 +385,7 @@ public:
}
else if (new_size < size())
{
unsigned int cnt = size() - new_size;
unsigned cnt = size() - new_size;
while (cnt--)
{
pop_back();
@@ -464,7 +464,7 @@ public:
return *this;
}
template <uavcan::ArrayMode RhsArrayMode, unsigned int RhsMaxSize>
template <uavcan::ArrayMode RhsArrayMode, unsigned RhsMaxSize>
SelfType& operator+=(const Array<T, RhsArrayMode, RhsMaxSize>& rhs)
{
typedef Array<T, RhsArrayMode, RhsMaxSize> Rhs;
@@ -520,20 +520,20 @@ public:
typedef SizeType size_type;
};
template <typename R, typename T, ArrayMode ArrayMode, unsigned int MaxSize>
template <typename R, typename T, ArrayMode ArrayMode, unsigned MaxSize>
inline bool operator==(const R& rhs, const Array<T, ArrayMode, MaxSize>& lhs)
{
return lhs.operator==(rhs);
}
template <typename R, typename T, ArrayMode ArrayMode, unsigned int MaxSize>
template <typename R, typename T, ArrayMode ArrayMode, unsigned MaxSize>
inline bool operator!=(const R& rhs, const Array<T, ArrayMode, MaxSize>& lhs)
{
return lhs.operator!=(rhs);
}
template <typename T, ArrayMode ArrayMode, unsigned int MaxSize>
template <typename T, ArrayMode ArrayMode, unsigned MaxSize>
class YamlStreamer<Array<T, ArrayMode, MaxSize> >
{
typedef Array<T, ArrayMode, MaxSize> ArrayType;
@@ -545,7 +545,7 @@ class YamlStreamer<Array<T, ArrayMode, MaxSize> >
return true;
}
static const char Good[] = {'\n', '\r', '\t'};
for (unsigned int i = 0; i < sizeof(Good) / sizeof(Good[0]); i++)
for (unsigned i = 0; i < sizeof(Good) / sizeof(Good[0]); i++)
{
if (Good[i] == c)
{
@@ -24,7 +24,7 @@ class BitStream
int bit_offset_;
uint8_t byte_cache_;
static inline unsigned int bitlenToBytelen(unsigned int bits) { return (bits + 7) / 8; }
static inline unsigned bitlenToBytelen(unsigned bits) { return (bits + 7) / 8; }
static inline void copyBitArray(const uint8_t* src_org, int src_offset, int src_len,
uint8_t* dst_org, int dst_offset)
@@ -23,7 +23,7 @@
namespace uavcan
{
template <unsigned int BitLen>
template <unsigned BitLen>
struct NativeFloatSelector
{
struct ErrorNoSuchFloat;
@@ -46,7 +46,7 @@ public:
/// UAVCAN requires rounding to nearest for all float conversions
static std::float_round_style roundstyle() { return std::round_to_nearest; }
template <unsigned int BitLen>
template <unsigned BitLen>
static typename IntegerSpec<BitLen, SignednessUnsigned, CastModeTruncate>::StorageType
toIeee(typename NativeFloatSelector<BitLen>::Type value)
{
@@ -58,7 +58,7 @@ public:
return u.i;
}
template <unsigned int BitLen>
template <unsigned BitLen>
static typename NativeFloatSelector<BitLen>::Type
toNative(typename IntegerSpec<BitLen, SignednessUnsigned, CastModeTruncate>::StorageType value)
{
@@ -83,7 +83,7 @@ IEEE754Converter::toNative<16>(typename IntegerSpec<16, SignednessUnsigned, Cast
return halfToNativeNonIeee(value);
}
template <unsigned int BitLen> struct IEEE754Limits;
template <unsigned BitLen> struct IEEE754Limits;
template <> struct IEEE754Limits<16>
{
static typename NativeFloatSelector<16>::Type max() { return 65504.0; }
@@ -101,7 +101,7 @@ template <> struct IEEE754Limits<64>
};
template <unsigned int BitLen_, CastMode CastMode>
template <unsigned BitLen_, CastMode CastMode>
class FloatSpec : public IEEE754Limits<BitLen_>
{
FloatSpec();
@@ -183,7 +183,7 @@ private:
};
template <unsigned int BitLen, CastMode CastMode>
template <unsigned BitLen, CastMode CastMode>
struct YamlStreamer<FloatSpec<BitLen, CastMode> >
{
typedef typename FloatSpec<BitLen, CastMode>::StorageType StorageType;
@@ -16,7 +16,7 @@ namespace uavcan
enum Signedness { SignednessUnsigned, SignednessSigned };
template <unsigned int BitLen_, Signedness Signedness, CastMode CastMode>
template <unsigned BitLen_, Signedness Signedness, CastMode CastMode>
class IntegerSpec
{
struct ErrorNoSuchInteger;
@@ -124,14 +124,14 @@ struct IsIntegerSpec
enum { Result = 0 };
};
template <unsigned int BitLen, Signedness Signedness, CastMode CastMode>
template <unsigned BitLen, Signedness Signedness, CastMode CastMode>
struct IsIntegerSpec<IntegerSpec<BitLen, Signedness, CastMode> >
{
enum { Result = 1 };
};
template <unsigned int BitLen, Signedness Signedness, CastMode CastMode>
template <unsigned BitLen, Signedness Signedness, CastMode CastMode>
struct YamlStreamer<IntegerSpec<BitLen, Signedness, CastMode> >
{
typedef IntegerSpec<BitLen, Signedness, CastMode> RawType;
@@ -142,7 +142,7 @@ struct YamlStreamer<IntegerSpec<BitLen, Signedness, CastMode> >
{
// Get rid of character types - we want its integer representation, not ASCII code
typedef typename Select<(sizeof(StorageType) >= sizeof(int)), StorageType,
typename Select<RawType::IsSigned, int, unsigned int>::Result >::Result TempType;
typename Select<RawType::IsSigned, int, unsigned>::Result >::Result TempType;
s << TempType(value);
}
};
@@ -68,7 +68,7 @@ static Stream& operator<<(Stream& s, const ReceivedDataStructure<DataType>& rds)
}
template <typename DataStruct_, unsigned int NumStaticReceivers_, unsigned int NumStaticBufs_>
template <typename DataStruct_, unsigned NumStaticReceivers_, unsigned NumStaticBufs_>
class TransferListenerInstantiationHelper
{
enum { DataTypeMaxByteLen = BitLenToByteLen<DataStruct_::MaxBitLen>::Result };
@@ -109,8 +109,8 @@ public:
void getDataTypeIDMask(DataTypeKind kind, DataTypeIDMask& mask) const;
unsigned int getNumMessageTypes() const { return msgs_.getLength(); }
unsigned int getNumServiceTypes() const { return srvs_.getLength(); }
unsigned getNumMessageTypes() const { return msgs_.getLength(); }
unsigned getNumServiceTypes() const { return srvs_.getLength(); }
#if UAVCAN_DEBUG
/// Required for unit testing
@@ -14,7 +14,7 @@ class IMarshalBuffer : public ITransferBuffer
{
public:
virtual const uint8_t* getDataPtr() const = 0;
virtual unsigned int getDataLength() const = 0;
virtual unsigned getDataLength() const = 0;
};
@@ -22,30 +22,30 @@ class IMarshalBufferProvider
{
public:
virtual ~IMarshalBufferProvider() { }
virtual IMarshalBuffer* getBuffer(unsigned int size) = 0;
virtual IMarshalBuffer* getBuffer(unsigned size) = 0;
};
template <unsigned int MaxSize_ = MaxTransferPayloadLen>
template <unsigned MaxSize_ = MaxTransferPayloadLen>
class MarshalBufferProvider : public IMarshalBufferProvider
{
class Buffer : public IMarshalBuffer
{
StaticTransferBuffer<MaxSize_> buf_;
int read(unsigned int offset, uint8_t* data, unsigned int len) const
int read(unsigned offset, uint8_t* data, unsigned len) const
{
return buf_.read(offset, data, len);
}
int write(unsigned int offset, const uint8_t* data, unsigned int len)
int write(unsigned offset, const uint8_t* data, unsigned len)
{
return buf_.write(offset, data, len);
}
const uint8_t* getDataPtr() const { return buf_.getRawPtr(); }
unsigned int getDataLength() const { return buf_.getMaxWritePos(); }
unsigned getDataLength() const { return buf_.getMaxWritePos(); }
public:
void reset() { buf_.reset(); }
@@ -56,7 +56,7 @@ class MarshalBufferProvider : public IMarshalBufferProvider
public:
enum { MaxSize = MaxSize_ };
IMarshalBuffer* getBuffer(unsigned int size)
IMarshalBuffer* getBuffer(unsigned size)
{
if (size > MaxSize)
{
+2 -2
View File
@@ -27,8 +27,8 @@ namespace uavcan
{
template <std::size_t MemPoolSize_,
unsigned int OutgoingTransferRegistryStaticEntries = 10,
unsigned int OutgoingTransferMaxPayloadLen = MaxTransferPayloadLen>
unsigned OutgoingTransferRegistryStaticEntries = 10,
unsigned OutgoingTransferMaxPayloadLen = MaxTransferPayloadLen>
class Node : public INode
{
enum
+1 -1
View File
@@ -49,7 +49,7 @@ public:
void add(DeadlineHandler* mdh);
void remove(DeadlineHandler* mdh);
bool doesExist(const DeadlineHandler* mdh) const;
unsigned int getNumHandlers() const { return handlers_.getLength(); }
unsigned getNumHandlers() const { return handlers_.getLength(); }
MonotonicTime pollAndGetMonotonicTime(ISystemClock& sysclock);
MonotonicTime getEarliestDeadline() const;
@@ -27,8 +27,8 @@ template <typename DataType_,
typename Callback = void (*)(const ReceivedDataStructure<typename DataType_::Request>&,
typename DataType_::Response&),
#endif
unsigned int NumStaticReceivers = 2,
unsigned int NumStaticBufs = 1>
unsigned NumStaticReceivers = 2,
unsigned NumStaticBufs = 1>
class ServiceServer : public GenericSubscriber<DataType_, typename DataType_::Request,
typename TransferListenerInstantiationHelper<typename DataType_::Request,
NumStaticReceivers,
+2 -2
View File
@@ -25,8 +25,8 @@ template <typename DataType_,
#else
typename Callback = void (*)(const ReceivedDataStructure<DataType_>&),
#endif
unsigned int NumStaticReceivers = 2,
unsigned int NumStaticBufs = 1>
unsigned NumStaticReceivers = 2,
unsigned NumStaticBufs = 1>
class Subscriber : public GenericSubscriber<DataType_, DataType_,
typename TransferListenerInstantiationHelper<DataType_,
NumStaticReceivers,
@@ -150,9 +150,9 @@ class CanIOManager : Noncopyable
CanTxQueue tx_queues_[MaxCanIfaces];
IfaceFrameCounters counters_[MaxCanIfaces];
int sendToIface(int iface_index, const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags);
int sendFromTxQueue(int iface_index);
int makePendingTxMask() const;
int sendToIface(uint8_t iface_index, const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags);
int sendFromTxQueue(uint8_t iface_index);
uint8_t makePendingTxMask() const;
public:
CanIOManager(ICanDriver& driver, IAllocator& allocator, ISystemClock& sysclock)
@@ -168,9 +168,9 @@ public:
}
}
int getNumIfaces() const;
uint8_t getNumIfaces() const;
CanIfacePerfCounters getIfacePerfCounters(int iface_index) const;
CanIfacePerfCounters getIfacePerfCounters(uint8_t iface_index) const;
/**
* Returns:
@@ -179,7 +179,7 @@ public:
* negative - failure
*/
int send(const CanFrame& frame, MonotonicTime tx_deadline, MonotonicTime blocking_deadline,
int iface_mask, CanTxQueue::Qos qos, CanIOFlags flags);
uint8_t iface_mask, CanTxQueue::Qos qos, CanIOFlags flags);
int receive(CanRxFrame& out_frame, MonotonicTime blocking_deadline, CanIOFlags& out_flags);
};
+1 -1
View File
@@ -40,7 +40,7 @@ public:
value_ = ((value_ << 8) ^ Table[((value_ >> 8) ^ byte) & 0xFF]) & 0xFFFF;
}
void add(const uint8_t* bytes, unsigned int len)
void add(const uint8_t* bytes, unsigned len)
{
assert(bytes);
while (len--)
@@ -48,7 +48,7 @@ public:
void add(LoopbackFrameListenerBase* listener);
void remove(LoopbackFrameListenerBase* listener);
bool doesExist(const LoopbackFrameListenerBase* listener) const;
unsigned int getNumListeners() const { return listeners_.getLength(); }
unsigned getNumListeners() const { return listeners_.getLength(); }
void invokeListeners(RxFrame& frame);
};
+2 -2
View File
@@ -57,9 +57,9 @@ public:
}
int getMaxPayloadLen() const;
int setPayload(const uint8_t* data, int len);
int setPayload(const uint8_t* data, unsigned len);
int getPayloadLen() const { return payload_len_; }
unsigned getPayloadLen() const { return payload_len_; }
const uint8_t* getPayloadPtr() const { return payload_; }
TransferType getTransferType() const { return transfer_type_; }
@@ -27,7 +27,7 @@ public:
void addError() { errors_++; }
void addErrors(unsigned int errors)
void addErrors(unsigned errors)
{
errors_ += errors;
}
@@ -25,8 +25,8 @@ class ITransferBuffer
public:
virtual ~ITransferBuffer() { }
virtual int read(unsigned int offset, uint8_t* data, unsigned int len) const = 0;
virtual int write(unsigned int offset, const uint8_t* data, unsigned int len) = 0;
virtual int read(unsigned offset, uint8_t* data, unsigned len) const = 0;
virtual int write(unsigned offset, const uint8_t* data, unsigned len) = 0;
};
/**
@@ -108,21 +108,21 @@ class DynamicTransferBufferManagerEntry
static Block* instantiate(IAllocator& allocator);
static void destroy(Block*& obj, IAllocator& allocator);
void read(uint8_t*& outptr, unsigned int target_offset,
unsigned int& total_offset, unsigned int& left_to_read);
void write(const uint8_t*& inptr, unsigned int target_offset,
unsigned int& total_offset, unsigned int& left_to_write);
void read(uint8_t*& outptr, unsigned target_offset,
unsigned& total_offset, unsigned& left_to_read);
void write(const uint8_t*& inptr, unsigned target_offset,
unsigned& total_offset, unsigned& left_to_write);
};
IAllocator& allocator_;
LinkedListRoot<Block> blocks_; // Blocks are ordered from lower to higher buffer offset
unsigned int max_write_pos_;
const unsigned int max_size_;
unsigned max_write_pos_;
const unsigned max_size_;
void resetImpl();
public:
DynamicTransferBufferManagerEntry(IAllocator& allocator, unsigned int max_size)
DynamicTransferBufferManagerEntry(IAllocator& allocator, unsigned max_size)
: allocator_(allocator)
, max_write_pos_(0)
, max_size_(max_size)
@@ -137,22 +137,22 @@ public:
resetImpl();
}
static DynamicTransferBufferManagerEntry* instantiate(IAllocator& allocator, unsigned int max_size);
static DynamicTransferBufferManagerEntry* instantiate(IAllocator& allocator, unsigned max_size);
static void destroy(DynamicTransferBufferManagerEntry*& obj, IAllocator& allocator);
int read(unsigned int offset, uint8_t* data, unsigned int len) const;
int write(unsigned int offset, const uint8_t* data, unsigned int len);
int read(unsigned offset, uint8_t* data, unsigned len) const;
int write(unsigned offset, const uint8_t* data, unsigned len);
};
UAVCAN_PACKED_END
/**
* Standalone static buffer
*/
template <unsigned int Size>
template <unsigned Size>
class StaticTransferBuffer : public ITransferBuffer
{
uint8_t data_[Size];
unsigned int max_write_pos_;
unsigned max_write_pos_;
public:
StaticTransferBuffer()
@@ -162,7 +162,7 @@ public:
std::fill(data_, data_ + Size, 0);
}
int read(unsigned int offset, uint8_t* data, unsigned int len) const
int read(unsigned offset, uint8_t* data, unsigned len) const
{
if (!data)
{
@@ -182,7 +182,7 @@ public:
return len;
}
int write(unsigned int offset, const uint8_t* data, unsigned int len)
int write(unsigned offset, const uint8_t* data, unsigned len)
{
if (!data)
{
@@ -214,14 +214,14 @@ public:
uint8_t* getRawPtr() { return data_; }
const uint8_t* getRawPtr() const { return data_; }
unsigned int getMaxWritePos() const { return max_write_pos_; }
void setMaxWritePos(unsigned int value) { max_write_pos_ = value; }
unsigned getMaxWritePos() const { return max_write_pos_; }
void setMaxWritePos(unsigned value) { max_write_pos_ = value; }
};
/**
* Statically allocated storage for buffer manager
*/
template <unsigned int Size>
template <unsigned Size>
class StaticTransferBufferManagerEntry : public TransferBufferManagerEntry
{
StaticTransferBuffer<Size> buf_;
@@ -232,12 +232,12 @@ class StaticTransferBufferManagerEntry : public TransferBufferManagerEntry
}
public:
int read(unsigned int offset, uint8_t* data, unsigned int len) const
int read(unsigned offset, uint8_t* data, unsigned len) const
{
return buf_.read(offset, data, len);
}
int write(unsigned int offset, const uint8_t* data, unsigned int len)
int write(unsigned offset, const uint8_t* data, unsigned len)
{
return buf_.write(offset, data, len);
}
@@ -310,7 +310,7 @@ public:
/**
* Buffer manager implementation.
*/
template <unsigned int MaxBufSize, unsigned int NumStaticBufs>
template <unsigned MaxBufSize, unsigned NumStaticBufs>
class TransferBufferManager : public ITransferBufferManager, Noncopyable
{
typedef StaticTransferBufferManagerEntry<MaxBufSize> StaticBufferType;
@@ -321,7 +321,7 @@ class TransferBufferManager : public ITransferBufferManager, Noncopyable
StaticBufferType* findFirstStatic(const TransferBufferManagerKey& key)
{
for (unsigned int i = 0; i < NumStaticBufs; i++)
for (unsigned i = 0; i < NumStaticBufs; i++)
{
if (static_buffers_[i].getKey() == key)
{
@@ -476,12 +476,12 @@ public:
bool isEmpty() const { return (getNumStaticBuffers() == 0) && (getNumDynamicBuffers() == 0); }
unsigned int getNumDynamicBuffers() const { return dynamic_buffers_.getLength(); }
unsigned getNumDynamicBuffers() const { return dynamic_buffers_.getLength(); }
unsigned int getNumStaticBuffers() const
unsigned getNumStaticBuffers() const
{
unsigned int res = 0;
for (unsigned int i = 0; i < NumStaticBufs; i++)
unsigned res = 0;
for (unsigned i = 0; i < NumStaticBufs; i++)
{
if (!static_buffers_[i].isEmpty())
{
@@ -31,7 +31,7 @@ class IncomingTransfer : public ITransferBuffer
uint8_t iface_index_;
/// That's a no-op, asserts in debug builds
int write(unsigned int offset, const uint8_t* data, unsigned int len);
int write(unsigned offset, const uint8_t* data, unsigned len);
protected:
IncomingTransfer(MonotonicTime ts_mono, UtcTime ts_utc, TransferType transfer_type,
@@ -67,7 +67,7 @@ class SingleFrameIncomingTransfer : public IncomingTransfer
const uint8_t payload_len_;
public:
SingleFrameIncomingTransfer(const RxFrame& frm);
int read(unsigned int offset, uint8_t* data, unsigned int len) const;
int read(unsigned offset, uint8_t* data, unsigned len) const;
};
/**
@@ -79,7 +79,7 @@ class MultiFrameIncomingTransfer : public IncomingTransfer, Noncopyable
public:
MultiFrameIncomingTransfer(MonotonicTime ts_mono, UtcTime ts_utc, const RxFrame& last_frame,
TransferBufferAccessor& tba);
int read(unsigned int offset, uint8_t* data, unsigned int len) const;
int read(unsigned offset, uint8_t* data, unsigned len) const;
void release() { buf_acc_.remove(); }
};
@@ -117,7 +117,7 @@ public:
/**
* This class should be derived by transfer receivers (subscribers, servers).
*/
template <unsigned int MaxBufSize, unsigned int NumStaticBufs, unsigned int NumStaticReceivers>
template <unsigned MaxBufSize, unsigned NumStaticBufs, unsigned NumStaticReceivers>
class TransferListener : public TransferListenerBase
{
typedef TransferBufferManager<MaxBufSize, NumStaticBufs> BufferManager;
@@ -203,7 +203,7 @@ public:
/**
* This class should be derived by callers.
*/
template <unsigned int MaxBufSize>
template <unsigned MaxBufSize>
class ServiceResponseTransferListener : public TransferListener<MaxBufSize, 1, 1>
{
public: