AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefRename::GetBaseValue ( ImplAAFPropertyValue * pInPropVal, ImplAAFPropertyValue ** ppOutPropVal) { if (! pInPropVal) return AAFRESULT_NULL_PARAM; if (! ppOutPropVal) return AAFRESULT_NULL_PARAM; // Get the property value's embedded type and // check if it's the same as the base type. ImplAAFTypeDefSP pInPropType; if( AAFRESULT_FAILED( pInPropVal->GetType( &pInPropType ) ) ) return AAFRESULT_BAD_TYPE; ASSERTU (pInPropType); if( (ImplAAFTypeDef *)pInPropType != this ) return AAFRESULT_BAD_TYPE; aafUInt32 inBitsSize; ImplAAFPropValDataSP pOutPVData; ImplAAFPropValDataSP pvd; ImplAAFTypeDefSP ptd; AAFRESULT hr; hr = GetBaseType (&ptd); if (AAFRESULT_FAILED (hr)) return hr; ASSERTU (ptd); // aafUInt32 elementSize = ptd->PropValSize(); ASSERTU (pInPropVal); pvd = dynamic_cast<ImplAAFPropValData*> (pInPropVal); ASSERTU (pvd); hr = pvd->GetBitsSize (&inBitsSize); if (! AAFRESULT_SUCCEEDED (hr)) return hr; pOutPVData = (ImplAAFPropValData *)CreateImpl(CLSID_AAFPropValData); if (! pOutPVData) return AAFRESULT_NOMEMORY; // Bobt: Hack bugfix! SmartPointer operator= will automatically // AddRef; CreateImpl *also* will addref, so we've got one too // many. Put us back to normal. pOutPVData->ReleaseReference (); ASSERTU (ptd); hr = pOutPVData->Initialize (ptd); if (AAFRESULT_FAILED(hr)) return hr; hr = pOutPVData->AllocateFromPropVal (pvd, 0, inBitsSize, NULL); if (AAFRESULT_FAILED(hr)) return hr; ASSERTU (ppOutPropVal); *ppOutPropVal = pOutPVData; (*ppOutPropVal)->AcquireReference (); ASSERTU (*ppOutPropVal); return AAFRESULT_SUCCESS; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefRename::CreateValue ( ImplAAFPropertyValue * pInPropVal, ImplAAFPropertyValue ** ppOutPropVal) { if (! pInPropVal) return AAFRESULT_NULL_PARAM; if (! ppOutPropVal) return AAFRESULT_NULL_PARAM; aafUInt32 inBitsSize; ImplAAFPropValDataSP pOutPVData; ImplAAFPropValDataSP pvd; AAFRESULT hr; ASSERTU (pInPropVal); pvd = dynamic_cast<ImplAAFPropValData*> (pInPropVal); ASSERTU (pvd); hr = pvd->GetBitsSize (&inBitsSize); if (! AAFRESULT_SUCCEEDED (hr)) return hr; pOutPVData = (ImplAAFPropValData *)CreateImpl(CLSID_AAFPropValData); if (! pOutPVData) return AAFRESULT_NOMEMORY; // SmartPointer operator= will automatically AddRef; CreateImpl *also* will // addref, so we've got one too many. Put us back to normal. pOutPVData->ReleaseReference (); hr = pOutPVData->Initialize (this); if (AAFRESULT_FAILED(hr)) return hr; hr = pOutPVData->AllocateFromPropVal (pvd, 0, inBitsSize, NULL); if (AAFRESULT_FAILED(hr)) return hr; ASSERTU (ppOutPropVal); *ppOutPropVal = pOutPVData; (*ppOutPropVal)->AcquireReference (); ASSERTU (*ppOutPropVal); return AAFRESULT_SUCCESS; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefArray::GetElementValue ( ImplAAFPropertyValue * pInPropVal, aafUInt32 index, ImplAAFPropertyValue ** ppOutPropVal) { if (! pInPropVal) return AAFRESULT_NULL_PARAM; if (! ppOutPropVal) return AAFRESULT_NULL_PARAM; // Get the property value's embedded type and // check if it's the same as the base type. ImplAAFTypeDefSP pIncomingType; if( AAFRESULT_FAILED( pInPropVal->GetType( &pIncomingType ) ) ) return AAFRESULT_BAD_TYPE; ASSERTU (pIncomingType); if( (ImplAAFTypeDef *)pIncomingType != this ) return AAFRESULT_BAD_TYPE; ImplAAFRefArrayValue* pRefArray = dynamic_cast<ImplAAFRefArrayValue*>(pInPropVal); if (NULL != pRefArray) { return pRefArray->GetElementAt(index, ppOutPropVal); } if (index >= pvtCount (pInPropVal)) return AAFRESULT_BADINDEX; aafUInt32 inBitsSize; ImplAAFPropValDataSP pOutPVData; ImplAAFPropValDataSP pvd; ImplAAFTypeDefSP ptd; AAFRESULT hr; hr = GetType (&ptd); if (AAFRESULT_FAILED (hr)) return hr; // aafUInt32 elementSize = ptd->PropValSize(); aafUInt32 elementSize = ptd->ActualSize(); // okay for data not to be registered? ASSERTU (pInPropVal); pvd = dynamic_cast<ImplAAFPropValData*> (pInPropVal); hr = pvd->GetBitsSize (&inBitsSize); if (! AAFRESULT_SUCCEEDED (hr)) return hr; ASSERTU ((index+1) * elementSize <= inBitsSize); pOutPVData = (ImplAAFPropValData *)CreateImpl(CLSID_AAFPropValData); if (! pOutPVData) return AAFRESULT_NOMEMORY; // Bobt: Hack bugfix! SmartPointer operator= will automatically // AddRef; CreateImpl *also* will addref, so we've got one too // many. Put us back to normal. pOutPVData->ReleaseReference (); hr = pOutPVData->Initialize (ptd); if (AAFRESULT_FAILED(hr)) return hr; hr = pOutPVData->AllocateFromPropVal (pvd, index * elementSize, elementSize, NULL); if (AAFRESULT_FAILED(hr)) return hr; ASSERTU (ppOutPropVal); *ppOutPropVal = pOutPVData; ASSERTU (*ppOutPropVal); (*ppOutPropVal)->AcquireReference (); return AAFRESULT_SUCCESS; }