/////////////////////////////////////////////////////////////////////////////// // 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. /////////////////////////////////////////////////////////////////////////////// #ifndef DbNamedAssocActionIndex_INCLUDED_ #define DbNamedAssocActionIndex_INCLUDED_ /*!DOM*/ #include "DbObject.h" #define STL_USING_SET #include "OdaSTL.h" #include "OdHashSet.h" #include "OdString_Hasher.h" #include "TD_PackPush.h" /** \details This class represents the protocol extension interface of named objects. Library: Source code provided. */ class OdDbNamedObjectPE : public OdRxObject { public: ODRX_DECLARE_MEMBERS(OdDbNamedObjectPE); virtual OdResult getObjectName(const OdDbObject* object, OdString& name) const = 0; virtual OdResult setObjectName(OdDbObject* object, const OdString& name) = 0; virtual const OdRxClass* indexingObjectClass() const = 0; }; typedef OdSmartPtr OdDbNamedObjectPEPtr; class OdDbNamedObjectIndex; /** \details This class represents the interface of named associative actions index node. Library: Source code provided. */ class OdDbNamedObjectIndexNode : public OdDbObjectReactor { friend class OdDbNamedObjectIndex; OdDbNamedObjectIndex* m_index; OdDbNamedObjectIndexNode* m_prev; OdDbNamedObjectIndexNode* m_next; OdString m_name; OdDbObjectId m_id; enum { kDirty = 1, kOpenedForModify = 2, kModified = 8, }; OdUInt32 m_flags; bool update(); bool update(const OdDbObject* object); void initInIndex(const OdDbObject* object, OdDbNamedObjectIndex* index); public: ODRX_DECLARE_MEMBERS(OdDbNamedObjectIndexNode); OdDbNamedObjectIndexNode(); static OdDbNamedObjectIndexNode* fromObject(const OdDbObject* object, OdDbNamedObjectIndex* createInIndex = 0); virtual void openedForModify(const OdDbObject* object) ODRX_OVERRIDE; virtual void modified(const OdDbObject* object) ODRX_OVERRIDE; virtual void erased(const OdDbObject* pObject, bool erasing = true) ODRX_OVERRIDE; virtual void goodbye(const OdDbObject* object) ODRX_OVERRIDE; void removeFromIndex(); bool isDirty() const { return GETBIT(m_flags, kDirty); } bool isOpenedForModify() const { return GETBIT(m_flags, kOpenedForModify); } bool isModified() const { return GETBIT(m_flags, kModified); } }; /** \details This class represents the interface of named associative actions index. Library: Source code provided. */ class OdDbNamedObjectIndex : public OdDbObjectReactor { friend class OdDbNamedObjectIndexNode; friend void DbAssocVariableTests(class OdDbHostAppServices* pHostApp, int curRun); struct Hash : OdString_Hasher<> { size_t operator ()(const OdDbNamedObjectIndexNode* node) const { return OdString_Hasher::operator ()(node->m_name); } }; struct NodeWrap { OdDbNamedObjectIndexNode* ptr; NodeWrap(OdDbNamedObjectIndexNode* p) : ptr(p) {} NodeWrap() : ptr(0) {} const bool operator == (const NodeWrap& r) const { return ptr->m_name == r.ptr->m_name; } const bool operator != (const NodeWrap& r) const { return ptr->m_name != r.ptr->m_name; } operator const OdDbNamedObjectIndexNode* () const { return ptr; } operator OdDbNamedObjectIndexNode* () { return ptr; } OdDbNamedObjectIndexNode* operator ->() { return ptr; } const OdDbNamedObjectIndexNode* operator ->() const { return ptr; } }; typedef OdHashSet NodesByName; NodesByName nodesByName; OdDbObjectId indexHolderId; const OdRxClass* classIndexed; OdUInt32 numUpToDate; OdDbNamedObjectIndexNode* upToDateNodes; OdUInt32 numDirty; OdDbNamedObjectIndexNode* dirtyNodes; bool bNeedRegen; void addToList(OdDbNamedObjectIndexNode* node); void removeFromList(OdDbNamedObjectIndexNode* node); protected: OdDbNamedObjectIndex(); public: ODRX_DECLARE_MEMBERS(OdDbNamedObjectIndex); static OdDbNamedObjectIndex* fromObject(const OdDbObject* indexHolder, const OdRxClass* classToBeIndexed, bool create = false); OdDbObjectId objectByName(const OdString& name); void setNeedRegen() { bNeedRegen = true; } protected: bool needRegen() const { return bNeedRegen; } void reset(); void update(); virtual void goodbye(const OdDbObject* object) ODRX_OVERRIDE; }; #include "TD_PackPop.h" #endif //#ifndef DbNamedAssocActionIndex_INCLUDED_