Ejemplo n.º 1
0
// Return the reference count of the given implementation object
// container's reference count.
aafUInt32 ReferenceImplCount(ImplAAFRoot *pObj)
{
    IAAFRoot * pRoot = static_cast<IAAFRoot *>(pObj->GetContainer());
    assert(pRoot);
    pRoot->AddRef();
    return pRoot->Release();
}
Ejemplo n.º 2
0
// Creates and returns an Impl object based on the given class ID.
// Will create the appropriate kind of API class and attach it.
//
// Implementation note:  This function does the following:
// 1) Create the API class.  (The API class will create the Impl class
//    and attach it.)
// 2) Ask the newly created API class for its contained Impl class.
// 3) Return that Impl class.
//
ImplAAFRoot * CreateImpl (const aafClassID_t & rClassID)
{
    IAAFRoot	*pIAAFRoot;
    ImplAAFRoot	*implRoot;
    HRESULT		hr;
    CLSID           classID;

    // Cast (by bitwise copy) from aafClassID_t to CLSID.
    //
    memcpy(&classID, &rClassID, sizeof(CLSID));

    // The reference implementation must be "self-contained". We do
    // not want any user supplied classes to be created and used
    // instead on one our built-in classes.
    //
    // The simplest change is to just simulate a call to
    // CoCreateInstance:
    //
    // This code is invoked within the current module so we
    // should just be able to call the DllGetClassObject entry point
    // instead of calling CoCreateInstance and searching the
    // registry.
    IClassFactory *pFactory = NULL;
    hr = DllGetClassObject(classID, IID_IClassFactory, (void **)&pFactory);
    if (SUCCEEDED(hr))
    {
        hr = pFactory->CreateInstance(NULL, IID_IAAFRoot, (void **)&pIAAFRoot);
        pFactory->Release();
    }

    if (SUCCEEDED(hr))
        pIAAFRoot->GetImplRep((void **)&implRoot);
    else
        implRoot = NULL;

    return (implRoot);
}
Ejemplo n.º 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;
}
Ejemplo n.º 4
0
// Increases the reference count of the API container object.
aafUInt32 AcquireImplReference(ImplAAFRoot *pObj)
{
    IAAFRoot * pRoot = static_cast<IAAFRoot *>(pObj->GetContainer());
    assert(pRoot);
    return pRoot->AddRef();
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
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;
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
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;
}
Ejemplo n.º 9
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;
}