# BasicCOMImplementations.h File Reference

## Classes
class | TBasicUnknown
class | TBasicDataExchanger
class | TBasicRegisterer
## Defines
#define | STANDARD_RELEASE
#define | STANDARD_RELEASE_BRANCH(X)
#define | QUERY_INTERFACE(X, iid, obj)
#define | QUERY_CLASS(X, iid, obj)
## Functions
void | InitUtilities (IMCUnknown *utilities)
void | CleanUpUtilities ()
## Variables
int32 | gBasicComRefCount

## Define Documentation

#define QUERY_CLASS | ( | X,
|  | iid,
|  | obj |  | ) |

Value:

    if (MCIsEqualIID(iid, X::sClassId)) \
            { \
                    TMCCountedGetHelper<X> result(obj); \
                    result = this; \
                    return MC_S_OK; \
            }

#define QUERY_INTERFACE | ( | X,
|  | iid,
|  | obj |  | ) |

Value:

    if (MCIsEqualIID(iid, IID_##X)) \
            { \
                    TMCCountedGetHelper<X> result(obj); \
                    result = this; \
                    return MC_S_OK; \
            }

#define STANDARD_RELEASE

Value:

    virtual uint32 MCCOMAPI Release() { \
            if (fControllingUnknown)\
            {\
                    uint32 releaseResult = fControllingUnknown->Release();\
                    if (releaseResult == -1)\
                    {\
                            delete this;\
                    }\
                    return releaseResult;\
            }\
            else \
            {\
                    fRefCount--; \
                    uint32 res = fRefCount; \
                    if (fRefCount == 0) \
                    { \
                            delete this; \
                    } \
                    else if (int32(fRefCount) < 0) \
                    { \
                            throw TMCException(-2); \
                    } \
                    return res; \
            }\
    }

Place this macro in your class declaration to get a standard implementation of release that handles aggregation

#define STANDARD_RELEASE_BRANCH | ( | X |  | ) |

Value:

    virtual uint32 MCCOMAPI Release() { \
            if (X::fControllingUnknown)\
            {\
                    uint32 releaseResult = X::fControllingUnknown->Release();\
                    if (releaseResult == -1)\
                    {\
                            delete this;\
                    }\
                    return releaseResult;\
            }\
            else \
            {\
                    X::fRefCount--; \
                    uint32 res = X::fRefCount; \
                    if (X::fRefCount == 0) \
                    { \
                            delete this; \
                    } \
                    else if (int32(X::fRefCount) < 0) \
                    { \
                            throw TMCException(-2, 0); \
                    } \
                    return res; \
            }\
    }

## Function Documentation

void CleanUpUtilities | ( |  | ) |

void InitUtilities | ( | IMCUnknown * | utilities | ) |

## Variable Documentation

int32 gBasicComRefCount