Example #1
0
HRESULT STDMETHODCALLTYPE
    CAAFIdentification::SetProductVersion (aafProductVersion_constref  version)
{
  HRESULT hr;

  ImplAAFIdentification * ptr;
  ImplAAFRoot * pO;
  pO = GetRepObject ();
  assert (pO);
  ptr = static_cast<ImplAAFIdentification*> (pO);
  assert (ptr);


  try
    {
      hr = ptr->SetProductVersion
       (version);
    }
  catch (OMException& e)
    {
      // OMExceptions should be handled by the impl code. However, if an
      // unhandled OMException occurs, control reaches here. We must not
      // allow the unhandled exception to reach the client code, so we
      // turn it into a failure status code.
      //
      // If the OMException contains an HRESULT, it is returned to the
      // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
      //
      hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
    }
  catch (OMAssertionViolation &)
    {
      // Control reaches here if there is a programming error in the
      // impl code that was detected by an assertion violation.
      // We must not allow the assertion to reach the client code so
      // here we turn it into a failure status code.
      //
      hr = AAFRESULT_ASSERTION_VIOLATION;
    }
  catch (...)
    {
      // We CANNOT throw an exception out of a COM interface method!
      // Return a reasonable exception code.
      //
      hr = AAFRESULT_UNEXPECTED_EXCEPTION;
    }

  return hr;
}
Example #2
0
HRESULT STDMETHODCALLTYPE
    CEnumAAFLoadedPlugins::Clone (IEnumAAFLoadedPlugins ** ppEnum)
{
  HRESULT hr;

  ImplEnumAAFLoadedPlugins * ptr;
  ImplAAFRoot * pO;
  pO = GetRepObject ();
  assert (pO);
  ptr = static_cast<ImplEnumAAFLoadedPlugins*> (pO);
  assert (ptr);

  //
  // set up for ppEnum
  //
  ImplEnumAAFLoadedPlugins * internalppEnum = NULL;
  ImplEnumAAFLoadedPlugins ** pinternalppEnum = NULL;
  if (ppEnum)
    {
      pinternalppEnum = &internalppEnum;
    }

  try
    {
      hr = ptr->Clone
       (pinternalppEnum);
    }
  catch (OMException& e)
    {
      // OMExceptions should be handled by the impl code. However, if an
      // unhandled OMException occurs, control reaches here. We must not
      // allow the unhandled exception to reach the client code, so we
      // turn it into a failure status code.
      //
      // If the OMException contains an HRESULT, it is returned to the
      // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
      //
      hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
    }
  catch (OMAssertionViolation &)
    {
      // Control reaches here if there is a programming error in the
      // impl code that was detected by an assertion violation.
      // We must not allow the assertion to reach the client code so
      // here we turn it into a failure status code.
      //
      hr = AAFRESULT_ASSERTION_VIOLATION;
    }
  catch (...)
    {
      // We CANNOT throw an exception out of a COM interface method!
      // Return a reasonable exception code.
      //
      hr = AAFRESULT_UNEXPECTED_EXCEPTION;
    }

  //
  // cleanup for ppEnum
  //
  if (SUCCEEDED(hr))
    {
      IUnknown *pUnknown;
      HRESULT hStat;

      if (internalppEnum)
        {
          pUnknown = static_cast<IUnknown *> (internalppEnum->GetContainer());
          hStat = pUnknown->QueryInterface(IID_IEnumAAFLoadedPlugins, (void **)ppEnum);
          assert (SUCCEEDED (hStat));
          //pUnknown->Release();
          internalppEnum->ReleaseReference(); // We are through with this pointer.
        }
    }
  return hr;
}
Example #3
0
HRESULT STDMETHODCALLTYPE
    CAAFTypeDefObjectRef::SetObject (IAAFPropertyValue * pPropVal,
        IUnknown * pObject)
{
  HRESULT hr;

  ImplAAFTypeDefObjectRef * ptr;
  ImplAAFRoot * pO;
  pO = GetRepObject ();
  assert (pO);
  ptr = static_cast<ImplAAFTypeDefObjectRef*> (pO);
  assert (ptr);

  //
  // set up for pPropVal
  //
  ImplAAFPropertyValue * internalpPropVal = NULL;
  if (pPropVal)
    {
      HRESULT hStat;
      IAAFRoot * iObj;
      ImplAAFRoot *arg;
      hStat = pPropVal->QueryInterface (IID_IAAFRoot, (void **)&iObj);
      assert (SUCCEEDED (hStat));
      assert (iObj);
      hStat = iObj->GetImplRep((void **)&arg);
      assert (SUCCEEDED (hStat));
      iObj->Release(); // we are through with this interface pointer.
      internalpPropVal = static_cast<ImplAAFPropertyValue*>(arg);
      assert (internalpPropVal);
    }
  //
  // set up for pObject
  //
  ImplAAFRoot * internalpObject = NULL;
  if (pObject)
    {
      HRESULT hStat;
      IAAFRoot * iObj;
      ImplAAFRoot *arg;
      hStat = pObject->QueryInterface (IID_IAAFRoot, (void **)&iObj);
      if (FAILED(hStat))
      {
        // If input IUnknown argument MUST supprt our private IAAFRoot interface.
        // If it does not than the argument is not one of our implementation objects!
        assert(E_NOINTERFACE == hStat);
        if (E_NOINTERFACE == hStat)
          return AAFRESULT_INVALID_PARAM;
        else
          return hStat;
      }
      assert (iObj);
      hStat = iObj->GetImplRep((void **)&arg);
      assert (SUCCEEDED (hStat));
      iObj->Release(); // we are through with this interface pointer.
      internalpObject = static_cast<ImplAAFRoot*>(arg);
      assert (internalpObject);
    }

  try
    {
      hr = ptr->SetObject
       (internalpPropVal,
        internalpObject);
    }
  catch (OMException& e)
    {
      // OMExceptions should be handled by the impl code. However, if an
      // unhandled OMException occurs, control reaches here. We must not
      // allow the unhandled exception to reach the client code, so we
      // turn it into a failure status code.
      //
      // If the OMException contains an HRESULT, it is returned to the
      // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
      //
      hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
    }
  catch (OMAssertionViolation &)
    {
      // Control reaches here if there is a programming error in the
      // impl code that was detected by an assertion violation.
      // We must not allow the assertion to reach the client code so
      // here we turn it into a failure status code.
      //
      hr = AAFRESULT_ASSERTION_VIOLATION;
    }
  catch (...)
    {
      // We CANNOT throw an exception out of a COM interface method!
      // Return a reasonable exception code.
      //
      hr = AAFRESULT_UNEXPECTED_EXCEPTION;
    }

  //
  // no cleanup necessary for pPropVal
  //
  //
  // no cleanup necessary for pObject
  //
  return hr;
}
Example #4
0
HRESULT STDMETHODCALLTYPE
    CAAFTypeDefObjectRef::GetObject (IAAFPropertyValue * pPropVal,
        REFIID  iid,
        IUnknown ** ppObject)
{
  HRESULT hr = S_OK;

  try
    {
    

  ImplAAFTypeDefObjectRef * ptr;
  ImplAAFRoot * pO;
  pO = GetRepObject ();
  assert (pO);
  ptr = static_cast<ImplAAFTypeDefObjectRef*> (pO);
  assert (ptr);

  //
  // set up for pPropVal
  //
  ImplAAFPropertyValue * internalpPropVal = NULL;
  if (pPropVal)
    {
      HRESULT hStat;
      IAAFRoot * iObj;
      ImplAAFRoot *arg;
      hStat = pPropVal->QueryInterface (IID_IAAFRoot, (void **)&iObj);
      assert (SUCCEEDED (hStat));
      assert (iObj);
      hStat = iObj->GetImplRep((void **)&arg);
      assert (SUCCEEDED (hStat));
      iObj->Release(); // we are through with this interface pointer.
      internalpPropVal = static_cast<ImplAAFPropertyValue*>(arg);
      assert (internalpPropVal);
    }

  //
  // set up for ppObject
  //
  ImplAAFRoot * internalppObject = NULL;
  ImplAAFRoot ** pinternalppObject = NULL;
  if (ppObject)
    {
      pinternalppObject = &internalppObject;
    }


  hr = ptr->GetObject
       (internalpPropVal,
        pinternalppObject);

  //
  // no cleanup necessary for pPropVal
  //

  //
  // cleanup for ppObject
  //
  if (internalppObject)
    {
      IUnknown *pUnknown = static_cast<IUnknown *> (internalppObject->GetContainer());
      HRESULT hStat = pUnknown->QueryInterface(iid, (void **)ppObject);
      if (SUCCEEDED(hr) && FAILED(hStat))
        hr = hStat;
      internalppObject->ReleaseReference(); // We are through with this pointer.
    }


    }
  catch (OMException& e)
    {
      // OMExceptions should be handled by the impl code. However, if an
      // unhandled OMException occurs, control reaches here. We must not
      // allow the unhandled exception to reach the client code, so we
      // turn it into a failure status code.
      //
      // If the OMException contains an HRESULT, it is returned to the
      // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
      //
      hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
    }
  catch (OMAssertionViolation &)
    {
      // Control reaches here if there is a programming error in the
      // impl code that was detected by an assertion violation.
      // We must not allow the assertion to reach the client code so
      // here we turn it into a failure status code.
      //
      hr = AAFRESULT_ASSERTION_VIOLATION;
    }
  catch (...)
    {
      // We CANNOT throw an exception out of a COM interface method!
      // Return a reasonable exception code.
      //
      hr = AAFRESULT_UNEXPECTED_EXCEPTION;
    }


  return hr;
}
Example #5
0
HRESULT STDMETHODCALLTYPE
    CAAFSelector::RemoveAlternateSegment (IAAFSegment * pSegment)
{
  HRESULT hr;

  ImplAAFSelector * ptr;
  ImplAAFRoot * pO;
  pO = GetRepObject ();
  assert (pO);
  ptr = static_cast<ImplAAFSelector*> (pO);
  assert (ptr);

  //
  // set up for pSegment
  //
  ImplAAFSegment * internalpSegment = NULL;
  if (pSegment)
    {
      HRESULT hStat;
      IAAFRoot * iObj;
      ImplAAFRoot *arg;
      hStat = pSegment->QueryInterface (IID_IAAFRoot, (void **)&iObj);
      assert (SUCCEEDED (hStat));
      assert (iObj);
      hStat = iObj->GetImplRep((void **)&arg);
      assert (SUCCEEDED (hStat));
      iObj->Release(); // we are through with this interface pointer.
      internalpSegment = static_cast<ImplAAFSegment*>(arg);
      assert (internalpSegment);
    }

  try
    {
      hr = ptr->RemoveAlternateSegment
       (internalpSegment);
    }
  catch (OMException& e)
    {
      // OMExceptions should be handled by the impl code. However, if an
      // unhandled OMException occurs, control reaches here. We must not
      // allow the unhandled exception to reach the client code, so we
      // turn it into a failure status code.
      //
      // If the OMException contains an HRESULT, it is returned to the
      // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
      //
      hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
    }
  catch (OMAssertionViolation &)
    {
      // Control reaches here if there is a programming error in the
      // impl code that was detected by an assertion violation.
      // We must not allow the assertion to reach the client code so
      // here we turn it into a failure status code.
      //
      hr = AAFRESULT_ASSERTION_VIOLATION;
    }
  catch (...)
    {
      // We CANNOT throw an exception out of a COM interface method!
      // Return a reasonable exception code.
      //
      hr = AAFRESULT_UNEXPECTED_EXCEPTION;
    }

  //
  // no cleanup necessary for pSegment
  //
  return hr;
}
Example #6
0
HRESULT STDMETHODCALLTYPE
    CAAFSourceClip::SetFade (aafInt32  fadeInLen,
        aafFadeType_t  fadeInType,
        aafInt32  fadeOutLen,
        aafFadeType_t  fadeOutType)
{
  HRESULT hr;

  ImplAAFSourceClip * ptr;
  ImplAAFRoot * pO;
  pO = GetRepObject ();
  assert (pO);
  ptr = static_cast<ImplAAFSourceClip*> (pO);
  assert (ptr);

  //
  // set up for fadeInType
  //
  if (! Is_aafFadeType_t_Valid(fadeInType))
    return AAFRESULT_INVALID_ENUM_VALUE;
  //
  // set up for fadeOutType
  //
  if (! Is_aafFadeType_t_Valid(fadeOutType))
    return AAFRESULT_INVALID_ENUM_VALUE;

  try
    {
      hr = ptr->SetFade
       (fadeInLen,
        fadeInType,
        fadeOutLen,
        fadeOutType);
    }
  catch (OMException& e)
    {
      // OMExceptions should be handled by the impl code. However, if an
      // unhandled OMException occurs, control reaches here. We must not
      // allow the unhandled exception to reach the client code, so we
      // turn it into a failure status code.
      //
      // If the OMException contains an HRESULT, it is returned to the
      // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
      //
      hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
    }
  catch (OMAssertionViolation &)
    {
      // Control reaches here if there is a programming error in the
      // impl code that was detected by an assertion violation.
      // We must not allow the assertion to reach the client code so
      // here we turn it into a failure status code.
      //
      hr = AAFRESULT_ASSERTION_VIOLATION;
    }
  catch (...)
    {
      // We CANNOT throw an exception out of a COM interface method!
      // Return a reasonable exception code.
      //
      hr = AAFRESULT_UNEXPECTED_EXCEPTION;
    }

  return hr;
}
Example #7
0
HRESULT STDMETHODCALLTYPE
    CEnumAAFFileDescriptors::Next (aafUInt32  count,
        IAAFFileDescriptor ** ppFileDescriptors,
        aafUInt32 *  pNumFetched)
{
  HRESULT hr;

  ImplEnumAAFFileDescriptors * ptr;
  ImplAAFRoot * pO;
  pO = GetRepObject ();
  assert (pO);
  ptr = static_cast<ImplEnumAAFFileDescriptors*> (pO);
  assert (ptr);

  //
  // set up for ppFileDescriptors
  //
  ImplAAFFileDescriptor ** internalppFileDescriptors = NULL;
  assert (count >= 0);
  internalppFileDescriptors = new ImplAAFFileDescriptor*[count];
  assert (internalppFileDescriptors);

  ImplAAFFileDescriptor ** pinternalppFileDescriptors = NULL;
  if (ppFileDescriptors)
    {
      pinternalppFileDescriptors = internalppFileDescriptors;
    }

  try
    {
      hr = ptr->Next
       (count,
        pinternalppFileDescriptors,
        pNumFetched);
    }
  catch (OMException& e)
    {
      // OMExceptions should be handled by the impl code. However, if an
      // unhandled OMException occurs, control reaches here. We must not
      // allow the unhandled exception to reach the client code, so we
      // turn it into a failure status code.
      //
      // If the OMException contains an HRESULT, it is returned to the
      // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
      //
      hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
    }
  catch (OMAssertionViolation &)
    {
      // Control reaches here if there is a programming error in the
      // impl code that was detected by an assertion violation.
      // We must not allow the assertion to reach the client code so
      // here we turn it into a failure status code.
      //
      hr = AAFRESULT_ASSERTION_VIOLATION;
    }
  catch (...)
    {
      // We CANNOT throw an exception out of a COM interface method!
      // Return a reasonable exception code.
      //
      hr = AAFRESULT_UNEXPECTED_EXCEPTION;
    }

  //
  // cleanup for ppFileDescriptors
  //
  if (SUCCEEDED(hr)||hr==AAFRESULT_NO_MORE_OBJECTS)
    {
      IUnknown *pUnknown;
      HRESULT hStat;
      aafUInt32 localIdx;
	  assert (count >= 0);
	  for (localIdx = 0; localIdx < *pNumFetched; localIdx++)
		{
		  pUnknown = static_cast<IUnknown *> (internalppFileDescriptors[localIdx]->GetContainer());
		  hStat = pUnknown->QueryInterface(IID_IAAFFileDescriptor, (void **)(ppFileDescriptors+localIdx));
		  assert (SUCCEEDED (hStat));
		  //pUnknown->Release();
		  internalppFileDescriptors[localIdx]->ReleaseReference(); // We are through with this pointer.
		}
    }
  delete[] internalppFileDescriptors;
  internalppFileDescriptors = 0;
  return hr;
}
Example #8
0
HRESULT STDMETHODCALLTYPE
    CAAFTypeDefRecord::Initialize (aafUID_constref  id,
        IAAFTypeDef ** ppMemberTypes,
        aafString_t *  pMemberNames,
        aafUInt32  numMembers,
        aafCharacter_constptr  pTypeName)
{
  HRESULT hr;

  ImplAAFTypeDefRecord * ptr;
  ImplAAFRoot * pO;
  pO = GetRepObject ();
  assert (pO);
  ptr = static_cast<ImplAAFTypeDefRecord*> (pO);
  assert (ptr);

  //
  // set up for ppMemberTypes
  //
  ImplAAFTypeDef ** internalppMemberTypes = NULL;
  if (ppMemberTypes)
    {
      aafUInt32 localIdx;
	  assert (numMembers >= 0);
	  internalppMemberTypes = new ImplAAFTypeDef*[numMembers];
	  assert (internalppMemberTypes);

	  for (localIdx = 0; localIdx < numMembers; localIdx++)
		{
		  HRESULT hStat;
		  IAAFRoot * iObj;
		  ImplAAFRoot *arg;
		  hStat = ppMemberTypes[localIdx]->QueryInterface (IID_IAAFRoot, (void **)&iObj);
		  assert (SUCCEEDED (hStat));
		  assert (iObj);
		  hStat = iObj->GetImplRep((void **)&arg);
		  assert (SUCCEEDED (hStat));
		  iObj->Release(); // we are through with this interface pointer.
		  internalppMemberTypes[localIdx] = static_cast<ImplAAFTypeDef*>(arg);
		  assert (internalppMemberTypes[localIdx]);
		}
    }

  try
    {
      hr = ptr->Initialize
       (id,
        internalppMemberTypes,
        const_cast<aafCharacter_constptr*>(pMemberNames),
        numMembers,
        pTypeName);
    }
  catch (OMException& e)
    {
      // OMExceptions should be handled by the impl code. However, if an
      // unhandled OMException occurs, control reaches here. We must not
      // allow the unhandled exception to reach the client code, so we
      // turn it into a failure status code.
      //
      // If the OMException contains an HRESULT, it is returned to the
      // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
      //
      hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
    }
  catch (OMAssertionViolation &)
    {
      // Control reaches here if there is a programming error in the
      // impl code that was detected by an assertion violation.
      // We must not allow the assertion to reach the client code so
      // here we turn it into a failure status code.
      //
      hr = AAFRESULT_ASSERTION_VIOLATION;
    }
  catch (...)
    {
      // We CANNOT throw an exception out of a COM interface method!
      // Return a reasonable exception code.
      //
      hr = AAFRESULT_UNEXPECTED_EXCEPTION;
    }

  //
  // cleanup for ppMemberTypes
  //
  if (internalppMemberTypes)
    {
      delete[] internalppMemberTypes;
      internalppMemberTypes = 0;
    }
  return hr;
}
Example #9
0
HRESULT STDMETHODCALLTYPE
    CAAFTypeDefRecord::CreateValueFromValues (IAAFPropertyValue ** pMemberValues,
        aafUInt32  numMembers,
        IAAFPropertyValue ** ppPropVal)
{
  HRESULT hr;

  ImplAAFTypeDefRecord * ptr;
  ImplAAFRoot * pO;
  pO = GetRepObject ();
  assert (pO);
  ptr = static_cast<ImplAAFTypeDefRecord*> (pO);
  assert (ptr);

  //
  // set up for pMemberValues
  //
  ImplAAFPropertyValue ** internalpMemberValues = NULL;
  if (pMemberValues)
    {
      aafUInt32 localIdx;
	  assert (numMembers >= 0);
	  internalpMemberValues = new ImplAAFPropertyValue*[numMembers];
	  assert (internalpMemberValues);

	  for (localIdx = 0; localIdx < numMembers; localIdx++)
		{
		  HRESULT hStat;
		  IAAFRoot * iObj;
		  ImplAAFRoot *arg;
		  hStat = pMemberValues[localIdx]->QueryInterface (IID_IAAFRoot, (void **)&iObj);
		  assert (SUCCEEDED (hStat));
		  assert (iObj);
		  hStat = iObj->GetImplRep((void **)&arg);
		  assert (SUCCEEDED (hStat));
		  iObj->Release(); // we are through with this interface pointer.
		  internalpMemberValues[localIdx] = static_cast<ImplAAFPropertyValue*>(arg);
		  assert (internalpMemberValues[localIdx]);
		}
    }
  //
  // set up for ppPropVal
  //
  ImplAAFPropertyValue * internalppPropVal = NULL;
  ImplAAFPropertyValue ** pinternalppPropVal = NULL;
  if (ppPropVal)
    {
      pinternalppPropVal = &internalppPropVal;
    }

  try
    {
      hr = ptr->CreateValueFromValues
       (internalpMemberValues,
        numMembers,
        pinternalppPropVal);
    }
  catch (OMException& e)
    {
      // OMExceptions should be handled by the impl code. However, if an
      // unhandled OMException occurs, control reaches here. We must not
      // allow the unhandled exception to reach the client code, so we
      // turn it into a failure status code.
      //
      // If the OMException contains an HRESULT, it is returned to the
      // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
      //
      hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
    }
  catch (OMAssertionViolation &)
    {
      // Control reaches here if there is a programming error in the
      // impl code that was detected by an assertion violation.
      // We must not allow the assertion to reach the client code so
      // here we turn it into a failure status code.
      //
      hr = AAFRESULT_ASSERTION_VIOLATION;
    }
  catch (...)
    {
      // We CANNOT throw an exception out of a COM interface method!
      // Return a reasonable exception code.
      //
      hr = AAFRESULT_UNEXPECTED_EXCEPTION;
    }

  //
  // cleanup for pMemberValues
  //
  if (internalpMemberValues)
    {
      delete[] internalpMemberValues;
      internalpMemberValues = 0;
    }
  //
  // cleanup for ppPropVal
  //
  if (SUCCEEDED(hr))
    {
      IUnknown *pUnknown;
      HRESULT hStat;

      if (internalppPropVal)
        {
          pUnknown = static_cast<IUnknown *> (internalppPropVal->GetContainer());
          hStat = pUnknown->QueryInterface(IID_IAAFPropertyValue, (void **)ppPropVal);
          assert (SUCCEEDED (hStat));
          //pUnknown->Release();
          internalppPropVal->ReleaseReference(); // We are through with this pointer.
        }
    }
  return hr;
}
Example #10
0
HRESULT STDMETHODCALLTYPE
    CAAFClassDef::RegisterNewPropertyDef (aafUID_constref  id,
        aafCharacter_constptr  pName,
        IAAFTypeDef * pTypeDef,
        aafBoolean_t  isOptional,
        aafBoolean_t  isUniqueIdentifier,
        IAAFPropertyDef ** ppPropDef)
{
  HRESULT hr;

  ImplAAFClassDef * ptr;
  ImplAAFRoot * pO;
  pO = GetRepObject ();
  assert (pO);
  ptr = static_cast<ImplAAFClassDef*> (pO);
  assert (ptr);

  //
  // set up for pTypeDef
  //
  ImplAAFTypeDef * internalpTypeDef = NULL;
  if (pTypeDef)
    {
      HRESULT hStat;
      IAAFRoot * iObj;
      ImplAAFRoot *arg;
      hStat = pTypeDef->QueryInterface (IID_IAAFRoot, (void **)&iObj);
      assert (SUCCEEDED (hStat));
      assert (iObj);
      hStat = iObj->GetImplRep((void **)&arg);
      assert (SUCCEEDED (hStat));
      iObj->Release(); // we are through with this interface pointer.
      internalpTypeDef = static_cast<ImplAAFTypeDef*>(arg);
      assert (internalpTypeDef);
    }
  //
  // set up for isOptional
  //
  if (! Is_aafBoolean_t_Valid(isOptional))
    return AAFRESULT_INVALID_ENUM_VALUE;
  //
  // set up for isUniqueIdentifier
  //
  if (! Is_aafBoolean_t_Valid(isUniqueIdentifier))
    return AAFRESULT_INVALID_ENUM_VALUE;
  //
  // set up for ppPropDef
  //
  ImplAAFPropertyDef * internalppPropDef = NULL;
  ImplAAFPropertyDef ** pinternalppPropDef = NULL;
  if (ppPropDef)
    {
      pinternalppPropDef = &internalppPropDef;
    }

  try
    {
      hr = ptr->RegisterNewPropertyDef
       (id,
        pName,
        internalpTypeDef,
        isOptional,
        isUniqueIdentifier,
        pinternalppPropDef);
    }
  catch (OMException& e)
    {
      // OMExceptions should be handled by the impl code. However, if an
      // unhandled OMException occurs, control reaches here. We must not
      // allow the unhandled exception to reach the client code, so we
      // turn it into a failure status code.
      //
      // If the OMException contains an HRESULT, it is returned to the
      // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
      //
      hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
    }
  catch (OMAssertionViolation &)
    {
      // Control reaches here if there is a programming error in the
      // impl code that was detected by an assertion violation.
      // We must not allow the assertion to reach the client code so
      // here we turn it into a failure status code.
      //
      hr = AAFRESULT_ASSERTION_VIOLATION;
    }
  catch (...)
    {
      // We CANNOT throw an exception out of a COM interface method!
      // Return a reasonable exception code.
      //
      hr = AAFRESULT_UNEXPECTED_EXCEPTION;
    }

  //
  // no cleanup necessary for pTypeDef
  //
  //
  // cleanup for ppPropDef
  //
  if (SUCCEEDED(hr))
    {
      IUnknown *pUnknown;
      HRESULT hStat;

      if (internalppPropDef)
        {
          pUnknown = static_cast<IUnknown *> (internalppPropDef->GetContainer());
          hStat = pUnknown->QueryInterface(IID_IAAFPropertyDef, (void **)ppPropDef);
          assert (SUCCEEDED (hStat));
          //pUnknown->Release();
          internalppPropDef->ReleaseReference(); // We are through with this pointer.
        }
    }
  return hr;
}
Example #11
0
//
// Creates an object of this class, and returns it by reference in
  /// the location specified by the ppObject argument.
  /// 
  /// Succeeds if:
  /// - The ppObject pointer is valid.
  ///
  /// This method will return the following codes.  If more than one of
  /// the listed errors is in effect, it will return the first one
  /// encountered in the order given below:
  /// 
  /// AAFRESULT_SUCCESS
  ///   - succeeded.  (This is the only code indicating success.)
  ///
  /// AAFRESULT_NULL_PARAM
  ///   - ppObject arg is NULL.
HRESULT CAAFClassDef::CreateInstance
   (// Reference to the identifier of the interface
    /*[in, ref]*/ REFIID riid,

    // Address of output variable that receives the 
    // interface pointer requested in riid
    /*[out, iid_is(riid)]*/ IUnknown ** ppvObject)
{
  HRESULT hr = S_OK;
  AAFRESULT result = AAFRESULT_SUCCESS;

  // Validate the input arguments.
  if (NULL == ppvObject)
    return E_INVALIDARG;

  // Find the factory on the corresponding impl class.
  ImplAAFRoot * pImplRoot = GetRepObject();
  assert(pImplRoot);
  ImplAAFClassDef * pImplAAFClassDef = dynamic_cast<ImplAAFClassDef *>(pImplRoot);
  if (NULL == pImplAAFClassDef)
  { // This should never happen.
    return AAFRESULT_INTERNAL_ERROR;
  }

  // Get the class id and make sure then this is not a private class...
  aafUID_t id;
  result = pImplAAFClassDef->GetAUID(&id);
  if (AAFRESULT_SUCCESS != result)
    return result;
      
  
  // Make sure that the client fails when they attempt to create a "private"
  // toolkit object instance.
  const AAFObjectModel * pObjectModel = AAFObjectModel::singleton();
  assert(pObjectModel); // this is statically contructed so it should not fail.
  const ClassDefinition * classDefinition = pObjectModel->findClassDefinition(&id);
  if (NULL != classDefinition)
  {
    if (classDefinition->privateClass())
      return AAFRESULT_INVALID_CLASS_ID;
  }


  // Create the corresponding impl object.
  ImplAAFObject *pObject = NULL;
  result = pImplAAFClassDef->CreateInstance(&pObject);
  if (AAFRESULT_SUCCESS != result)
    return result;

  // Get the COM container for the new Impl object and see if
  // it supports the requested interface pointer.
  IUnknown *pUnknown = static_cast<IUnknown *>(pObject->GetContainer());
  assert(pUnknown);
  hr = pUnknown->QueryInterface(riid, (void **)ppvObject);
  
  // Release the impl object pointer. If the previous QI failed
  // then the object will be deleted.
  pObject->ReleaseReference();

  return hr;
}