C12Adapter Opensource C++ Interface
MGuid Class Reference

Global identifier (GUID) object. More...

Inheritance diagram for MGuid:

Classes

struct  GUID
 Define Windows-like GUID type on non-Windows platforms. More...
 
union  RawGuidType
 System independent representation of GUID, 16 bytes long randomized byte string. More...
 

Public Member Functions

 MGuid ()
 GUID generator constructor, null GUID is generated. More...
 
 MGuid (const MStdString &str)
 Construct GUID from a given string. More...
 
 MGuid (const MGuid &other)
 Copy one GUID from another. More...
 
 MGuid (const RawGuidType &guid)
 Create GUID object from its internal in-memory representation. More...
 
 MGuid (const Muint8 *guid)
 Create GUID object from its internal in-memory representation. More...
 
 MGuid (const GUID &guid)
 Create GUID object from value of Windows specific type. More...
 
virtual ~MGuid ()
 Reclaim resources allocated by the object.
 
bool IsNull () const
 Check whether the GUID is null, not generated.
 
void CheckIfNotNull () const
 Check the GUID is not NULL, otherwise throw a No Value exception.
 
void SetToNull ()
 Reset the value into null, meaning there is no value present in the GUID object.
 
int Compare (const MGuid &other)
 Ternary GUID comparison function. More...
 
bool operator== (const MGuid &other)
 Whether the GUID objects have the same value. More...
 
bool operator!= (const MGuid &other)
 Whether the GUID objects have different values. More...
 
bool operator< (const MGuid &other)
 Whether the GUID object value is less than the given value. More...
 
bool operator> (const MGuid &other)
 Whether the GUID object value is bigger than the given value. More...
 
bool operator<= (const MGuid &other)
 Whether the GUID object value is less or equal than the given value. More...
 
bool operator>= (const MGuid &other)
 Whether the GUID object value is bigger or equal than the given value. More...
 
virtual unsigned GetEmbeddedSizeof () const
 This is an embedded object type, therefore return its size in bytes. More...
 
RawGuidTypeAsRawGuid ()
 
const RawGuidTypeAsRawGuid () const
 
GUIDAsWindowsGuid ()
 
const GUIDAsWindowsGuid () const
 
 operator GUID () const
 
MStdString AsString () const
 
void SetAsString (const MStdString &str)
 
void Assign (const MGuid &guid)
 
MGuidoperator= (const MGuid &guid)
 
MGuidoperator= (const RawGuidType &guid)
 
MGuidoperator= (const GUID &guid)
 
MGuidoperator= (const Muint8 *guid)
 
- Public Member Functions inherited from MObject
virtual ~MObject ()
 Object destructor.
 
virtual const MClassGetClass () const =0
 Get the final class of the object. More...
 
bool IsEmbeddedObject () const
 Tell if the object is of embedded kind. More...
 
SHOW_INTERNAL MVariant Call (const MStdString &name, const MVariant &params)
 Call the object service with parameters, given as variant. More...
 
MVariant Call0 (const MStdString &name)
 Call the object service with no parameters. More...
 
MVariant Call1 (const MStdString &name, const MVariant &p1)
 Call the object service with one parameter. More...
 
MVariant Call2 (const MStdString &name, const MVariant &p1, const MVariant &p2)
 Call the object service with two parameter. More...
 
MVariant Call3 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3)
 Call the object service with three parameter. More...
 
MVariant Call4 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4)
 Call the object service with four parameter. More...
 
MVariant Call5 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5)
 Call the object service with five parameter. More...
 
MVariant Call6 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5, const MVariant &p6)
 Call the object service with six parameter. More...
 
virtual MVariant CallV (const MStdString &name, const MVariant::VariantVector &params)
 Call the object service with parameters, given as variant vector. More...
 
virtual bool IsPropertyPresent (const MStdString &name) const
 Tell if the property with the given name exists.
 
virtual bool IsServicePresent (const MStdString &name) const
 Tell if the service with the given name exists.
 
virtual MVariant GetProperty (const MStdString &name) const
 Get the property value using name of the property. More...
 
virtual void SetProperty (const MStdString &name, const MVariant &value)
 Set the property using name of the property, and value. More...
 
virtual MStdStringVector GetAllPropertyNames () const
 Return the list of publicly available properties, persistent or not. More...
 
virtual MStdStringVector GetAllPersistentPropertyNames () const
 Return the list of persistent properties. More...
 
virtual void SetPersistentPropertiesToDefault ()
 Set the persistent properties of the object to their default values. More...
 
virtual MVariant GetPersistentPropertyDefaultValue (const MStdString &name) const
 Get the default value of persistent property with the name given. More...
 
virtual void SetPersistentPropertyToDefault (const MStdString &name)
 Set the persistent property with the name given to default value. More...
 
virtual const char * GetType () const
 Get the name of the type for the object (could be the same as class name).
 
virtual void SetType (const MStdString &)
 Intentionally, it will set the name of the type for the object, but the service will not allow setting the name to anything other than the current name. More...
 
virtual void Validate ()
 Validate internal structures of the object. More...
 

Static Public Member Functions

static MGuid Generate ()
 Generate a new GUID using cryptographically strong random number generation algorithm.
 
- Static Public Member Functions inherited from MObject
static const MClassGetStaticClass ()
 Get the declared class of this particular object. More...
 
static bool IsClassPresent (const MStdString &name)
 Tells if the given class name is available. More...
 

Additional Inherited Members

- Static Public Attributes inherited from MObject
static const MClass s_class
 Class of MObject.
 
- Protected Member Functions inherited from MObject
 MObject ()
 Object constructor, protected as the class is abstract.
 
void DoSetPersistentPropertiesToDefault (const MClass *staticClass)
 Set the persistent properties to their default values for one object provided the class for that object. More...
 

Detailed Description

Global identifier (GUID) object.

The class handles Microsoft style GUID objects, as used by Windows platform. The implementation is generic, and it behaves in the same way in non-Microsoft platforms.

String representation of GUID class has a fixed format:

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

where x is a hexadecimal digit. Only this exact string format is consumed at initialization, and produced by AsString.

Constructor & Destructor Documentation

MGuid::MGuid ( )
inline

GUID generator constructor, null GUID is generated.

One has to be sure not to use a null GUID for anything that requires a cryptographically unique GUID number.

MGuid::MGuid ( const MStdString str)
inline

Construct GUID from a given string.

Parameters
strGUID string in the format as described here in the class description, or an exception is thrown.
MGuid::MGuid ( const MGuid other)
inline

Copy one GUID from another.

Parameters
otherGUID from which value to create this value.
MGuid::MGuid ( const RawGuidType guid)
inline

Create GUID object from its internal in-memory representation.

Parameters
guidGUID type from which value to create this value.
MGuid::MGuid ( const Muint8 *  guid)
inline

Create GUID object from its internal in-memory representation.

Parameters
guidSixteen bytes that will be copied into this GUID value
MGuid::MGuid ( const GUID guid)
inline

Create GUID object from value of Windows specific type.

Parameters
guidInitialized GUID value, no checks of any sort is performed

Member Function Documentation

RawGuidType& MGuid::AsRawGuid ( )
inline

Read-write access of the internal raw GUID binary representation.

const RawGuidType& MGuid::AsRawGuid ( ) const
inline

Read-write access of the internal raw GUID binary representation.

void MGuid::Assign ( const MGuid guid)

Assign GUID object using value of another GUID object.

Parameters
guidValue to copy from. Null GUID will produce a null GUID.
MStdString MGuid::AsString ( ) const

Read write property to represent string representation of GUID.

The string representation of GUID is given here in the class description. When assigning to this property, the format shall be exactly as the one specified.

GUID& MGuid::AsWindowsGuid ( )
inline

Read-write access to Windows GUID type, available only on Windows.

This is the same as AsRawGuid().m_guid

const GUID& MGuid::AsWindowsGuid ( ) const
inline

Read-write access to Windows GUID type, available only on Windows.

This is the same as AsRawGuid().m_guid

int MGuid::Compare ( const MGuid other)

Ternary GUID comparison function.

Partial order comparison of GUID objects, while it does not make much sense semantically, is the way of building efficient data structures that require presence of less-than or bigger-than operators. Null GUID is smaller than any other non-null GUID. Two null GUIDs are equal to each other.

Parameters
otherOther GUID object to compare with.
Returns
  • Null is returned if GUIDs have exactly the same values.
  • Value less than zero means the guid is smaller than the other guid given.
  • Value bigger than zero means the guid is bigger than the other guid given.
virtual unsigned MGuid::GetEmbeddedSizeof ( ) const
virtual

This is an embedded object type, therefore return its size in bytes.

Returns
size of MGuid in bytes.

Reimplemented from MObject.

MGuid::operator GUID ( ) const
inline

Read-write access to Windows GUID type, available only on Windows.

This is the same as AsRawGuid().m_guid

bool MGuid::operator!= ( const MGuid other)
inline

Whether the GUID objects have different values.

Two null GUIDs are not equal to each other.

Parameters
otherOther GUID object to compare with.
bool MGuid::operator< ( const MGuid other)
inline

Whether the GUID object value is less than the given value.

Parameters
otherOther GUID object to compare with.
bool MGuid::operator<= ( const MGuid other)
inline

Whether the GUID object value is less or equal than the given value.

Parameters
otherOther GUID object to compare with.
MGuid& MGuid::operator= ( const MGuid guid)
inline

Assign GUID object using value of another GUID object.

Parameters
guidValue to copy from. Null GUID will produce a null GUID.
MGuid& MGuid::operator= ( const RawGuidType guid)
inline

Assign GUID object using value of another GUID object.

Parameters
guidValue to copy from. Null GUID will produce a null GUID.
MGuid& MGuid::operator= ( const GUID guid)
inline

Assign GUID object using value of another GUID object.

Parameters
guidValue to copy from. Null GUID will produce a null GUID.
MGuid& MGuid::operator= ( const Muint8 *  guid)

Assign GUID object using value of another GUID object.

Parameters
guidValue to copy from. Null GUID will produce a null GUID.
bool MGuid::operator== ( const MGuid other)
inline

Whether the GUID objects have the same value.

Two null GUIDs are equal to each other.

Parameters
otherOther GUID object to compare with.
bool MGuid::operator> ( const MGuid other)
inline

Whether the GUID object value is bigger than the given value.

Parameters
otherOther GUID object to compare with.
bool MGuid::operator>= ( const MGuid other)
inline

Whether the GUID object value is bigger or equal than the given value.

Parameters
otherOther GUID object to compare with.
void MGuid::SetAsString ( const MStdString str)

Read write property to represent string representation of GUID.

The string representation of GUID is given here in the class description. When assigning to this property, the format shall be exactly as the one specified.