Ejemplo n.º 1
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefExtEnum::GetNameBufLenFromAUID (
											  const aafUID_t & value,
											  aafUInt32 * pLen)
{
	if (! pLen)
		return AAFRESULT_NULL_PARAM;
	
	aafUInt32 i;
	aafUInt32 count;
	AAFRESULT hr;
	hr = CountElements(&count);
	if (AAFRESULT_FAILED(hr))
		return hr;
	for (i = 0; i < count; i++)
	{
		aafUID_t val;
		hr = GetElementValue (i, &val);
		if (AAFRESULT_FAILED(hr))
			return hr;
		if (EqualAUID (&val, &value))
		{
			aafUInt32 len;
			hr = GetElementNameBufLen(i, &len);
			if (AAFRESULT_FAILED(hr))
				return hr;
			ASSERTU (pLen);
			*pLen = len;
			return AAFRESULT_SUCCESS;
		}
	}
	// fell out of for() loop, so we didn't find it.
	return AAFRESULT_ILLEGAL_VALUE;
}
Ejemplo n.º 2
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;  
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefArray::CreateValueFromCArray (
											aafMemPtr_t pInitData,
											aafUInt32 initDataSize,
											ImplAAFPropertyValue ** ppPropVal)
{
	if (! pInitData)
		return AAFRESULT_NULL_PARAM;
	
	if (! ppPropVal)
		return AAFRESULT_NULL_PARAM;
	
  ImplAAFTypeDefSP pElementType;
  AAFRESULT result = GetType(&pElementType);
  if (AAFRESULT_FAILED(result))
    return result;     
      
  if (dynamic_cast<ImplAAFTypeDefObjectRef*>((ImplAAFTypeDef*) pElementType))
  {
    // 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;
  }

	ImplAAFPropValDataSP pvd;
	ImplAAFPropValData * tmp;
	tmp = (ImplAAFPropValData*) CreateImpl (CLSID_AAFPropValData);
	if (!tmp) return AAFRESULT_NOMEMORY;
	pvd = tmp;
	// the pvd smart pointer will maintain a reference for us...
	aafUInt32 refCount;
	refCount = tmp->ReleaseReference ();
	// ...make sure it really does
	ASSERTU (1 == refCount);
	
	AAFRESULT hr;
	hr = pvd->Initialize(this);
	if (! AAFRESULT_SUCCEEDED (hr))
		return hr;
	
	hr = SetCArray (pvd, pInitData, initDataSize);
	if (AAFRESULT_FAILED (hr))
		return hr;
	
	ASSERTU (ppPropVal);
	*ppPropVal = pvd;
	ASSERTU (*ppPropVal);
	(*ppPropVal)->AcquireReference ();
	return AAFRESULT_SUCCESS;
}
Ejemplo n.º 5
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefArray::ValidateInputParams (
												  ImplAAFPropertyValue ** ppElementValues,
												  aafUInt32  numElements)
												  
{
	//first validate params + basic stuff ...
	if (!ppElementValues)
		return AAFRESULT_NULL_PARAM;
	
	//verify that all the individual elem types are the same as each other,
	
	HRESULT hr;
	
	//get Base TD
	ImplAAFTypeDefSP spTargetTD;
	hr = GetType(&spTargetTD); //gets base elem type
	if (AAFRESULT_FAILED (hr)) return hr;
	if (! spTargetTD->IsRegistered ())
		return AAFRESULT_NOT_REGISTERED;
	
	//Get size
	aafUInt32 targetElemSize = spTargetTD->NativeSize();
	
	for (aafUInt32 i=0; i<numElements; i++)
	{
		//get  source type
		ImplAAFTypeDefSP  spSourceTD;
		hr = ppElementValues[i]->GetType (&spSourceTD);
		if (AAFRESULT_FAILED (hr)) 
			return hr;
		
		//verify that spTargetTD == spSourceTD
		if (spSourceTD != spTargetTD )
			return AAFRESULT_BAD_TYPE;
		
		//verify FIXED/VARIABLE Arrayable
		if (! IsArrayable(spSourceTD) )
			return AAFRESULT_BAD_TYPE;
		
		//verify that the target elem size is equal to that of source 
		aafUInt32 sourceSize = spSourceTD->NativeSize();	
		if (sourceSize != targetElemSize )
			return AAFRESULT_BAD_SIZE;
		
	}//for each elem

	return AAFRESULT_SUCCESS;

}//ValidateInputParams()
Ejemplo n.º 6
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFControlPoint::SetValue (
      aafUInt32  valueSize,
      aafDataBuffer_t  pValue)
{
	if (!pValue)
		return(AAFRESULT_NULL_PARAM);

	if (valueSize > OMPROPERTYSIZE_MAX)
		return(AAFRESULT_BAD_SIZE);
//	_value.setValue(pValue, valueSize);

  if (!_cachedTypeDef)
  {
    // Lookup the type definition from this constrol point. If it fails
    // then the control point is invalid!
    AAFRESULT result = GetTypeDefinition (&_cachedTypeDef);
    if (AAFRESULT_FAILED (result))
      return result;
  }


  // Validate the property and get the property definition and type definition, 
	// and the actual length of the data
	return (ImplAAFTypeDefIndirect::SetActualPropertyValue (_value, _cachedTypeDef, pValue, valueSize));
}
Ejemplo n.º 7
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFRawStorage::Read
        (aafMemPtr_t  buf,
		 aafUInt32  bufSize,
         aafUInt32 *  pNumRead)
{
  if (! _rep)
	return AAFRESULT_NOT_INITIALIZED;

  if (! buf)
	return AAFRESULT_NULL_PARAM;

  if (! pNumRead)
	return AAFRESULT_NULL_PARAM;

  aafBoolean_t readable = kAAFFalse;
  AAFRESULT hr = IsReadable (&readable);
  if (AAFRESULT_FAILED (hr))
	return hr;
  if (! readable)
	return AAFRESULT_NOT_READABLE;

  _rep->read (buf, bufSize, *pNumRead);
  return AAFRESULT_SUCCESS;
}
Ejemplo n.º 8
0
AAFRESULT ImplAAFPropertyDef::pvtInitialize (
      const aafUID_t & propertyAuid,
      OMPropertyId omPid,
      const aafCharacter * pPropName,
	  const aafUID_t & typeId,
      aafBoolean_t isOptional,
      aafBoolean_t isUniqueIdentifier,
      OMClassDefinition* pContainingClass)
{
  AAFRESULT hr;

  if (! pPropName) return AAFRESULT_NULL_PARAM;
  if (! pContainingClass)
    return AAFRESULT_NULL_PARAM;

  hr = ImplAAFMetaDefinition::Initialize(propertyAuid, pPropName, NULL);
	if (AAFRESULT_FAILED (hr))
    return hr;

  _Type = typeId;
  _pid = omPid;
  _IsOptional = isOptional;

  if (isUniqueIdentifier)
  {
    // Only set this optional property if true.
    _IsUniqueIdentifier = isUniqueIdentifier;
  }

  _containingClass = pContainingClass;

  return AAFRESULT_SUCCESS;
}
Ejemplo n.º 9
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFPluginDef::GetLocatorAt (
	  aafUInt32 index,
      ImplAAFLocator ** ppLocator)
{
	if(ppLocator == NULL)
		return(AAFRESULT_NULL_PARAM);

	aafUInt32 count;
	AAFRESULT hr;
	hr = CountLocators (&count);
	if (AAFRESULT_FAILED (hr)) return hr;

	if (index >= count)
	  return AAFRESULT_BADINDEX;

	ImplAAFLocator *pLocator;
	_locators.getValueAt(pLocator,index);

	ASSERTU(pLocator);
	pLocator->AcquireReference();
	(*ppLocator)=pLocator;

	return AAFRESULT_SUCCESS;
}
Ejemplo n.º 10
0
// Insert the given object into this contain property.
AAFRESULT STDMETHODCALLTYPE ImplAAFRefContainerValue::InsertObject(
  ImplAAFStorable* pObject)
{
  AAFRESULT result = AAFRESULT_SUCCESS;
  if (NULL == pObject)
    return AAFRESULT_NULL_PARAM;
		
	result = ValidateNewObject(pObject);
	if (AAFRESULT_FAILED(result))
		return result;

  ASSERTU (isInitialized());
  if (!isInitialized())
    return AAFRESULT_NOT_INITIALIZED;
 
  // Hand off to the OMReferenceContainer
  OMReferenceContainer* pReferenceContainer = referenceContainer();

  // Object refernce containers should only contain a single reference
  // to an object.
  if (!pReferenceContainer->containsObject(pObject))
  {
    pReferenceContainer->insertObject(pObject);
    if (usesReferenceCounting())
    {
      pObject->AcquireReference();
    }
    
  }
    
  return result;
}
Ejemplo n.º 11
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFRawStorage::Write
        (aafMemConstPtr_t  buf,
         aafUInt32  bufSize,
		 aafUInt32 * pNumWritten)
{
  if (! _rep)
	return AAFRESULT_NOT_INITIALIZED;

  if (! buf)
	return AAFRESULT_NULL_PARAM;

  if (! pNumWritten)
	return AAFRESULT_NULL_PARAM;

  aafBoolean_t writeable = kAAFFalse;
  AAFRESULT hr = IsWriteable (&writeable);
  if (AAFRESULT_FAILED (hr))
	return hr;
  if (! writeable)
	return AAFRESULT_NOT_WRITEABLE;

  _rep->write (buf, bufSize, *pNumWritten);

  if (*pNumWritten < bufSize)
	// Note!  This violates one tenet, that if a method fails, no
	// action is taken.  However, this failure notice is given *after*
	// some bytes have been written...
	return AAFRESULT_SMALLBUF;

  return AAFRESULT_SUCCESS;
}
Ejemplo n.º 12
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFSetFileBits::WriteAt (
      aafMemPtr_t  buf,
      aafUInt32  bufSize,
      aafUInt64  position)
{
  if (! _rep)
	return AAFRESULT_NOT_INITIALIZED;

  if ( ! buf)
	return AAFRESULT_NULL_PARAM;

  aafUInt64 s = _rep->extent ();
  if (s < (position + bufSize))
	{
	  AAFRESULT hr;
	  hr = SetSize (position + bufSize);
	  if (AAFRESULT_FAILED (hr))
		return hr;
	}

  aafUInt32 bytesWritten;
  _rep->writeAt (position, buf, bufSize, bytesWritten);
  if (bytesWritten != bufSize)
	return AAFRESULT_INVALID_PARAM;
  return AAFRESULT_SUCCESS;
}
Ejemplo n.º 13
0
//
// private method
//
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefExtEnum::GetElementName (
									   aafUInt32 index,
									   wchar_t * pName,
									   aafUInt32  bufSize)
{
	AAFRESULT hr;
	aafUInt32 count;
	aafUInt32 indexIntoProp;
	aafUInt32 currentIndex;
	
	if (!pName) return AAFRESULT_NULL_PARAM;
	
	hr = CountElements(&count);
	if (AAFRESULT_FAILED(hr)) return hr;
	
	if (index >= count) return AAFRESULT_ILLEGAL_VALUE;
	
	wchar_t c;
	size_t numChars = _ElementNames.count();
	indexIntoProp = 0;
	currentIndex = 0;
	if (0 != index)
	{
		for (OMUInt32 i = 0; i < numChars; i++)
		{
			indexIntoProp++;
			_ElementNames.getValueAt(&c, i);
			if (0 == c)
			{
				// We've found the null just before the string we want.
				// We'll increment the indexIntoProp to the start of the
				// string and break out of the loop, but first make sure
				// there's more string there to index into.
				ASSERTU (i < numChars);
				currentIndex++;
				if (index == currentIndex)
					break;
			}
		}
		// Make sure we didn't terminate the loop by dropping out before
		// the correct index was found.
		ASSERTU (indexIntoProp < numChars);
	}
	
	// indexIntoProp now indicates the starting char we want.  Copy it
	// into the client's buffer.
	do
	{
		if (! bufSize) return AAFRESULT_SMALLBUF;
		_ElementNames.getValueAt(&c, indexIntoProp++);
		// BobT Note!!! We're cheating here, modifying client data
		// before we're sure this method will succeed.
		*pName++ = c;
		bufSize--;
	}
	while (c);
	return AAFRESULT_SUCCESS;
}
Ejemplo n.º 14
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefExtEnum::GetNameFromAUID (
										const aafUID_t & value,
										wchar_t * pName,
										aafUInt32 bufSize)
{
	if (! pName)
		return AAFRESULT_NULL_PARAM;
	
	AAFRESULT hr;
	aafUInt32 len;
	// following call may return AAFRESULT_ILLEGAL_VALUE if value isn't
	// recognized
	hr = GetNameBufLenFromAUID (value, &len);
	if (AAFRESULT_FAILED(hr))
		return hr;
	
	// len includes space for trailing null
	if (bufSize < len)
		return AAFRESULT_SMALLBUF;
	
	aafUInt32 i;
	aafUInt32 count;
	hr = CountElements(&count);
	if (AAFRESULT_FAILED(hr))
		return hr;
	for (i = 0; i < count; i++)
	{
		aafUID_t val;
		hr = GetElementValue (i, &val);
		if (AAFRESULT_FAILED(hr))
			return hr;
		if (EqualAUID (&val, &value))
		{
			// given integer value matches value of "i"th element.
			hr = GetElementName(i, pName, bufSize);
			if (AAFRESULT_FAILED(hr))
				return hr;
			return AAFRESULT_SUCCESS;
		}
	}
	// fell out of for() loop, so we didn't find it.
	// redundant, since GetNameBufLenFromInteger() should have already
	// found it.
	return AAFRESULT_ILLEGAL_VALUE;
}
Ejemplo n.º 15
0
AAFRESULT ImplAAFPropertyDef::pvtInitialize (
      aafUID_constref propertyAuid,
      OMPropertyId omPid,
      aafCharacter_constptr pPropName,
      ImplAAFTypeDef *pType,
      aafBoolean_t isOptional,
      aafBoolean_t isUniqueIdentifier,
      OMClassDefinition* pContainingClass)
{
  AAFRESULT hr;

  if (! pPropName) return AAFRESULT_NULL_PARAM;
  if (! pType)
    return AAFRESULT_NULL_PARAM;
  if (! pContainingClass)
    return AAFRESULT_NULL_PARAM;

  aafUID_t typeId;
  hr = pType->GetAUID(&typeId);
  if (AAFRESULT_FAILED (hr))
    return hr;

  hr = ImplAAFMetaDefinition::Initialize(propertyAuid, pPropName, NULL);
  if (AAFRESULT_FAILED (hr))
    return hr;

  _cachedType = pType;
  _cachedType->AcquireReference();


  _Type = typeId;
  _pid = omPid;
  _IsOptional = isOptional;

  if (isUniqueIdentifier)
  {
    // Only set this optional property if true.
    _IsUniqueIdentifier = isUniqueIdentifier;
  }

  _containingClass = pContainingClass;

  return AAFRESULT_SUCCESS;
}
Ejemplo n.º 16
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefString::GetElements (
    ImplAAFPropertyValue * pInPropVal,
    aafMemPtr_t pBuffer,
    aafUInt32 bufferSize)
{
    AAFRESULT hr;

    if (! pInPropVal) return AAFRESULT_NULL_PARAM;
    if (! pBuffer) 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( pInPropVal->GetType( &pIncomingType ) ) )
        return AAFRESULT_BAD_TYPE;
    ASSERTU (pIncomingType);
    if( (ImplAAFTypeDef *)pIncomingType != this )
        return AAFRESULT_BAD_TYPE;

    ImplAAFPropValDataSP pvd;
    pvd = dynamic_cast<ImplAAFPropValData*>(pInPropVal);
    if (!pvd) return AAFRESULT_BAD_TYPE;

    aafUInt32 propBitsSize;
    hr = pvd->GetBitsSize(&propBitsSize);
    if (AAFRESULT_FAILED(hr)) return hr;
    if (bufferSize < propBitsSize)
        return AAFRESULT_SMALLBUF;

    aafMemPtr_t pBits = NULL;
    hr = pvd->GetBits (&pBits);
    if (AAFRESULT_FAILED(hr)) return hr;
    ASSERTU (pBits);

    ASSERTU (pBuffer);
    ASSERTU (propBitsSize <= bufferSize);
    memcpy (pBuffer, pBits, propBitsSize);

    return AAFRESULT_SUCCESS;
}
Ejemplo n.º 17
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefArray::CreateEmptyValue
(ImplAAFPropertyValue ** ppPropVal)
{
  AAFRESULT result = AAFRESULT_SUCCESS;
  if (NULL == ppPropVal)
    return AAFRESULT_NULL_PARAM;
      
  ImplAAFTypeDefSP pElementType;
  result = GetType(&pElementType);
  if (AAFRESULT_FAILED(result))
    return result;
      
      
  if (dynamic_cast<ImplAAFTypeDefStrongObjRef*>((ImplAAFTypeDef*) pElementType))
  {
    // element is strong ref
    ImplAAFStrongRefArrayValue* pStrongRefArray = NULL;
    pStrongRefArray = (ImplAAFStrongRefArrayValue*) CreateImpl (CLSID_AAFStrongRefArrayValue);
    if (!pStrongRefArray) 
      return AAFRESULT_NOMEMORY;
    result = pStrongRefArray->Initialize(this, kAAFTrue == IsFixedSize());
    if (AAFRESULT_SUCCEEDED(result))
    {
      *ppPropVal = pStrongRefArray;
    }
    else
    {
      pStrongRefArray->ReleaseReference();
    }
  }
  else if (dynamic_cast<ImplAAFTypeDefWeakObjRef*>((ImplAAFTypeDef*) pElementType))
  {
    // element is weak ref
    ImplAAFWeakRefArrayValue* pWeakRefArray = NULL;
    pWeakRefArray = (ImplAAFWeakRefArrayValue*) CreateImpl (CLSID_AAFWeakRefArrayValue);
    if (!pWeakRefArray) 
      return AAFRESULT_NOMEMORY;
    result = pWeakRefArray->Initialize(this, kAAFTrue == IsFixedSize());
    if (AAFRESULT_SUCCEEDED(result))
    {
      *ppPropVal = pWeakRefArray;
    }
    else
    {
      pWeakRefArray->ReleaseReference();
    }
  }
  else
  { 
  	//simply defer to base impl (size is 0)
  	result = CreateValue(ppPropVal);
  }
  
  return result;
}
Ejemplo n.º 18
0
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;
}
Ejemplo n.º 19
0
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));
}
Ejemplo n.º 20
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefExtEnum::SetAUIDValue (
									 ImplAAFPropertyValue * pPropValToSet,
									 const aafUID_t & valueIn)
{
	ImplAAFTypeDef* ptd;
	ImplAAFTypeDefRecord* ptAuid;
	
	if (! pPropValToSet)
		return AAFRESULT_NULL_PARAM;
	
	// Get the property value's embedded type and 
	// check if it's the same as the local type.
	ImplAAFTypeDefSP	spPropType;
	if( AAFRESULT_FAILED( pPropValToSet->GetType( &spPropType ) ) )
		return AAFRESULT_BAD_TYPE;
	ASSERTU (spPropType);
	if( (ImplAAFTypeDef *)spPropType != this )
		return AAFRESULT_BAD_TYPE;


	AAFRESULT hr;
	
	// Call this method to find out if this is a legal value
	aafUInt32 tmp; // unused
	hr = GetNameBufLenFromAUID (valueIn, &tmp);
	if (AAFRESULT_FAILED (hr))
		return hr;
	
	ptd = NonRefCountedBaseType ();
	ASSERTU (ptd);
	
	ptAuid = dynamic_cast<ImplAAFTypeDefRecord*> ((ImplAAFTypeDef*) ptd);
	ASSERTU (ptAuid);
	
	hr = ptAuid->SetStruct (pPropValToSet, (aafMemPtr_t) &valueIn, sizeof (aafUID_t));
	if (AAFRESULT_FAILED(hr))
		return hr;
	
	return AAFRESULT_SUCCESS;
}
Ejemplo n.º 21
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;  
}
Ejemplo n.º 22
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFPropertyDef::GetTypeDef (
      ImplAAFTypeDef ** ppTypeDef) const
{
  if (! ppTypeDef) return AAFRESULT_NULL_PARAM;

  if (! _cachedType)
	{
	  ImplAAFDictionarySP pDict;
	  AAFRESULT hr;

	  hr = GetDictionary(&pDict);
	  if (AAFRESULT_FAILED (hr)) return hr;
	  ASSERTU (pDict);

	  ImplAAFPropertyDef * pNonConstThis =
		  (ImplAAFPropertyDef *) this;
	  aafUID_t typeId = _Type;

	  ImplAAFTypeDef * tmp = 0;
	  hr = pDict->LookupTypeDef (typeId, &tmp);
	  if (AAFRESULT_FAILED (hr))
		return hr;
	  ASSERTU (tmp);
	  if (!_cachedType) {
		pNonConstThis->_cachedType = tmp;
		_cachedType->AcquireReference();
	  }
	  // If lookup caused this to already be put into the cache, just
	  // throw away the current copy (in tmp)
	  tmp->ReleaseReference ();
	  tmp = 0;
	}
  ASSERTU (ppTypeDef);
  *ppTypeDef = _cachedType;
  ASSERTU (*ppTypeDef);
  (*ppTypeDef)->AcquireReference ();

  return AAFRESULT_SUCCESS;
}
Ejemplo n.º 23
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefExtEnum::GetAUIDValue (
									 ImplAAFPropertyValue * pPropValIn,
									 aafUID_t * pValueOut)
{
	ImplAAFTypeDef* ptd;
	ImplAAFTypeDefRecord* ptAuid;
	
	if (! pPropValIn)
		return AAFRESULT_NULL_PARAM;
	if (! pValueOut)
		return AAFRESULT_NULL_PARAM;
	
	// Get the property value's embedded type and 
	// check if it's the same as the local type.
	ImplAAFTypeDefSP	spPropType;
	if( AAFRESULT_FAILED( pPropValIn->GetType( &spPropType ) ) )
		return AAFRESULT_BAD_TYPE;
	ASSERTU (spPropType);
	if( (ImplAAFTypeDef *)spPropType != this )
		return AAFRESULT_BAD_TYPE;

	AAFRESULT hr;
	aafUID_t retval;
	
	ptd = NonRefCountedBaseType ();
	ASSERTU (ptd);
	
	ptAuid = dynamic_cast<ImplAAFTypeDefRecord*> ((ImplAAFTypeDef*) ptd);
	ASSERTU (ptAuid);
	
	hr = ptAuid->GetStruct (pPropValIn, (aafMemPtr_t) &retval, sizeof (retval));
	if (AAFRESULT_FAILED(hr))
		return hr;
	
	ASSERTU (pValueOut);
	*pValueOut = retval;
	
	return AAFRESULT_SUCCESS;
}
Ejemplo n.º 24
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefString::GetCount (
    ImplAAFPropertyValue * pPropVal,
    aafUInt32 *  pCount)
{
    ImplAAFTypeDefSP pIncomingType;
    ImplAAFTypeDefSP ptd;
    AAFRESULT hr;

    if (! pPropVal) return AAFRESULT_NULL_PARAM;
    if (! pCount) return AAFRESULT_NULL_PARAM;

    // Get the property value's embedded type and
    // check if it's the same as the base type.
    if( AAFRESULT_FAILED( pPropVal->GetType( &pIncomingType ) ) )
        return AAFRESULT_BAD_TYPE;
    ASSERTU (pIncomingType);
    if( (ImplAAFTypeDef *)pIncomingType != this )
        return AAFRESULT_BAD_TYPE;

    hr = GetType (&ptd);
    if (AAFRESULT_FAILED(hr)) return hr;
    ASSERTU (ptd);
    ASSERTU (ptd->IsFixedSize());
    aafUInt32 elemSize = ptd->ActualSize();
    aafUInt32 propSize;
    ASSERTU (pPropVal);

    ImplAAFPropValDataSP pvd;
    pvd = dynamic_cast<ImplAAFPropValData *>(pPropVal);

    ASSERTU (pvd);
    hr = pvd->GetBitsSize (&propSize);
    if (AAFRESULT_FAILED(hr)) return hr;
    ASSERTU (pCount);
    *pCount = propSize / elemSize;

    return AAFRESULT_SUCCESS;
}
Ejemplo n.º 25
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFTypeDef::pvtGetUInt8Array8Type (
      ImplAAFTypeDef ** ppRawTypeDef)
{
  if (! ppRawTypeDef)
	return AAFRESULT_NULL_PARAM;
  
  ImplAAFDictionarySP pDict;
  AAFRESULT hr = GetDictionary(&pDict);
  if (AAFRESULT_FAILED (hr)) return hr;
  
  return pDict->LookupTypeDef (kAAFTypeID_UInt8Array, ppRawTypeDef);
}
Ejemplo n.º 26
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFOperationDef::RemoveDegradeToOperationAt (
	  aafUInt32 index)
{
	aafUInt32 count;
	AAFRESULT hr;
	hr = CountDegradeToOperations (&count);
	if (AAFRESULT_FAILED (hr)) return hr;
	if (index >= count)
		return AAFRESULT_BADINDEX;
	
	_degradeTo.removeAt(index);
	return AAFRESULT_SUCCESS;
}
Ejemplo n.º 27
0
// Remove the given object from the container property.
AAFRESULT STDMETHODCALLTYPE ImplAAFRefContainerValue::RemoveElement(
  ImplAAFPropertyValue* pPropertyValue)
{
  AAFRESULT result = AAFRESULT_SUCCESS;
  if (NULL == pPropertyValue)
    return AAFRESULT_NULL_PARAM;
    
  ImplAAFStorable * pObject = GetStorableFromPropertyValue(pPropertyValue, result);
  if (AAFRESULT_FAILED(result))
    return result;
  
  result = RemoveObject(pObject); 
  return result;
}
Ejemplo n.º 28
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefArray::CreateValue(ImplAAFPropertyValue ** ppPropVal, 
								 aafUInt32 dataSize)
{
	if (! ppPropVal)
		return AAFRESULT_NULL_PARAM;
	
	ImplAAFPropValDataSP pvd;
	ImplAAFPropValData * tmp;
	tmp = (ImplAAFPropValData*) CreateImpl (CLSID_AAFPropValData);
	if (!tmp) return AAFRESULT_NOMEMORY;
	pvd = tmp;
	// the pvd smart pointer will maintain a reference for us...
	tmp->ReleaseReference ();
	
	//Initialize pvd to this type
	HRESULT hr = pvd->Initialize(this);
	if (AAFRESULT_FAILED(hr)) return hr;
	
	//deal with dataSize - Allocate bits if this param is non-zero
	if (dataSize)
	{
		//Allocate the necesary bits
		aafMemPtr_t pTargetData = 0;
		hr = pvd->AllocateBits(dataSize, &pTargetData);
		if (AAFRESULT_FAILED (hr))
			return hr;
	}//if dataSize
	else
		//we're effectively creating an "Empty" value
		;
	
	*ppPropVal = pvd;
	ASSERTU (*ppPropVal);
	(*ppPropVal)->AcquireReference ();
	return AAFRESULT_SUCCESS;
}//CreateValue()
Ejemplo n.º 29
0
// Insert pObject into the OMObjectVector at position index. 
// Existing objects at index> and higher are shifted up one index position.
AAFRESULT STDMETHODCALLTYPE ImplAAFRefArrayValue::InsertElementAt(
  ImplAAFPropertyValue* pPropertyValue,
  aafUInt32 index)
{
  AAFRESULT result = AAFRESULT_SUCCESS;
  if (NULL == pPropertyValue)
    return AAFRESULT_NULL_PARAM;
    
  ImplAAFStorable * pObject = GetStorableFromPropertyValue(pPropertyValue, result);
  if (AAFRESULT_FAILED(result))
    return result;
  
  result = InsertObjectAt(pObject, index); 
  return result;
}
Ejemplo n.º 30
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefExtEnum::Initialize (
								   const aafUID_t & id,
								   const aafCharacter * pTypeName)
{
	if (!pTypeName)
		return AAFRESULT_NULL_PARAM;
	
	AAFRESULT hr;
	
	hr = ImplAAFMetaDefinition::Initialize(id, pTypeName, NULL);
	if (AAFRESULT_FAILED (hr))
		return hr;
	
	return AAFRESULT_SUCCESS;
}