Exemple #1
0
HRESULT STDMETHODCALLTYPE
    CAAFTypeDefObjectRef::CreateValue (IUnknown * pObj,
        IAAFPropertyValue ** ppPropVal)
{
  HRESULT hr;

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

  //
  // set up for pObj
  //
  ImplAAFRoot * internalpObj = NULL;
  if (pObj)
    {
      HRESULT hStat;
      IAAFRoot * iObj;
      ImplAAFRoot *arg;
      hStat = pObj->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.
      internalpObj = static_cast<ImplAAFRoot*>(arg);
      assert (internalpObj);
    }
  //
  // set up for ppPropVal
  //
  ImplAAFPropertyValue * internalppPropVal = NULL;
  ImplAAFPropertyValue ** pinternalppPropVal = NULL;
  if (ppPropVal)
    {
      pinternalppPropVal = &internalppPropVal;
    }

  try
    {
      hr = ptr->CreateValue
       (internalpObj,
        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;
    }

  //
  // no cleanup necessary for pObj
  //
  //
  // 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;
}
Exemple #2
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;
}
Exemple #3
0
HRESULT STDMETHODCALLTYPE
    CAAFTypeDefRecord::CreateValueFromStruct (aafMemPtr_t  pInitData,
        aafUInt32  initDataSize,
        IAAFPropertyValue ** ppPropVal)
{
  HRESULT hr;

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

  //
  // set up for ppPropVal
  //
  ImplAAFPropertyValue * internalppPropVal = NULL;
  ImplAAFPropertyValue ** pinternalppPropVal = NULL;
  if (ppPropVal)
    {
      pinternalppPropVal = &internalppPropVal;
    }

  try
    {
      hr = ptr->CreateValueFromStruct
       (pInitData,
        initDataSize,
        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 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;
}
Exemple #4
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefArray::CreateValueFromValues (
													ImplAAFPropertyValue ** ppElementValues,
													aafUInt32  numElements,
													ImplAAFPropertyValue ** ppPropVal)
{
	AAFRESULT hr = AAFRESULT_SUCCESS;
	
	//first validate params ...
	if (!ppPropVal)
		return AAFRESULT_NULL_PARAM;
	
	hr = ValidateInputParams(ppElementValues, numElements);
	if (AAFRESULT_FAILED (hr))
	  return hr;

	// All params validated; proceed ....

  // PATCH DR4_CPR: transdel. Create the appropriate ImplAAFRefArray without an associated
  // property. The property value's writeTo method needs to copy (or replace) the contents
  // of the current property. This a hybrid of the old-pseudo "direct access" and the new
  // more direct property access.

  ImplAAFTypeDefSP pElementType;
  hr = GetType(&pElementType);
  if (AAFRESULT_FAILED(hr))
    return hr;

  if (dynamic_cast<ImplAAFTypeDefObjectRef*>((ImplAAFTypeDef*) pElementType))
  {
    ImplAAFPropertyValue *pPropertyValue = NULL;
    hr = CreateEmptyValue(&pPropertyValue);
    if (AAFRESULT_SUCCEEDED(hr))
    {
      ImplAAFRefArrayValue *pRefArray = dynamic_cast<ImplAAFRefArrayValue *>(pPropertyValue);
      ASSERTU(NULL != pRefArray);
      if (NULL == pRefArray)
        hr = AAFRESULT_INVALID_OBJ;
      
      aafUInt32 index;
      for (index = 0; (index < numElements) && AAFRESULT_SUCCEEDED(hr); ++index)
      {
        hr = pRefArray->AppendElement(ppElementValues[index]);
      }
      
      if (AAFRESULT_SUCCEEDED(hr))
        *ppPropVal = pPropertyValue; // refcount already incremented
      else
        pPropertyValue->ReleaseReference();
        
      pPropertyValue = NULL;
    }
  }
  else
  {
  	//2nd step - Create the value;  defer to base impl

  	//first, calculate the total size needed for allocation, based on type
  	//get Base TD
  	ImplAAFTypeDefSP spTargetTD;
  	hr = GetType(&spTargetTD); //gets base elem type
  	if (AAFRESULT_FAILED (hr)) return hr;
  	//Get Elem size
  	aafUInt32 targetElemSize = spTargetTD->NativeSize();
  	//Total size ...
  	aafUInt32 totalSize = targetElemSize * numElements; //size based on "n" Elements
  	
  	//create the value
  	hr = ImplAAFTypeDefArray::CreateValue(ppPropVal, totalSize);
  	if (AAFRESULT_FAILED(hr)) return hr;
  	
  	
  	//... Copy the values ; defer to base impl
  	hr = ImplAAFTypeDefArray::CopyValuesIntoValue(ppElementValues,numElements,
  												targetElemSize, ppPropVal);
	}
	
	return hr;
}