// Retrieve the property as an OMReferenceContainer. OMReferenceContainer* ImplAAFRefContainerValue::referenceContainer(void) const { ASSERTU (isInitialized()); OMProperty* p = property(); OMContainerProperty* cp = dynamic_cast<OMContainerProperty*>(p); ASSERTU(cp != 0); OMReferenceContainer* result = cp->referenceContainer(); ASSERTU(result != 0); return result; }
// // WriteTo // AAFRESULT STDMETHODCALLTYPE ImplAAFRefArrayValue::WriteTo( OMProperty* pOmProp) { AAFRESULT result = AAFRESULT_SUCCESS; OMObject* object; ImplAAFStorable* obj; if (NULL == property()) { // First empty the current property. OMContainerProperty * pNewContainerProperty = dynamic_cast<OMContainerProperty *>(pOmProp); if (NULL == pNewContainerProperty) return AAFRESULT_INVALID_OBJ; OMReferenceContainer *pNewReferenceContainer = pNewContainerProperty->referenceContainer(); if (NULL == pNewReferenceContainer) return AAFRESULT_INVALID_OBJ; if (usesReferenceCounting()) { result = ReleaseAllObjects(pNewReferenceContainer); if (AAFRESULT_FAILED(result)) return result; } // Make sure that there are no elements in the new property container. pNewReferenceContainer->removeAllObjects(); // Install the new "empty" container property. SetProperty(pOmProp); OMReferenceContainerIterator* tempIterator = _tempStorableVector->createIterator(); if (NULL == tempIterator) { result = AAFRESULT_NOMEMORY; } else { while (AAFRESULT_SUCCEEDED(result) && (tempIterator->before() || tempIterator->valid())) { if (++(*tempIterator)) { object = tempIterator->currentObject(); obj = dynamic_cast<ImplAAFStorable*>(object); ASSERTU(NULL != obj); if (NULL == obj) { result = AAFRESULT_INVALID_OBJ; } else { // if (usesReferenceCounting()) // { // obj->detach(); // } // Add the element from the temporary property container to the property. result = InsertObject(obj); // reference counts if necessary... if (AAFRESULT_SUCCEEDED(result)) { if (usesReferenceCounting()) { obj->ReleaseReference(); } } } } } delete tempIterator; tempIterator = NULL; } // Cleanup the temporary property now the the the pOmProp has been created and initialized. delete _tempStorableVector; _tempStorableVector = NULL; if (AAFRESULT_FAILED(result)) return result; } return (ImplAAFRefContainerValue::WriteTo(pOmProp)); }