OTR out of line methods

This commit is contained in:
Pavel Kirienko
2014-04-08 19:07:57 +04:00
parent e6559eff9f
commit 6a68318d49
@@ -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 <int NumStaticEntries>
TransferID* OutgoingTransferRegistry<NumStaticEntries>::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 <int NumStaticEntries>
bool OutgoingTransferRegistry<NumStaticEntries>::exists(DataTypeID dtid, TransferType tt) const
{
return NULL != map_.findFirstKey(ExistenceCheckingPredicate(dtid, tt));
}
template <int NumStaticEntries>
void OutgoingTransferRegistry<NumStaticEntries>::cleanup(MonotonicTime ts)
{
map_.removeWhere(DeadlineExpiredPredicate(ts));
}
}