10 // the base of all identifier classes
11 template <ui32_t SIZE>
12 class Identifier : public IArchive
19 memset(m_Value, 0, SIZE);
23 inline Result_t Set(const byte_t* value) {
24 ASDCP_TEST_NULL(value);
25 memcpy(m_Value, value, SIZE);
30 inline Result_t ReadFrom(ASDCP::MemIOReader& Reader) {
31 Reader.ReadRaw(m_Value, SIZE);
36 inline Result_t WriteTo(ASDCP::MemIOWriter& Writer) {
37 Writer.WriteRaw(m_Value, SIZE);
41 inline const byte_t* Data() const { return m_Value; }
43 inline ui32_t Size() const { return SIZE; }
46 inline bool operator<(const Identifier& rhs) const
48 for ( ui32_t i = 0; i < SIZE; i++ )
50 if ( m_Value[i] != rhs.m_Value[i] )
51 return m_Value[i] < rhs.m_Value[i];
58 inline bool operator==(const Identifier& rhs) const
60 if ( rhs.Size() != SIZE )
63 return ( memcmp(m_Value, rhs.m_Value, SIZE) == 0 );
67 // todo: refactor characrer insertion back to bin2hex()
68 const char* ToString(char* str_buf) const
72 for ( ui32_t i = 0; i < SIZE; i++ )
74 *p = (m_Value[i] >> 4) & 0x0f;
75 *p += *p < 10 ? 0x30 : 0x61 - 10;
78 *p = m_Value[i] & 0x0f;
79 *p += *p < 10 ? 0x30 : 0x61 - 10;
95 // UID - either a UL or a UUID
96 class UID : public Identifier<SMPTE_UL_LENGTH>
98 friend class ASDCP::UL;
99 friend class ASDCP::UUID;
103 UID(const UID& rhs) {
104 memcpy(m_Value, rhs.m_Value, SMPTE_UL_LENGTH);
109 class UL : public Identifier<SMPTE_UL_LENGTH>
114 memcpy(m_Value, rhs.m_Value, SMPTE_UL_LENGTH);
118 memcpy(m_Value, rhs.m_Value, SMPTE_UL_LENGTH);
121 UL(const byte_t* value) {
123 memcpy(m_Value, value, SMPTE_UL_LENGTH);
126 bool operator==(const UL& rhs) const {
127 return ( memcmp(m_Value, rhs.m_Value, SMPTE_UL_LENGTH) == 0 ) ? true : false;
132 class UUID : public Identifier<SMPTE_UL_LENGTH>
136 UUID(const UUID& rhs) {
137 memcpy(m_Value, rhs.m_Value, SMPTE_UL_LENGTH);
140 UUID(const UID& rhs) {
141 memcpy(m_Value, rhs.m_Value + 8, 8);
142 memcpy(m_Value + 8, rhs.m_Value, 8);
145 void GenRandomValue();
149 class UMID : public Identifier<SMPTE_UMID_LENGTH>
153 UMID(const UMID &rhs) {
154 memcpy(m_Value, rhs.m_Value, SMPTE_UMID_LENGTH);
157 void MakeUMID(int Type);
159 void MakeUMID(int Type, const UUID& ID);
161 void SetMaterial(UL& aUL);
163 void SetInstance(int Instance, int Method = -1);
165 ui32_t GetInstance(void) const
168 return ( m_Value[13] << 16 ) | ( m_Value[14] << 8 ) | m_Value[15];
172 } // namespace mxflib
174 #endif // _IDENTIFIER_H_