// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#include "Precompiled.h"
#include "SharedIncludes.h"
namespace RuntimeForStatic {
//==================================================================================================

$COMDummyObject::$COMDummyObject()
{
   ::InterlockedExchange( &_RefCount_, 1 );
}

//--------------------------------------------------------------------------------------------------

STDMETHODIMP_(ULONG) $COMDummyObject::AddRef()
{
   return ::InterlockedIncrement( &_RefCount_ );
}
STDMETHODIMP_(ULONG) $COMDummyObject::Release()
{
   ULONG refCount = ::InterlockedDecrement( &_RefCount_ );
   if ( !refCount )
      delete this;
   return refCount;
}
STDMETHODIMP $COMDummyObject::QueryInterface( REFIID riid, $PPVoid ppvObject )
{
   $$VERIFY_POINTER_ARG_( ppvObject );
   if ( ::IsEqualIID( riid, IID_IPersist ) ||
        ::IsEqualIID( riid, IID_IUnknown ) )
   {
      AddRef();
      ::InterlockedExchangePointer( ppvObject, this );
      return S_OK;
   }
   ::InterlockedExchangePointer( ppvObject, NULL );
   return E_NOINTERFACE;
}

STDMETHODIMP $COMDummyObject::GetClassID( CLSID* pClassID ) $ret_success
{
   $$VERIFY_POINTER_ARG_( pClassID );
   *pClassID = CLSID_NULL;
   return S_OK;
}

//==================================================================================================
} // RuntimeForStatic
