ZG  "1.00
 All Classes Namespaces Files Functions Variables Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
ZGPeerID Class Reference

A ZGPeerID is a 128-bit integer that uniquely represents a particular peer in a ZG system. More...

#include <ZGPeerID.h>

Inheritance diagram for ZGPeerID:
Inheritance graph
[legend]

Public Member Functions

 ZGPeerID ()
 Default constructor – sets the ZGPeerID to its invalid state (all zeroes) More...
 
 ZGPeerID (uint64 highBits, uint64 lowBits)
 Explicit constructor. More...
 
bool operator== (const ZGPeerID &rhs) const
 Equality operator; returns true iff this ZGPeerID is equal to (rhs) More...
 
bool operator!= (const ZGPeerID &rhs) const
 Inequality operator; returns true iff this ZGPeerID is not equal to (rhs) More...
 
bool operator< (const ZGPeerID &rhs) const
 Comparison operator; returns true iff this ZGPeerID is less than (rhs) More...
 
bool operator>= (const ZGPeerID &rhs) const
 Comparison operator; returns true iff this ZGPeerID is greater than or equal to (rhs) More...
 
bool operator> (const ZGPeerID &rhs) const
 Comparison operator; returns true iff this ZGPeerID is greater than (rhs) More...
 
bool operator<= (const ZGPeerID &rhs) const
 Comparison operator; returns true iff this ZGPeerID is less than or equal to (rhs) More...
 
ZGPeerIDoperator= (const ZGPeerID &rhs)
 Assignment operator. More...
 
bool IsValid () const
 Returns true iff the ZGPeerID has any non-zero bits in it. More...
 
void FromString (const String &s)
 Sets this peer ID from the specified String representation (in the format used by ToString()), or to zero if the string isn't parsed. More...
 
String ToString () const
 Returns a String representation of this peer ID (e.g. More...
 
uint32 CalculateChecksum () const
 Returns a 32-bit checksum for this object. More...
 
void Flatten (uint8 *buffer) const
 Copies this point into an endian-neutral flattened buffer. More...
 
status_t Unflatten (const uint8 *buffer, uint32 size)
 Restores this point from an endian-neutral flattened buffer. More...
 
uint32 HashCode () const
 This is implemented so that if ZGPeerID is used as the key in a Hashtable, the HashCode() method will be selected by the AutoChooseHashFunctor template logic, instead of the PODHashFunctor. More...
 

Static Public Member Functions

static MUSCLE_CONSTEXPR bool IsFixedSize ()
 Part of the Flattenable pseudo-interface: Returns true. More...
 
static MUSCLE_CONSTEXPR uint32 TypeCode ()
 Part of the Flattenable pseudo-interface: Returns ZG_PEER_ID_TYPE. More...
 
static MUSCLE_CONSTEXPR bool AllowsTypeCode (uint32 tc)
 Returns true iff (tc) equals ZG_PEER_ID_TYPE. More...
 
static MUSCLE_CONSTEXPR uint32 FlattenedSize ()
 Part of the Flattenable pseudo-interface: 2*sizeof(uint64) More...
 

Detailed Description

A ZGPeerID is a 128-bit integer that uniquely represents a particular peer in a ZG system.

A peer's ZGPeerID is assigned to at startup, and will never change over the course of the peer's lifetime. It will be different for each ZG peer process that is started.

Definition at line 18 of file ZGPeerID.h.

Constructor & Destructor Documentation

ZGPeerID ( )
inline

Default constructor – sets the ZGPeerID to its invalid state (all zeroes)

Definition at line 22 of file ZGPeerID.h.

ZGPeerID ( uint64  highBits,
uint64  lowBits 
)
inline

Explicit constructor.

Parameters
highBitsthe upper 64 bits of the ZGPeerID
lowBitsthe lower 64 bits of the ZGPeerID

Definition at line 28 of file ZGPeerID.h.

Member Function Documentation

static MUSCLE_CONSTEXPR bool AllowsTypeCode ( uint32  tc)
inlinestatic

Returns true iff (tc) equals ZG_PEER_ID_TYPE.

Definition at line 98 of file ZGPeerID.h.

References ZGPeerID::TypeCode().

uint32 CalculateChecksum ( ) const
inline

Returns a 32-bit checksum for this object.

Definition at line 104 of file ZGPeerID.h.

Referenced by ZGPeerID::HashCode().

void Flatten ( uint8 *  buffer) const
inline

Copies this point into an endian-neutral flattened buffer.

Parameters
bufferPoints to an array of at least FlattenedSize() bytes.

Definition at line 109 of file ZGPeerID.h.

static MUSCLE_CONSTEXPR uint32 FlattenedSize ( )
inlinestatic

Part of the Flattenable pseudo-interface: 2*sizeof(uint64)

Definition at line 101 of file ZGPeerID.h.

Referenced by ZGPeerID::Unflatten().

void FromString ( const String &  s)
inline

Sets this peer ID from the specified String representation (in the format used by ToString()), or to zero if the string isn't parsed.

Parameters
sA human-readable string (e.g. "123A:432B") that we will set this ZGPeerID's state from

Definition at line 71 of file ZGPeerID.h.

uint32 HashCode ( ) const
inline

This is implemented so that if ZGPeerID is used as the key in a Hashtable, the HashCode() method will be selected by the AutoChooseHashFunctor template logic, instead of the PODHashFunctor.

Definition at line 134 of file ZGPeerID.h.

References ZGPeerID::CalculateChecksum().

static MUSCLE_CONSTEXPR bool IsFixedSize ( )
inlinestatic

Part of the Flattenable pseudo-interface: Returns true.

Definition at line 92 of file ZGPeerID.h.

bool IsValid ( ) const
inline

Returns true iff the ZGPeerID has any non-zero bits in it.

(An all-zero ZGPeerID is considered an invalid/null ID)

Definition at line 66 of file ZGPeerID.h.

bool operator!= ( const ZGPeerID rhs) const
inline

Inequality operator; returns true iff this ZGPeerID is not equal to (rhs)

Parameters
rhsThe ZGPeerID to compare to

Definition at line 38 of file ZGPeerID.h.

bool operator< ( const ZGPeerID rhs) const
inline

Comparison operator; returns true iff this ZGPeerID is less than (rhs)

Parameters
rhsThe ZGPeerID to compare to

Definition at line 43 of file ZGPeerID.h.

bool operator<= ( const ZGPeerID rhs) const
inline

Comparison operator; returns true iff this ZGPeerID is less than or equal to (rhs)

Parameters
rhsThe ZGPeerID to compare to

Definition at line 58 of file ZGPeerID.h.

ZGPeerID& operator= ( const ZGPeerID rhs)
inline

Assignment operator.

Sets (*this) to be the same as (rhs)

Parameters
rhsThe ZGPeerID to copy the state of

Definition at line 63 of file ZGPeerID.h.

bool operator== ( const ZGPeerID rhs) const
inline

Equality operator; returns true iff this ZGPeerID is equal to (rhs)

Parameters
rhsThe ZGPeerID to compare to

Definition at line 33 of file ZGPeerID.h.

bool operator> ( const ZGPeerID rhs) const
inline

Comparison operator; returns true iff this ZGPeerID is greater than (rhs)

Parameters
rhsThe ZGPeerID to compare to

Definition at line 53 of file ZGPeerID.h.

bool operator>= ( const ZGPeerID rhs) const
inline

Comparison operator; returns true iff this ZGPeerID is greater than or equal to (rhs)

Parameters
rhsThe ZGPeerID to compare to

Definition at line 48 of file ZGPeerID.h.

String ToString ( ) const
inline

Returns a String representation of this peer ID (e.g.

"123A:432B")

Definition at line 84 of file ZGPeerID.h.

static MUSCLE_CONSTEXPR uint32 TypeCode ( )
inlinestatic

Part of the Flattenable pseudo-interface: Returns ZG_PEER_ID_TYPE.

Definition at line 95 of file ZGPeerID.h.

References zg::ZG_PEER_ID_TYPE.

Referenced by ZGPeerID::AllowsTypeCode().

status_t Unflatten ( const uint8 *  buffer,
uint32  size 
)
inline

Restores this point from an endian-neutral flattened buffer.

Parameters
bufferPoints to an array of (size) bytes
sizeThe number of bytes (buffer) points to (should be at least FlattenedSize())
Returns
B_NO_ERROR on success, B_ERROR on failure (size was too small)

Definition at line 120 of file ZGPeerID.h.

References ZGPeerID::FlattenedSize().


The documentation for this class was generated from the following file: