Jetson Linux API 参考文档

32.7.4 版本
UUID.h
前往此文件的文档。
1 /*
2  * 版权所有 (c) 2016-2021, NVIDIA CORPORATION。保留所有权利。
3  *
4  * 只要满足以下条件,则允许以源代码和二进制形式重新分发和使用,无论是否
5  * 经过修改:
6  *
7  * * 源代码的重新分发必须保留以上版权声明、
8  * 此条件列表以及以下免责声明。
9  *
10  * * 二进制形式的重新分发必须在随发行版提供的
11  * 文档和/或其他材料中复制以上版权声明、此条件列表以及以下免责声明。
12  *
13  * * 未经 NVIDIA CORPORATION 或其名称的书面许可,不得使用 NVIDIA CORPORATION 的名称或其
14  * 贡献者的名称来认可或推广源自本软件的产品。
15  *
16  * 本软件由版权所有者``按原样''提供,并且不作任何明示或暗示的担保,包括但不限于
17  * 对适销性和特定用途适用性的暗示担保。在任何情况下,版权所有者或
18  * 贡献者均不对任何直接、间接、偶然、特殊、
19  * 惩戒性或后果性损害(包括但不限于
20  * 替代商品或服务的采购;使用、数据或
21  * 利润损失;或业务中断)承担任何责任,无论其原因和任何责任理论,
22  * 无论是合同、严格责任还是侵权行为
23  * (包括疏忽或其他原因)以任何方式因使用本软件而引起,即使已被告知可能发生此类损害。
24  *
25  *
26  */
27 
28 
36 #ifndef _ARGUS_UUID_H
37 #define _ARGUS_UUID_H
38 
39 #include <stdint.h>
40 #include <cstring>
41 
42 namespace Argus
43 {
44 
45 const uint32_t MAX_UUID_NAME_SIZE = 32;
46 
50 struct UUID
51 {
52  uint32_t time_low;
53  uint16_t time_mid;
55  uint16_t clock_seq;
56  uint8_t node[6];
57 
58  bool operator==(const UUID &r) const
59  {
60  return memcmp(this, &r, sizeof(UUID)) == 0;
61  }
62 
63  bool operator<(const UUID &r) const
64  {
65  return memcmp(this, &r, sizeof(UUID)) < 0;
66  }
67 };
68 
72 class NamedUUID : public UUID
73 {
74 public
75  NamedUUID(uint32_t time_low_
76  , uint16_t time_mid_
77  , uint16_t time_hi_and_version_
78  , uint16_t clock_seq_
79  , uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5
80  , const char* name)
81  {
82  time_low = time_low_;
83  time_mid = time_mid_;
84  time_hi_and_version = time_hi_and_version_;
85  clock_seq = clock_seq_;
86  node[0] = c0; node[1] = c1; node[2] = c2; node[3] = c3; node[4] = c4; node[5] = c5;
87  strncpy(m_name, name, sizeof(m_name)-1);
88  m_name[sizeof(m_name)-1] = '\0';
89  }
90 
91  NamedUUID(const NamedUUID& copied)
92  : UUID(copied)
93  {
94  memcpy(m_name, copied.m_name, (strnlen(copied.m_name, (sizeof(m_name) - 1)) + 1));
95  m_name[sizeof(m_name)-1] = '\0';
96  }
97 
98  NamedUUID& operator=(const NamedUUID& copied)
99  {
100  static_cast<UUID&>(*this) = copied;
101 
102  return *this;
103  }
104 
105  bool operator==(const NamedUUID& compared) const
106  {
107  return static_cast<const UUID&>(*this) == compared;
108  }
109 
110  bool operator!=(const NamedUUID& compared) const
111  {
112  return !(static_cast<const UUID&>(*this) == compared);
113  }
114 
115  const char* getName() const { return m_name; }
116 
117 private
118  char m_name[MAX_UUID_NAME_SIZE];
119 
120  NamedUUID();
121 };
122 
124 #define DEFINE_UUID(TYPE, NAME, l, s0, s1, s2, c0,c1,c2,c3,c4,c5) \
125  static const TYPE NAME(0x##l, 0x##s0, 0x##s1, 0x##s2, \
126  0x##c0, 0x##c1, 0x##c2, 0x##c3, 0x##c4, 0x##c5, #NAME);
127 
128 #define DEFINE_NAMED_UUID_CLASS(NAME) \
129  class NAME : public NamedUUID \
130  { \
131  public: \
132  NAME(uint32_t time_low_ \
133  , uint16_t time_mid_ \
134  , uint16_t time_hi_and_version_ \
135  , uint16_t clock_seq_ \
136  , uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5 \
137  , const char* name) \
138  : NamedUUID(time_low_, time_mid_, time_hi_and_version_, clock_seq_, \
139  c0, c1, c2, c3, c4, c5, name) \
140  {} \
141  private: \
142  NAME();\
143  };
144 
145 } // namespace Argus
146 
147 #endif // _ARGUS_UUID_H
Argus::MAX_UUID_NAME_SIZE
const uint32_t MAX_UUID_NAME_SIZE
Definition: UUID.h:45
Argus::NamedUUID
带名称的通用唯一标识符(用于调试目的)。
Definition: UUID.h:72
Argus
Definition: BayerAverageMap.h:39
Argus::UUID::operator<
bool operator<(const UUID &r) const
Definition: UUID.h:63
Argus::UUID::clock_seq
uint16_t clock_seq
Definition: UUID.h:55
Argus::NamedUUID::getName
const char * getName() const
Definition: UUID.h:115
Argus::UUID::time_mid
uint16_t time_mid
Definition: UUID.h:53
Argus::NamedUUID::operator!=
bool operator!=(const NamedUUID &compared) const
Definition: UUID.h:110
Argus::NamedUUID::operator=
NamedUUID & operator=(const NamedUUID &copied)
Definition: UUID.h:98
Argus::UUID::operator==
bool operator==(const UUID &r) const
Definition: UUID.h:58
Argus::NamedUUID::NamedUUID
NamedUUID(uint32_t time_low_, uint16_t time_mid_, uint16_t time_hi_and_version_, uint16_t clock_seq_, uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5, const char *name)
Definition: UUID.h:75
Argus::UUID
通用唯一标识符。
Definition: UUID.h:50
Argus::NamedUUID::operator==
bool operator==(const NamedUUID &compared) const
Definition: UUID.h:105
Argus::UUID::time_hi_and_version
uint16_t time_hi_and_version
Definition: UUID.h:54
Argus::UUID::node
uint8_t node[6]
Definition: UUID.h:56
Argus::NamedUUID::NamedUUID
NamedUUID(const NamedUUID &copied)
Definition: UUID.h:91
Argus::UUID::time_low
uint32_t time_low
Definition: UUID.h:52
. All rights reserved.