/////////////////////////////////////////////////////////////////////////////// // 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 ODDGLONGTRANSWORKSETITERATOR_INCLUDED #define ODDGLONGTRANSWORKSETITERATOR_INCLUDED #include "DgElement.h" /** \details This class implements Iterator elements that traverse OdDgLongTransaction worksets. */ class ODRX_ABSTRACT TG_EXPORT OdDgLongTransWorkSetIterator : public OdRxObject { public: ODDG_DECLARE_MEMBERS(OdDgLongTransWorkSetIterator); /** \details Sets this Iterator object to reference the element that it would normally return first. \param incRemovedObjs [in] True to include removed elements. \param incSecondaryObjs [in] True to include secondary elements. \remarks Allows multiple traversals of the iterator list. */ virtual void start( bool incRemovedObjs = false, bool incSecondaryObjs = false) = 0; /** \details Returns true if and only if the traversal by this Iterator object is complete. */ virtual bool done() = 0; /** \details Sets this Iterator object to reference the entity following the current entity. */ virtual void step() = 0; /** \details Returns the element ID of the entity currently referenced by this Iterator object. */ virtual OdDgElementId elementId() const = 0; /** \details Returns true if and only if the entity currently referenced by this Iterator object has been erased. \remarks The default iterators return only non-erased objects. */ virtual bool curElementIsErased() const = 0; /** \details Returns true if and only if the entity currently referenced by this Iterator object has been removed from the work set. \remarks The default iterators return only non-removed objects. */ virtual bool curElementIsRemoved() const = 0; /** \details Returns true if and only if the entity currently referenced by this Iterator object is a Primary object. \remarks Primary objects are in the work set because they have been explicitly added to it. Non-Primary objects are in the work set only because they are referenced by Primary objects. \remarks The default iterators return only Primary objects. */ virtual bool curElementIsPrimary() const = 0; }; /** \details This template class is a specialization of the OdSmartPtr class for OdDgLongTransWorkSetIterator object pointers. */ typedef OdSmartPtr OdDgLongTransWorkSetIteratorPtr; /** \details This class implements the tracking of long transactions. \remarks This class creates and appends OdcDgLongTransaction objects to the database and and returns the element ID of the OdDgLongTransaction object. Destruction of the OdDgLongTransaction object is handled by the database. */ class TG_EXPORT OdDgLongTransaction : public OdDgElement { public: ODDG_DECLARE_MEMBERS_INTERNAL(OdDgLongTransaction); enum { kSameDb = 0, // Entities are checked out from a normal block in the current *database*. kXrefDb = 1, // Entities are checked out from ModelSpace or an Xref dependent block in an Xref *database*. kUnrelatedDb = 2 // Entities are checked out from ModelSpace or a block in an unrelated *database*. }; /** \details Returns the type of the pending long transaction: \remarks type will return one of the following Name Value Description kSameDb 0 Entities are checked out from a normal block or layout in the current database. kXrefDb 1 Entities are checked out from ModelSpace or an Xref dependent block in an Xref database. kUnrelatedDb 2 Entities are checked out from ModelSpace or a block in an unrelated database.
*/ int type() const; /** \details Returns the element ID of the block from which the entities are cloned. */ OdDgElementId originBlock() const; /** \details Returns the element ID of the model to which the entities are cloned. */ OdDgElementId destinationModel() const; /** \details Returns the long transaction name. \returns Returns the name of the origin block or layout. */ OdString getLongTransactionName() const; /** \details Returns the element ID path to reference attachment or shared cell reference. */ OdDgElementIdArray getBlockReferenceIdPath() const; /** \details Adds the specified object to the current work set. \param elementId [in] Object ID to be added. \returns Returns eOk if successful, or an appropriate error code if not. elementId must be in the same database as the the transaction. elementId can specify objects from either the origin block or destination block. Elements from the destination block will be cloned; elements from the origin block will not. */ OdResult addToWorkSet(OdDgElementId elementId); /** \details Adds the specified object to the fade exclusion set. \param elementId [in] Element ID to be not faded. \returns Returns eOk if successful, or an appropriate error code if not. elementId must be in the same database as the the transaction. */ OdResult fadeExclusion(OdDgElementId elementId); /** \details Removes the specified object from the current work set. \param objectId [in] Element ID to be removed. \returns Returns eOk if successful, or an appropriate error code if not. */ OdResult removeFromWorkSet(OdDgElementId id); /** \details Synchronizes work set. \remarks removeFromWorkSet() does not remove from the work set elements referenced by removed elements. syncWorkSet() removes them. */ OdResult syncWorkSet(); /** \details Creates an Iterator object that provides access to the entities in the work set. \param incRemovedObjs [in] True to include removed and erased elements from the work set. \param incSecondaryObj [in] True to include objects referenced by elements in the work set. */ OdDgLongTransWorkSetIteratorPtr newWorkSetIterator( bool incRemovedObjs = false, bool incSecondaryObjs = false) const; /** \details Returns the object ID from which the workSetId was cloned. \param workSetId [in] Work set element ID.. */ OdDgElementId originObject( OdDgElementId workSetId) const; /** \details Returns true if and only if the specified element ID is in the work set. \param elementId [in] Element ID being tested. \param getErased [in] True to return true for erased and removed elements in the work set. */ bool workSetHas(OdDgElementId elementId, bool getErased = false) const; /** \details Checks whether an object with the specified ID needs to fade. \param elementId [in] Element ID to check. \returns true if and only if the specified element ID needs to fade. */ bool needsFading(OdDgElementId elementId) const; /** \details Returns a pointer to the OdDgMapping object used for OdLongTransationReactor callbacks used for checkin/checkout. */ OdDgIdMapping* activeIdMap(); void applyPartialUndo(OdDgFiler* pUndoFiler, OdRxClass* pClassObj); virtual OdResult dgnInFields(OdDgFiler* pFiler); virtual void dgnOutFields(OdDgFiler* pFiler) const; virtual OdResult subErase(bool erasing); }; typedef OdSmartPtr OdDgLongTransactionPtr; #endif // ODDGLONGTRANSWORKSETITERATOR_INCLUDED