AAFRESULT STDMETHODCALLTYPE ImplAAFKLVData::SetValue (aafUInt32 valueSize, aafDataBuffer_t pValue) { AAFRESULT result = AAFRESULT_SUCCESS; ImplAAFTypeDef *pDef = NULL; ImplAAFDictionary *pDict = NULL; aafUID_t keyUID; if (!pValue) return AAFRESULT_NULL_PARAM; if (valueSize > OMPROPERTYSIZE_MAX) return AAFRESULT_BAD_SIZE; if (!_cachedRenameTypeDef) { // Lookup the type definition from this KLV data. If it fails // then the control point is invalid! result = GetKey(&keyUID); if (AAFRESULT_FAILED(result)) return result; result = GetDictionary(&pDict); if (AAFRESULT_FAILED(result)) return result; result = pDict->LookupTypeDef(keyUID, &pDef); pDict->ReleaseReference(); pDict = 0; if (AAFRESULT_FAILED(result)) return result; pDef->ReleaseReference(); // This object is owned by the dictionary! _cachedRenameTypeDef = dynamic_cast<ImplAAFTypeDefRename*>(pDef); if (NULL == _cachedRenameTypeDef) return AAFRESULT_INVALID_OBJ; } // Validate the property and get the property definition and type definition, // and the actual length of the data return (ImplAAFTypeDefIndirect::SetActualPropertyValue (_value, _cachedRenameTypeDef, pValue, valueSize)); }
AAFRESULT ImplAAFPropertyDef::MergeTo( ImplAAFClassDef* pDestClassDef ) { ASSERTU( pDestClassDef ); AAFRESULT hr = AAFRESULT_SUCCESS; // This property ID aafUID_t propertyID; GetAUID( &propertyID ); if( ! pDestClassDef->PvtIsPropertyDefRegistered( propertyID ) ) { ImplAAFDictionary* pDestDictionary = NULL; pDestClassDef->GetDictionary( &pDestDictionary ); aafUInt32 nameBufLen = 0; GetNameBufLen( &nameBufLen ); aafUInt8* pName = new aafUInt8[ nameBufLen ]; GetName( (aafCharacter*)pName, nameBufLen ); // Find the property type definition in the destination file ImplAAFTypeDef* pTypeDef = NULL; GetTypeDef( &pTypeDef ); aafUID_t typeID; pTypeDef->GetAUID( &typeID ); pTypeDef->MergeTo( pDestDictionary ); pTypeDef->ReleaseReference(); pTypeDef = NULL; ImplAAFTypeDef* pDestTypeDef = NULL; pDestDictionary->LookupTypeDef( typeID, &pDestTypeDef ); ASSERTU( pDestTypeDef != NULL ); // Register the property definition. // The property registering method to use depends on whether // this class definition is attached to or detached from // the dictionary. ImplAAFPropertyDef* pDestPropertyDef = NULL; aafUID_t classID; pDestClassDef->GetAUID( &classID ); if( pDestDictionary->PvtIsClassPresent( classID ) ) { // This class definition is in the dictionary - only // optional properties can be registered. ASSERTU( _IsOptional == kAAFTrue ); hr = pDestClassDef->RegisterOptionalPropertyDef( propertyID, (aafCharacter*)pName, pDestTypeDef, &pDestPropertyDef ); } else { // This class definition is not in the dictionary - // any properties can be registered. aafBoolean_t isUniqueIdentifier = kAAFFalse; if( _IsUniqueIdentifier.isPresent() ) { isUniqueIdentifier = _IsUniqueIdentifier; } hr = pDestClassDef->RegisterNewPropertyDef( propertyID, (aafCharacter*)pName, pDestTypeDef, _IsOptional, isUniqueIdentifier, &pDestPropertyDef ); } // If present, copy the property definition description. if( AAFRESULT_SUCCEEDED( hr ) ) { aafUInt32 descriptionBufLen = 0; GetDescriptionBufLen( &descriptionBufLen ); if( descriptionBufLen > 0 ) { aafUInt8* pDescription = new aafUInt8[ descriptionBufLen ]; GetDescription( (aafCharacter*)pDescription, descriptionBufLen ); hr = pDestPropertyDef->SetDescription( (aafCharacter*)pDescription ); delete[] pDescription; pDescription = NULL; } } // Because RegisterOptionalPropertyDef/RegisterNewPropertyDef can // fail (for example, if the property's already registered with a // different class), pDestPropertyDef may not be a valid pointer. if( pDestPropertyDef ) { pDestPropertyDef->ReleaseReference(); pDestPropertyDef = NULL; } pDestTypeDef->ReleaseReference(); pDestTypeDef = NULL; delete[] pName; pName = NULL; pDestDictionary->ReleaseReference(); pDestDictionary = NULL; } return hr; }