123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- //-----------------------------------------------------------------------------
- // Copyright (c) 2012 GarageGames, LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- #ifndef _TORQUE_UUID_H_
- #define _TORQUE_UUID_H_
- #ifndef _PLATFORM_H_
- #include "platform/platform.h"
- #endif
- #include "console/engineTypeInfo.h"
- typedef unsigned int unsigned32;
- typedef unsigned short unsigned16;
- typedef unsigned char unsigned8;
- class xuuid_t
- {
- public:
- unsigned32 time_low;
- unsigned16 time_mid;
- unsigned16 time_hi_and_version;
- unsigned8 clock_seq_hi_and_reserved;
- unsigned8 clock_seq_low;
- unsigned8 node[6];
- };
- namespace Torque
- {
- /// A universally unique identifier.
- class UUID : public xuuid_t
- {
- friend class UUIDEngineExport;
- public:
-
- typedef void Parent;
-
- protected:
- U32 a;
- U16 b;
- U16 c;
- U8 d;
- U8 e;
- U8 f[ 6 ];
-
- static UUID smNull;
-
- public:
-
- UUID()
- {
- dMemset( this, 0, sizeof( UUID ) );
- }
-
- ///
- bool isNull() const { return ( *this == smNull ); }
-
- /// Generate a new universally unique identifier (UUID).
- void generate();
-
- /// Convert the given universally unique identifier to a printed string
- /// representation.
- String toString() const;
-
- /// Parse a text string generated by UUIDToString back into a
- /// universally unique identifier (UUID).
- bool fromString( const char* str );
- /// Return a hash value for this UUID.
- U32 getHash() const;
- bool operator ==( const UUID& uuid ) const
- {
- return ( dMemcmp( this, &uuid, sizeof( UUID ) ) == 0 );
- }
- bool operator !=( const UUID& uuid ) const
- {
- return !( *this == uuid );
- }
- };
- class UUIDEngineExport
- {
- public:
- static EngineFieldTable::Field getAField();
- static EngineFieldTable::Field getBField();
- static EngineFieldTable::Field getCField();
- static EngineFieldTable::Field getDField();
- static EngineFieldTable::Field getEField();
- static EngineFieldTable::Field getFField();
- };
- }
- namespace DictHash
- {
- inline U32 hash( const Torque::UUID& uuid )
- {
- return uuid.getHash();
- }
- }
- #endif // !_TORQUE_UUID_H_
|