/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #include "OdaCommon.h" #include "DbAssocManager.h" #include "DbAssocEvaluationMultiCallback.h" #define STL_USING_MEMORY #include "OdaSTL.h" std::unique_ptr g_multiCallback; // DNA: TODO: do diverse global pointer across thread contexts (use TLS) OdResult OdDbAssocManager::addGlobalEvaluationCallback(OdDbAssocEvaluationCallback* pCallback, int order) { if(!pCallback) return eInvalidInput; g_multiCallback->callbacks.insert(std::pair(order, pCallback)); return eOk; } OdResult OdDbAssocManager::removeGlobalEvaluationCallback(OdDbAssocEvaluationCallback* pCallback) { if(!pCallback) return eInvalidInput; for(OdDbAssocEvaluationMultiCallback::CallbackPtrMap::const_iterator it = g_multiCallback->callbacks.begin(), end = g_multiCallback->callbacks.end(); it!=end; ++it) { if(it->second==pCallback) { g_multiCallback->callbacks.erase(it); return eOk; } } return eKeyNotFound; } void OdDbAssocManager::getGlobalEvaluationCallbacks(OdDbAssocEvaluationCallbackPtrArray& callbacks, OdIntArray& orders) { orders.clear(); callbacks.clear(); for(OdDbAssocEvaluationMultiCallback::CallbackPtrMap::const_iterator it = g_multiCallback->callbacks.begin(), end = g_multiCallback->callbacks.end(); it!=end; ++it) { orders.append(it->first); callbacks.append(it->second); } } OdDbAssocEvaluationCallback * OdDbAssocManager::globalEvaluationMultiCallback() { return &*g_multiCallback; } bool OdDbAssocEvaluationMultiCallback::cancelActionEvaluation() { CallbackPtrMap::iterator it = callbacks.begin(),end = callbacks.end(); for(; it != end; ++it) { if(it->second->cancelActionEvaluation()) return true; } return false; } OdDbEvalContext* OdDbAssocEvaluationMultiCallback::getAdditionalData() const { CallbackPtrMap::const_iterator it = callbacks.begin(), end = callbacks.end(); for(; it != end; ++it) { OdDbEvalContext* addat = it->second->getAdditionalData(); if(addat) return addat; } return 0; } OdDbAssocTransformationType OdDbAssocEvaluationMultiCallback::getTransformationType() const { CallbackPtrMap::const_iterator it = callbacks.begin(),end = callbacks.end(); for(; it != end; ++it) { OdDbAssocTransformationType tt = it->second->getTransformationType(); if(tt != kNotSpecified) return tt; } return kNotSpecified; } void OdDbAssocEvaluationMultiCallback::allDependentActionsMarkedToEvaluate(OdDbAssocNetwork* pNetwork) { CallbackPtrMap::const_iterator it = callbacks.begin(), end = callbacks.end(); for(; it != end; ++it) { it->second->allDependentActionsMarkedToEvaluate(pNetwork); } } void OdDbAssocEvaluationMultiCallback::beginActionEvaluation(OdDbAssocAction* pAction) { CallbackPtrMap::const_iterator it = callbacks.begin(), end = callbacks.end(); for(; it != end; ++it) { it->second->beginActionEvaluation(pAction); } } void OdDbAssocEvaluationMultiCallback::endActionEvaluation(OdDbAssocAction* pAction) { CallbackPtrMap::const_iterator it = callbacks.begin(), end = callbacks.end(); for(; it != end; ++it) { it->second->endActionEvaluation(pAction); } } void OdDbAssocEvaluationMultiCallback::setActionEvaluationErrorStatus(OdDbAssocAction* pAction, OdResult errorStatus, const OdDbObjectId& objectId /*= OdDbObjectId::kNull*/, OdDbObject* pObject /*= NULL*/,void* pErrorInfo /*= NULL*/) { CallbackPtrMap::const_iterator it = callbacks.begin(), end = callbacks.end(); for(; it != end; ++it) { it->second->setActionEvaluationErrorStatus(pAction, errorStatus, objectId, pObject, pErrorInfo); } } OdDbAssocDraggingState OdDbAssocEvaluationMultiCallback::draggingState() const { CallbackPtrMap::const_iterator it = callbacks.begin(), end = callbacks.end(); for (; it != end; ++it) { const OdDbAssocDraggingState state = it->second->draggingState(); if (state != kNotDraggingAssocDraggingState) { return state; } } return kNotDraggingAssocDraggingState; }