// // WriteTo // AAFRESULT STDMETHODCALLTYPE ImplAAFWeakRefValue::WriteTo( OMProperty* pOmProp) { ASSERTU (isInitialized()); if (!isInitialized()) return AAFRESULT_NOT_INITIALIZED; AAFRESULT result = ImplAAFRefValue::WriteTo(pOmProp); if (AAFRESULT_SUCCEEDED(result)) { // If there is a referenceProperty then the SetObject method has already // written the object reference to the property. if (NULL == referenceProperty()) { OMReferenceProperty* refProperty = dynamic_cast<OMReferenceProperty *>(pOmProp); ASSERTU(refProperty); if (NULL == refProperty) return AAFRESULT_INVALID_OBJ; // ??? // Use an "indirect access" method of saving a strong object reference. // The local object reference must exist! NOTE: GetLocalObject() does NOT increment // the reference count of the returned object! result = SetNewObjectReference(refProperty, GetLocalObject()); if (AAFRESULT_SUCCEEDED(result)) { // Install the property direct access and cleanup the local reference. SetProperty(pOmProp); SetLocalObject(NULL); } } } return result; }
AAFRESULT STDMETHODCALLTYPE ImplAAFWeakRefValue::GetObject(ImplAAFStorable **ppObject) const { AAFRESULT result = AAFRESULT_SUCCESS; ImplAAFStorable *pObject = NULL; if (NULL == ppObject) return AAFRESULT_NULL_PARAM; *ppObject = NULL; ASSERTU (isInitialized()); if (!isInitialized()) return AAFRESULT_NOT_INITIALIZED; OMReferenceProperty* pProperty = referenceProperty(); if (NULL != pProperty) { if (! pProperty->isOptional() || pProperty->isPresent ()) { OMObject *object = pProperty->getObject(); if (NULL == object) return AAFRESULT_NULLOBJECT; pObject = ConvertOMObjectToRoot(object); ASSERTU (NULL != pObject); if (NULL == pObject) return AAFRESULT_INVALID_OBJ; // ??? } else { return AAFRESULT_PROP_NOT_PRESENT; } } else { // Use an "indirect access" method of retrieving a strong object reference. // // If there was not associated reference property then there MUST // be a local object pointer assigned to this instance. pObject = GetLocalObject(); ASSERTU (NULL != pObject); } *ppObject = pObject; (*ppObject)->AcquireReference(); return result; }
object array_get_object(object store, string name, int i) { return GetLocalObject(store,name+"_"+IntToString(i)+"_OBJECT"); }