Esempio n. 1
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;
}
Esempio n. 2
0
AAFRESULT STDMETHODCALLTYPE
ImplAAFTypeDefString::CreateValueFromCString (
    aafMemPtr_t  pInitData,
    aafUInt32  initDataSize,
    ImplAAFPropertyValue ** ppPropVal)
{
    if (! pInitData)
        return AAFRESULT_NULL_PARAM;

    if (! ppPropVal)
        return AAFRESULT_NULL_PARAM;

    if (! IsRegistered ())
        return AAFRESULT_NOT_REGISTERED;

    if (initDataSize > OMPROPERTYSIZE_MAX)
        return AAFRESULT_BAD_SIZE;

    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 = SetCString (pvd, pInitData, initDataSize);
    if (AAFRESULT_FAILED (hr))
        return hr;

    ASSERTU (ppPropVal);
    *ppPropVal = pvd;
    ASSERTU (*ppPropVal);
    (*ppPropVal)->AcquireReference ();
    return AAFRESULT_SUCCESS;
}
Esempio n. 3
0
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;
}
Esempio n. 4
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()
Esempio n. 5
0
// Allocate and initialize the correct subclass of ImplAAFPropertyValue 
// for the given OMProperty.
AAFRESULT STDMETHODCALLTYPE
  ImplAAFTypeDef::CreatePropertyValue(
    OMProperty *property,
    ImplAAFPropertyValue ** ppPropertyValue ) const
{
  AAFRESULT result = AAFRESULT_SUCCESS;
  ASSERTU (property && ppPropertyValue);
  if (NULL == property || NULL == ppPropertyValue)
    return AAFRESULT_NULL_PARAM;
  *ppPropertyValue = NULL; // initialize out parameter
  ASSERTU (property->definition());
  if (NULL == property->definition())
    return AAFRESULT_INVALID_PARAM;
  const OMType *type = property->definition()->type();
  ASSERTU (type);
  ImplAAFTypeDef *ptd = const_cast<ImplAAFTypeDef *>
                          (dynamic_cast<const ImplAAFTypeDef *>(type));
  ASSERTU (ptd);
  if (NULL == ptd)
    return AAFRESULT_INVALID_PARAM;
 
  ImplAAFPropValData *pvd = NULL;
  pvd = (ImplAAFPropValData*) CreateImpl (CLSID_AAFPropValData);
  if (!pvd) 
    return AAFRESULT_NOMEMORY;

  result = pvd->Initialize (ptd);
  if (AAFRESULT_SUCCEEDED(result))
  {
    // set the storage in the prop value
    OMUInt32 bitsSize;
    ASSERTU (property);
    bitsSize = property->bitsSize ();
    aafMemPtr_t pBits = NULL;
    // Bobt hack! This should be removed once we have proper
    // integration with OM property def support.
    if (! property->isOptional() || property->isPresent ())
    {
      result = pvd->AllocateBits (bitsSize, &pBits);
      if (AAFRESULT_SUCCEEDED (result))
      {
	if (bitsSize)
        {
          ASSERTU (pBits);
          property->getBits (pBits, bitsSize);
        }
      }
    }
  }

  if (AAFRESULT_SUCCEEDED(result))
  {
    *ppPropertyValue = pvd; // ref count is already 1.
    pvd = NULL;
  }
  else
  {
    pvd->ReleaseReference(); // delete the new object.
  }

  return (result) ;
}