neuray API Programmer's Manual

uuid.h File Reference

Description

A 128 bit representation of a universally unique identifier (UUID or GUID). See Interface Framework Technology, type mi::base::Uuid and template class mi::base::Uuid_t.

Code Example

uuid.h

‎//*****************************************************************************
// Copyright 1986, 2016 NVIDIA Corporation. All rights reserved.
//*****************************************************************************
//*****************************************************************************

#ifndef MI_BASE_UUID_H
#define MI_BASE_UUID_H

#include <mi/base/types.h>

namespace mi {
namespace base {





struct Uuid
{
    Uint32 
               m_id1; 
    Uint32 
               m_id2; 
    Uint32 
               m_id3; 
    Uint32 
               m_id4; 
};

inline bool operator ==( const Uuid & id1, const Uuid & id2) {
    if( id1.m_id1 != id2.m_id1 ) return false;
    if( id1.m_id2 != id2.m_id2 ) return false;
    if( id1.m_id3 != id2.m_id3 ) return false;
    if( id1.m_id4 != id2.m_id4 ) return false;
    return true;
}

inline bool operator !=( const Uuid & id1, const Uuid & id2) {
    if( id1.m_id1 != id2.m_id1 ) return true;
    if( id1.m_id2 != id2.m_id2 ) return true;
    if( id1.m_id3 != id2.m_id3 ) return true;
    if( id1.m_id4 != id2.m_id4 ) return true;
    return false;
}

inline bool operator < ( const Uuid & id1, const Uuid & id2) {
    if( id1.m_id1 < id2.m_id1 ) return true;
    if( id1.m_id1 > id2.m_id1 ) return false;
    if( id1.m_id2 < id2.m_id2 ) return true;
    if( id1.m_id2 > id2.m_id2 ) return false;
    if( id1.m_id3 < id2.m_id3 ) return true;
    if( id1.m_id3 > id2.m_id3 ) return false;
    if( id1.m_id4 < id2.m_id4 ) return true;
    return false;
}

inline bool operator >( const Uuid & id1, const Uuid & id2) {
    if( id1.m_id1 > id2.m_id1 ) return true;
    if( id1.m_id1 < id2.m_id1 ) return false;
    if( id1.m_id2 > id2.m_id2 ) return true;
    if( id1.m_id2 < id2.m_id2 ) return false;
    if( id1.m_id3 > id2.m_id3 ) return true;
    if( id1.m_id3 < id2.m_id3 ) return false;
    if( id1.m_id4 > id2.m_id4 ) return true;
    return false;
}

inline bool operator < =( const Uuid & id1, const Uuid & id2) {
    return !(id1 > id2);
}

inline bool operator >=( const Uuid & id1, const Uuid & id2) {
    return !(id1 < id2);
}

inline Uint32 
               uuid_hash32( const Uuid& id) {
    return id.m_id1 ^ id.m_id2 ^ id.m_id3 ^ id.m_id4; 
}


template <Uint32 id1, Uint16 id2, Uint16 id3
        , Uint8  id4, Uint8  id5, Uint8  id6, Uint8  id7
        , Uint8  id8, Uint8  id9, Uint8 id10, Uint8 id11>
class Uuid_t
{
public:
    operator const Uuid &() const
    {
        static const Uuid uuid = {m_id1, m_id2, m_id3, m_id4};
        return uuid;
    }

    static const Uint32 
               m_id1 = id1;

    static const Uint32 
               m_id2 = (Uint32) (id2 | (id3 << 16));

    static const Uint32 
               m_id3 = (Uint32) (id4 | (id5 << 8) | (id6 << 16) | (id7 << 24));

    static const Uint32 
               m_id4 = (Uint32) (id8 | (id9 << 8) | (id10 << 16) | (id11 << 24));

    static const Uint32 
               hash32 = m_id1 ^ m_id2 ^ m_id3 ^ m_id4;
};
 // end group mi_base_iinterface

} // namespace base
} // namespace mi

#endif // MI_BASE_UUID_H

Namespaces

namespace 
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH. More...
namespace 
Namespace for the Base API. More...

Classes

struct 
A 128 bit representation of a universally unique identifier (UUID or GUID). More...
class 
Class template for a compile-time representation of universally unique identifiers (UUIDs or GUIDs). More...

Functions

bool   ( const Uuid& id1, const Uuid& id2)
Returns true if id1 is not equal to id2. More...
bool   ( const Uuid& id1, const Uuid& id2)
Returns true if id1 is less than id2. More...
bool   ( const Uuid& id1, const Uuid& id2)
Returns true if id1 is less than or equal to id2. More...
bool   ( const Uuid& id1, const Uuid& id2)
Returns true if id1 is equal to id2. More...
bool   ( const Uuid& id1, const Uuid& id2)
Returns true if id1 is greater than id2. More...
bool   ( const Uuid& id1, const Uuid& id2)
Returns true if id1 is greater than or equal to id2. More...
Uint32  ( const Uuid& id)
Returns a 32 bit hash value by performing a bitwise xor of all four 32 bit values. More...