L4T Multimedia API Reference

27.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UUID.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA CORPORATION nor the names of its
13  * contributors may be used to endorse or promote products derived
14  * from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
37 #ifndef _ARGUS_UUID_H
38 #define _ARGUS_UUID_H
39 
40 #include <stdint.h>
41 #include <cstring>
42 
52 namespace Argus
53 {
54 
55 const uint32_t MAX_UUID_NAME_SIZE = 32;
56 
60 struct UUID
61 {
62  uint32_t time_low;
63  uint16_t time_mid;
65  uint16_t clock_seq;
66  uint8_t node[6];
67 };
68 
69 bool operator==(const UUID& l, const UUID& r);
70 bool operator<(const UUID& l, const UUID& r);
71 
75 class NamedUUID : public UUID
76 {
77 public:
78  NamedUUID(uint32_t time_low_
79  , uint16_t time_mid_
80  , uint16_t time_hi_and_version_
81  , uint16_t clock_seq_
82  , uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5
83  , const char* name)
84  {
85  time_low = time_low_;
86  time_mid = time_mid_;
87  time_hi_and_version = time_hi_and_version_;
88  clock_seq = clock_seq_;
89  node[0] = c0; node[1] = c1; node[2] = c2; node[3] = c3; node[4] = c4; node[5] = c5;
90  strncpy(m_name, name, sizeof(m_name)-1);
91  m_name[sizeof(m_name)-1] = '\0';
92  }
93 
94  NamedUUID(const NamedUUID& copied)
95  : UUID(copied)
96  {
97  strncpy(m_name, copied.m_name, sizeof(m_name)-1);
98  m_name[sizeof(m_name)-1] = '\0';
99  }
100 
101  NamedUUID& operator=(const NamedUUID& copied)
102  {
103  static_cast<UUID&>(*this) = copied;
104 
105  return *this;
106  }
107 
108  bool operator==(const NamedUUID& compared) const
109  {
110  return static_cast<const UUID&>(*this) == compared;
111  }
112 
113  bool operator!=(const NamedUUID& compared) const
114  {
115  return !(static_cast<const UUID&>(*this) == compared);
116  }
117 
118  const char* getName() const { return m_name; }
119 
120 private:
121  char m_name[MAX_UUID_NAME_SIZE];
122 
123  NamedUUID();
124 };
125 
127 #define DEFINE_UUID(TYPE, NAME, l, s0, s1, s2, c0,c1,c2,c3,c4,c5) \
128  static const TYPE NAME(0x##l, 0x##s0, 0x##s1, 0x##s2, \
129  0x##c0, 0x##c1, 0x##c2, 0x##c3, 0x##c4, 0x##c0, #NAME);
130 
131 #define DEFINE_NAMED_UUID_CLASS(NAME) \
132  class NAME : public NamedUUID \
133  { \
134  public: \
135  NAME(uint32_t time_low_ \
136  , uint16_t time_mid_ \
137  , uint16_t time_hi_and_version_ \
138  , uint16_t clock_seq_ \
139  , uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5 \
140  , const char* name) \
141  : NamedUUID(time_low_, time_mid_, time_hi_and_version_, clock_seq_, \
142  c0, c1, c2, c3, c4, c5, name) \
143  {} \
144  private: \
145  NAME();\
146  };
147 
148 } // namespace Argus
150 #endif // _ARGUS_UUID_H
NamedUUID(const NamedUUID &copied)
Definition: UUID.h:94
bool operator<(const UUID &l, const UUID &r)
uint16_t clock_seq
Definition: UUID.h:65
uint16_t time_hi_and_version
Definition: UUID.h:64
bool operator==(const UUID &l, const UUID &r)
uint32_t time_low
Definition: UUID.h:62
UUID.
Definition: UUID.h:60
bool operator==(const NamedUUID &compared) const
Definition: UUID.h:108
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:78
uint8_t node[6]
Definition: UUID.h:66
const char * getName() const
Definition: UUID.h:118
const uint32_t MAX_UUID_NAME_SIZE
Definition: UUID.h:55
A unique identifier with a name (primarily for debugging purposes).
Definition: UUID.h:75
bool operator!=(const NamedUUID &compared) const
Definition: UUID.h:113
NamedUUID & operator=(const NamedUUID &copied)
Definition: UUID.h:101
uint16_t time_mid
Definition: UUID.h:63