OMUInt32 ImplAAFTypeDef::ActualSize (void) const { if (IsRegistered()) return NativeSize(); else return PropValSize(); }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefCharacter::GetCharacter ( ImplAAFPropertyValue * pCharacterValue, aafCharacter * pCharacter) { TRACE("ImplAAFTypeDefCharacter::GetCharacter"); if (! pCharacterValue) return AAFRESULT_NULL_PARAM; if (! pCharacter) return AAFRESULT_NULL_PARAM; //get a pointer to the Val Data ImplAAFPropValDataSP pvd; pvd = dynamic_cast<ImplAAFPropValData*>(pCharacterValue); if (!pvd) return AAFRESULT_BAD_TYPE; // get the property value's embedded type ImplAAFTypeDefSP pPropType; check_hr ( pvd->GetType (&pPropType) ); //Make sure the TD of the pv passed in, matches that of the ImplAAFTypeDefCharacter if ((ImplAAFTypeDef *)pPropType != this) // call operator ImplAAFTypeDef * return AAFRESULT_BAD_TYPE; //check to make sure that the size in the val data matches that of the native size aafUInt32 cbChar = 0; check_hr ( pvd->GetBitsSize(&cbChar) ); if (cbChar != NativeSize()) { return AAFRESULT_BAD_SIZE; } //Now set the character from that contained in the prop val data aafMemPtr_t pBits = NULL; check_hr ( pvd->GetBits (&pBits) ); ASSERT("Valid bits", pBits != 0); memcpy (pCharacter, pBits, cbChar); return AAFRESULT_SUCCESS; }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefCharacter::CreateValueFromCharacter ( aafCharacter character, ImplAAFPropertyValue ** ppCharacterValue) { TRACE("ImplAAFTypeDefCharacter::CreateValueFromCharacter"); if (! ppCharacterValue) return AAFRESULT_NULL_PARAM; aafUInt32 cbChar = NativeSize(); // Create a temporary pointer to copy to the smartptr ImplAAFPropValData * tmp = (ImplAAFPropValData *)CreateImpl(CLSID_AAFPropValData); if (NULL == tmp) return AAFRESULT_NOMEMORY; ImplAAFPropValDataSP pv; pv = tmp; tmp->ReleaseReference(); // we don't need this reference anymore. tmp = 0; //Initialize check_hr ( pv->Initialize(this) ); //Allocate appropriate bits aafMemPtr_t pBits = NULL; check_hr ( pv->AllocateBits (cbChar, &pBits) ); //Set the bits to incoming character ASSERT("Valid bits", pBits != 0); memcpy (pBits, &character, cbChar); *ppCharacterValue = pv; (*ppCharacterValue)->AcquireReference (); return AAFRESULT_SUCCESS; }
OMUInt32 ImplAAFTypeDefCharacter::internalSize(void) const { return NativeSize(); }
OMUInt32 ImplAAFTypeDefStream::internalSize(void) const { return NativeSize(); }
OMUInt32 ImplAAFTypeDefRename::internalSize(void) const { return NativeSize(); }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefArray::SetCArray ( ImplAAFPropertyValue * pPropVal, aafMemPtr_t pData, aafUInt32 dataSize) { if (! pPropVal) return AAFRESULT_NULL_PARAM; if (! pData) return AAFRESULT_NULL_PARAM; if (! IsRegistered ()) return AAFRESULT_NOT_REGISTERED; // Get the property value's embedded type and // check if it's the same as the base type. ImplAAFTypeDefSP pIncomingType; if( AAFRESULT_FAILED( pPropVal->GetType( &pIncomingType ) ) ) return AAFRESULT_BAD_TYPE; ASSERTU (pIncomingType); if( (ImplAAFTypeDef *)pIncomingType != this ) return AAFRESULT_BAD_TYPE; AAFRESULT hr; ImplAAFTypeDefSP pBaseType; hr = GetType (&pBaseType); ASSERTU (pBaseType->IsFixedSize ()); pBaseType->AttemptBuiltinRegistration (); ASSERTU (pBaseType->IsRegistered ()); ImplAAFRefArrayValue* pRefArray = dynamic_cast<ImplAAFRefArrayValue*>(pPropVal); if (NULL != pRefArray) { // This interface is not type-safe for accessing objects! There is also no // mechanism in place to convert between a buffer pointer and an array // of interface pointers; this convertion would not be necessary for // arrays of non-objects. return AAFRESULT_BAD_TYPE; } // Size of individual elements aafUInt32 elemSize = pBaseType->NativeSize (); // number of elements in input data. If this is not an integral // number, this will round down and the test below will fail. aafUInt32 elemCount = dataSize / elemSize; // The size of the new property, calculated from number of elements // and the size of each element. aafUInt32 propSize = elemSize * elemCount; // If the given dataSize was not an integral multiple of the size of // each element, then we'll signal an error. if (propSize != dataSize) return AAFRESULT_BAD_SIZE; // In case of fixed-size arrays, we'll also have to see if the data // size matches what we're expecting. if (IsFixedSize ()) { aafUInt32 nativeSize = NativeSize (); if (nativeSize != dataSize) return AAFRESULT_BAD_SIZE; } ImplAAFPropValData * pvd = 0; ASSERTU (pPropVal); pvd = dynamic_cast<ImplAAFPropValData*> (pPropVal); ASSERTU (pvd); aafMemPtr_t pBits = 0; hr = pvd->AllocateBits (propSize, &pBits); if (AAFRESULT_FAILED (hr)) return hr; ASSERTU (pBits); memcpy (pBits, pData, propSize); return AAFRESULT_SUCCESS; }