uc_outgoing_transfer_registry.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
3  */
4 
6 
7 namespace uavcan
8 {
9 /*
10  * OutgoingTransferRegistryKey
11  */
12 #if UAVCAN_TOSTRING
13 std::string OutgoingTransferRegistryKey::toString() const
14 {
15  char buf[40];
16  (void)snprintf(buf, sizeof(buf), "dtid=%u tt=%u dnid=%u",
18  return std::string(buf);
19 }
20 #endif
21 
22 /*
23  * OutgoingTransferRegistry
24  */
26 
28  MonotonicTime new_deadline)
29 {
30  UAVCAN_ASSERT(!new_deadline.isZero());
31  Value* p = map_.access(key);
32  if (p == UAVCAN_NULLPTR)
33  {
34  p = map_.insert(key, Value());
35  if (p == UAVCAN_NULLPTR)
36  {
37  return UAVCAN_NULLPTR;
38  }
39  UAVCAN_TRACE("OutgoingTransferRegistry", "Created %s", key.toString().c_str());
40  }
41  p->deadline = new_deadline;
42  return &p->tid;
43 }
44 
46 {
47  return UAVCAN_NULLPTR != map_.find(ExistenceCheckingPredicate(dtid, tt));
48 }
49 
51 {
52  map_.removeAllWhere(DeadlineExpiredPredicate(ts));
53 }
54 
55 }
bool exists(DataTypeID dtid, TransferType tt) const
bool isZero() const
Definition: time.hpp:123
NodeID destination_node_id_
Not applicable for message broadcasting.
static const MonotonicDuration MinEntryLifetime
static std::string toString(long x)
Definition: multiset.cpp:16
uint8_t get() const
Definition: transfer.hpp:132
TransferType
Definition: transfer.hpp:18
uint16_t get() const
Definition: data_type.hpp:69
TransferID * accessOrCreate(const OutgoingTransferRegistryKey &key, MonotonicTime new_deadline)
static MonotonicDuration fromMSec(int64_t ms)
Definition: time.hpp:41
int snprintf(char *out, std::size_t maxlen, const char *format,...)
Definition: std.hpp:73
int
Definition: libstubs.cpp:120


uavcan_communicator
Author(s):
autogenerated on Wed Jan 11 2023 03:59:40