// 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; }
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; }