Пример #1
0
// Get the value of the OMObjectVector at position index.
AAFRESULT STDMETHODCALLTYPE ImplAAFRefArrayValue::GetElementAt(
  aafUInt32 index,
  ImplAAFPropertyValue** ppPropertyValue) const
{
  AAFRESULT result = AAFRESULT_SUCCESS;
  if (NULL == ppPropertyValue)
    return AAFRESULT_NULL_PARAM;
  *ppPropertyValue = NULL;
  
  ImplAAFStorableSP pObject;
  result = GetObjectAt(index, &pObject);
  if (AAFRESULT_FAILED(result))
    return result;

  ImplAAFTypeDefObjectRef *pElementType = GetElementType();
  ASSERTU(NULL != pElementType);
  if (NULL == pElementType)
    return AAFRESULT_INVALID_OBJ;
    
  result = pElementType->CreateValue((ImplAAFStorable *)pObject, ppPropertyValue);
  if (AAFRESULT_FAILED(result))
    return result;
  
  return result;  
}
Пример #2
0
/* static */ ImplAAFStorable * ImplAAFRefContainerValue::GetStorableFromPropertyValue(
  ImplAAFPropertyValue* pPropertyValue,
  AAFRESULT & result)
{
  result = AAFRESULT_SUCCESS;
  ASSERTU(NULL != pPropertyValue);
  
  ImplAAFStorable* storable = NULL; // initialize the returned parameter
  
  // Make sure that the type definition can contain a single object
  // reference.
  ImplAAFTypeDefSP pPropertyValueType;
  result = pPropertyValue->GetType(&pPropertyValueType);
  if (AAFRESULT_FAILED(result))
    return NULL;
  ImplAAFTypeDefObjectRef* pObjectRefType = NULL;
  pObjectRefType = dynamic_cast<ImplAAFTypeDefObjectRef *>((ImplAAFTypeDef *)pPropertyValueType);
  if (NULL == pObjectRefType)
  {
    result = AAFRESULT_INVALID_PARAM;
    return NULL;
  }
  
  // Use the type to extract the object from the input property
  // value.
  ImplAAFRoot *pObject = NULL;
  result = pObjectRefType->GetObject(pPropertyValue, &pObject); // returns reference counted object!
  if (AAFRESULT_FAILED(result))
    return NULL;
    
  // the returned object is NOT reference counted.
  pObject->ReleaseReference();

  storable = ImplAAFRefValue::ConvertRootToOMStorable(pObject);
  ASSERTU(NULL != storable);
  if (NULL == storable)
    result = AAFRESULT_INVALID_OBJ; 

  
  return storable;  
}
Пример #3
0
HRESULT STDMETHODCALLTYPE
    CAAFTypeDefObjectRef::GetObjectType (IAAFClassDef ** ppObjType)
{
  HRESULT hr;

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

  //
  // set up for ppObjType
  //
  ImplAAFClassDef * internalppObjType = NULL;
  ImplAAFClassDef ** pinternalppObjType = NULL;
  if (ppObjType)
    {
      pinternalppObjType = &internalppObjType;
    }

  try
    {
      hr = ptr->GetObjectType
       (pinternalppObjType);
    }
  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 ppObjType
  //
  if (SUCCEEDED(hr))
    {
      IUnknown *pUnknown;
      HRESULT hStat;

      if (internalppObjType)
        {
          pUnknown = static_cast<IUnknown *> (internalppObjType->GetContainer());
          hStat = pUnknown->QueryInterface(IID_IAAFClassDef, (void **)ppObjType);
          assert (SUCCEEDED (hStat));
          //pUnknown->Release();
          internalppObjType->ReleaseReference(); // We are through with this pointer.
        }
    }
  return hr;
}
Пример #4
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;
}
Пример #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;
}