Guid.h revision c829b606c5535f37e00ffee381cca0815a57f319
/* $Id$ */
/** @file
* MS COM / XPCOM Abstraction Layer:
* Guid class declaration
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef ___VBox_com_Guid_h
#define ___VBox_com_Guid_h
/* Make sure all the stdint.h macros are included - must come first! */
#ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif
#if defined (VBOX_WITH_XPCOM)
#include <nsMemory.h>
#endif
{
/**
* Helper class that represents the UUID type and hides platform-specific
* implementation details.
*/
{
Guid()
{
::RTUuidClear(&uuid);
refresh();
}
{
refresh();
}
{
refresh();
}
{
refresh();
}
{
::RTUuidClear(&uuid);
refresh();
}
{
::RTUuidClear (&uuid);
refresh();
}
{
refresh();
return *this;
}
{
refresh();
return *this;
}
{
refresh();
return *this;
}
{
refresh();
return *this;
}
void create()
{
::RTUuidCreate(&uuid);
refresh();
}
void clear()
{
::RTUuidClear(&uuid);
refresh();
}
{
char buf[RTUUID_STR_LENGTH];
}
{
if (isEmpty())
return Bstr();
}
bool isEmpty() const
{
return ::RTUuidIsNull (&uuid);
}
operator bool() const
{
return !isEmpty();
}
/* to pass instances as IN_GUID parameters to interface methods */
{
}
/* to directly pass instances to RTPrintf("%RTuuid") */
{
return &uuid;
}
/* to pass instances to printf-like functions */
{
return &uuid;
}
/* to pass instances to RTUuid*() as a constant argument */
{
return &uuid;
}
#if !defined (VBOX_WITH_XPCOM)
/* to assign instances to OUT_GUID parameters from within the
* interface method */
{
if (pguid)
return *this;
}
/* to pass instances as OUT_GUID parameters to interface methods */
GUID *asOutParam()
{
}
#else
/* to assign instances to OUT_GUID parameters from within the
* interface method */
{
return *this;
}
// internal helper class for asOutParam(); this takes a GUID refrence
// in the constructor and copies the uuid from the method to that instance
// in its destructor
{
: ptr(0),
{
}
~GuidOutParam()
{
{
}
}
};
/* to pass instances as OUT_GUID parameters to interface methods */
#endif
/* to directly test IN_GUID interface method's parameters */
{
}
/**
* Static immutable empty object. May be used for comparison purposes.
*/
// in debug code, refresh the UUID string representatino for
// debugging; must be called every time the internal uuid
// changes; compiles to nothing in release code
inline void refresh()
{
#ifdef DEBUG
#endif
}
#ifdef DEBUG
// in debug builds, have a Utf8Str representation of the UUID so we can look
// at it in the debugger more easily
char szUUID[RTUUID_STR_LENGTH];
const char *pcszUUID;
#endif
};
{
}
{
}
/* work around error C2593 of the stupid MSVC 7.x ambiguity resolver */
} /* namespace com */
#endif /* ___VBox_com_Guid_h */