diff --git a/libuavcan/include/uavcan/transport/outgoing_transfer_registry.hpp b/libuavcan/include/uavcan/transport/outgoing_transfer_registry.hpp index 0187855e4d..1bee6db283 100644 --- a/libuavcan/include/uavcan/transport/outgoing_transfer_registry.hpp +++ b/libuavcan/include/uavcan/transport/outgoing_transfer_registry.hpp @@ -132,32 +132,47 @@ public: : map_(allocator) { } - TransferID* accessOrCreate(const OutgoingTransferRegistryKey& key, MonotonicTime new_deadline) - { - assert(!new_deadline.isZero()); - Value* p = map_.access(key); - if (p == NULL) - { - p = map_.insert(key, Value()); - if (p == NULL) - { - return NULL; - } - UAVCAN_TRACE("OutgoingTransferRegistry", "Created %s", key.toString().c_str()); - } - p->deadline = new_deadline; - return &p->tid; - } + TransferID* accessOrCreate(const OutgoingTransferRegistryKey& key, MonotonicTime new_deadline); - bool exists(DataTypeID dtid, TransferType tt) const - { - return NULL != map_.findFirstKey(ExistenceCheckingPredicate(dtid, tt)); - } + bool exists(DataTypeID dtid, TransferType tt) const; - void cleanup(MonotonicTime ts) - { - map_.removeWhere(DeadlineExpiredPredicate(ts)); - } + void cleanup(MonotonicTime ts); }; +// ---------------------------------------------------------------------------- + +/* + * OutgoingTransferRegistry<> + */ +template +TransferID* OutgoingTransferRegistry::accessOrCreate(const OutgoingTransferRegistryKey& key, + MonotonicTime new_deadline) +{ + assert(!new_deadline.isZero()); + Value* p = map_.access(key); + if (p == NULL) + { + p = map_.insert(key, Value()); + if (p == NULL) + { + return NULL; + } + UAVCAN_TRACE("OutgoingTransferRegistry", "Created %s", key.toString().c_str()); + } + p->deadline = new_deadline; + return &p->tid; +} + +template +bool OutgoingTransferRegistry::exists(DataTypeID dtid, TransferType tt) const +{ + return NULL != map_.findFirstKey(ExistenceCheckingPredicate(dtid, tt)); +} + +template +void OutgoingTransferRegistry::cleanup(MonotonicTime ts) +{ + map_.removeWhere(DeadlineExpiredPredicate(ts)); +} + }