Oracle Coherence for C++ API
Release 3.7.1.0

E22845-01

UUID Class Reference

#include <coherence/util/UUID.hpp>

Inherits Object, Comparable, and PortableObject.

List of all members.


Detailed Description

A UUID is a 256-bit identifier that, if it is generated, is statistically guaranteed to be unique.

Author:
jh 2007.12.20

js 2008.03.24

 

Public Types

typedef spec::Handle Handle
 UUID Handle definition.
typedef spec::View View
 UUID View definition.
typedef spec::Holder Holder
 UUID Holder definition.

Public Member Functions

virtual bool isGenerated () const
 True if the UUID was generated, and false if it was built.
virtual int64_t getTimestamp () const
 Determine the date/time value for the UUID.
virtual bool isAddressIncluded () const
 True if the IP address is a real IP address.
virtual Array
< octet_t >::View 
getAddress () const
 Determine the internet address of the host that generated the UUID instance.
virtual int32_t getPort () const
 Determine the port portion of the UUID.
virtual int32_t getCount () const
 Determine the "counter" portion of the UUID that ensures that two UUIDs generated at the same exact time by the same process are unique.
virtual Array
< octet_t >::View 
toByteArray () const
 Convert the UUID to a byte array of 32 bytes.
virtual int32_t compareTo (Object::View v) const
  
virtual void readExternal (PofReader::Handle hIn)
  
virtual void writeExternal (PofWriter::Handle hOut) const
  
virtual void toStream (std::ostream &out) const
 Output a human-readable description of this Object to the given stream.

coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toStream method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents.

 Object::View vKey   = ...
 Object::View vValue = ...
 std::cout << vKey << " = " << vValue << std::endl;

 String::Handle hs = COH_TO_STRING(vKey << " = " << vValue);

Parameters:
 out the stream used to output the description
virtual bool equals (Object::View v) const
  
virtual size32_t hashCode () const
 Return a hash code value for the Object.

This method is supported for the benefit of hash-based containers.

The general contract of hashCode is:

  • Whenever it is invoked on the same Object more than once during an execution of an application, the hashCode method must consistently return the same value, provided no information used in equals comparisons on the object is modified. This value need not remain consistent from one execution of an application to another execution of the same application.
  • If two Objects are equal according to the equals method, then calling the hashCode method on each of the two Objects must produce the same value.
  • It is not required that if two Objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct results. However, the programmer should be aware that producing distinct results for unequal objects may improve the performance of hash-based containers.

The default implementation is identity based.

Returns:
a hash code value for this Object

Protected Member Functions

 UUID ()
 Generate a UUID.
 UUID (int64_t lDateTime, InetAddress::View vAddr, int32_t nPort, int32_t nCount)
 Build a UUID from its constituent members (advanced constructor).
 UUID (int64_t lDateTime, Array< octet_t >::View vabIP, int32_t nPort, int32_t nCount)
 Build a UUID from its constituent members (advanced constructor).
 UUID (String::View vs)
 Construct a UUID from a String.
 UUID (Array< octet_t >::View vab)
 Construct a UUID from a byte array.

Protected Attributes

int64_t m_lDateTime
 System date/time value that the UUID instance was generated.
int32_t m_nAddr1
 Internet address of host that generated the UUID instance.
int32_t m_nAddr2
 The second four bytes of the IP address.
int32_t m_nAddr3
 The third four bytes of the IP address.
int32_t m_nAddr4
 The fourth four bytes of the IP address.
int32_t m_nPort
 The least significant two bytes of this value are the port number if the UUID is built (not generated).
int32_t m_nCount
 A rolling counter.
size32_t m_nHash
 Cache the hash.

Static Protected Attributes

static const int32_t mask_allflags
 A bit mask that represents the portion of the "port" value reserved for bit flags.
static const int32_t mask_generated
 The bit mask for the "is generated UUID" flag.
static const int32_t mask_realaddr
 The bit mask for the "is a real IP address" flag.
static const int32_t mask_ipv6addr
 The bit mask for the "is an IPv6 address" flag.
static const int32_t mask_unused
 The one remaining bit for future use.

Constructor & Destructor Documentation

UUID ( int64_t  lDateTime,
    InetAddress::View  vAddr,
    int32_t  nPort,
    int32_t  nCount 
  )    [protected]

Build a UUID from its constituent members (advanced constructor).

It is guaranteed that a generated UUID will never equal a built UUID.

Parameters:
 lDateTime the creation date/time millis portion of the UUID
 vAddr the InetAddress portion of the UUID
 nPort the port number portion of the UUID; a port number is 16 bits, but up to 28 bits of data from this value will be maintained by the UUID
 nCount the counter portion of the UUID

UUID ( int64_t  lDateTime,
    Array< octet_t >::View  vabIP,
    int32_t  nPort,
    int32_t  nCount 
  )    [protected]

Build a UUID from its constituent members (advanced constructor).

It is guaranteed that a generated UUID will never equal a built UUID.

Parameters:
 lDateTime the creation date/time millis portion of the UUID
 vabIP the InetAddress portion of the UUID
 nPort the port number portion of the UUID; a port number is 16 bits, but up to 28 bits of data from this value will be maintained by the UUID
 nCount the counter portion of the UUID

UUID ( String::View  vs  )  [protected]

Construct a UUID from a String.

Parameters:
 vs a string as would be returned from UUID.toString()

UUID ( Array< octet_t >::View  vab  )  [protected]

Construct a UUID from a byte array.

Parameters:
 vab a byte array as would be returned from UUID.toByteArray()


Member Function Documentation

virtual bool isGenerated (  )  const [virtual]

True if the UUID was generated, and false if it was built.

A generated UUID is universally unique. Note that the port number is random if the UUID is generated.

Returns:
true if the UUID was generated

virtual int64_t getTimestamp (  )  const [virtual]

Determine the date/time value for the UUID.

Returns:
date/time value in millis

virtual bool isAddressIncluded (  )  const [virtual]

True if the IP address is a real IP address.

This is only false if two conditions are met: The UUID is generated, and it could not get an IP address (or one that is not a loopback/localhost address).

Returns:
true if the UUID has IP address information

virtual Array<octet_t>::View getAddress (  )  const [virtual]

Determine the internet address of the host that generated the UUID instance.

Returns:
an array of bytes containing the IP address information; the array can be zero bytes (no address,) four bytes (IPv4) or 16 bytes (IPv6)

virtual int32_t getPort (  )  const [virtual]

Determine the port portion of the UUID.

Note that the port is a 28-bit value; the first nibble is always 0x0.

Returns:
the port portion of the UID

virtual int32_t getCount (  )  const [virtual]

Determine the "counter" portion of the UUID that ensures that two UUIDs generated at the same exact time by the same process are unique.

Returns:
a number that helps to make the UUID unique

virtual Array<octet_t>::View toByteArray (  )  const [virtual]

Convert the UUID to a byte array of 32 bytes.

Returns:
the UUID data as a byte array of 32 bytes


Member Data Documentation

int32_t m_nAddr1 [mutable, protected]

Internet address of host that generated the UUID instance.

For IPv4, this contains the entire IP address. For IPv6, this contains only the first four bytes of the address. If the UUID is auto-generated and it could not obtain a real address, then this is a random number.

int32_t m_nAddr2 [mutable, protected]

The second four bytes of the IP address.

For IPv6, this is the second four bytes of the IP address. If the UUID is auto-generated and it could not obtain a real address, then this is a random number. Otherwise if the UUID is built (not generated) and the address is IPv4, then this is zero.

int32_t m_nAddr3 [mutable, protected]

The third four bytes of the IP address.

For IPv6, this is the third four bytes of the IP address. If the UUID is auto-generated and it could not obtain a real address, then this is a random number. Otherwise if the UUID is built (not generated) and the address is IPv4, then this is zero.

int32_t m_nAddr4 [mutable, protected]

The fourth four bytes of the IP address.

For IPv6, this is the fourth four bytes of the IP address. If the UUID is auto-generated and it could not obtain a real address, then this is a random number. Otherwise if the UUID is built (not generated) and the address is IPv4, then this is zero.

int32_t m_nPort [mutable, protected]

The least significant two bytes of this value are the port number if the UUID is built (not generated).

Otherwise this is a random number, with the exception of the most significant nibble. The most significant nibble contains the flags of the UUID.

size32_t m_nHash [mutable, protected]

Cache the hash.

Only zero pending deserialization or generation.


The documentation for this class was generated from the following file:
Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.