/////////////////////////////////////////////////////////////////////////////// // 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 _PRCOBJECTID_ #define _PRCOBJECTID_ #include "DbHandle.h" #include "SmartPtr.h" #include "PrcToolkitExportDef.h" #include "Gi/GiCommonDraw.h" class OdDbStub; class OdPrcStub; class OdPrcBase; /** \details A data type that represents a smart pointer to a . */ typedef OdSmartPtr OdPrcObjectPtr; /** \details Open mode enumerator. Determines the results of the open operation for a PRC object. */ enum OpenMode { /** The object is not open.*/ kNotOpen = -1, /** The object is open for reading.*/ kForRead = 0, /** The object is open for reading and/or writing.*/ kForWrite = 1, /** The object is open for notifications.*/ kForNotify = 2 }; /** \details The class implements PRC object identifier (ID) functionality. */ class PRC_TOOLKIT OdPrcObjectId { public: /** \details Creates a PRC object identifier with a null value. */ OdPrcObjectId() : m_Id (0) { } /** \details Creates a based on a specified stub. \param objectId [in] A raw pointer to the stub object. */ OdPrcObjectId (OdDbStub* objectId) : m_Id (objectId) { } //PRC_TOOLKIT static const OdPrcObjectId kNull; /** \details Checks whether the PRC object identifier is empty (NULL). \return A Boolean value that is equal to true if the is empty (NULL); otherwise, the method returns false. */ bool isNull() const { return m_Id == 0; } /** \details Sets the to the NULL value. */ void setNull() { m_Id = 0; } /** \details Checks whether the PRC object identifier has a valid value. \return A Boolean value that is equal to true if the is valid; otherwise, the method returns false. */ bool isValid() const; /** \details Checks whether the PRC object the identifier refers to is erased. \returns A Boolean value that is equal to true if the referred to is erased; otherwise, the method returns false. */ bool isErased() const; /** \details An assignment operator for . Assigns the value of a specified to this . \param elementId [in] Another to assign (the right-hand operand of the assignment operation). \returns A reference to the modified by the assignment operation. */ OdPrcObjectId& operator = (const OdPrcObjectId& elementId) { m_Id = elementId.m_Id; return *this; } /** \details An assignment operator for . Assigns the value from a specified stub object to this . \param objectId [in] A raw pointer to the stub object that contains the identifier value. \returns A reference to the modified by the assignment operation. */ OdPrcObjectId& operator = (OdDbStub* objectId) { m_Id = objectId; return *this; } /** \details An assignment operator for . Compares this with a value of another . \param elementId [in] Another to compare with (the right-hand operand of the comparison operation). \returns A Boolean value that is equal to true if the value of this is equal to another ; otherwise, the operator returns false. */ bool operator == (const OdPrcObjectId& elementId) const; /** \details A "more than" operator for . \param elementId [in] Another to compare with (the right-hand operand of the comparison operation). \returns A Boolean value that is equal to true if the value of this is more than another ; otherwise, the operator returns false. */ bool operator > (const OdPrcObjectId& elementId) const; /** \details A "less than" operator for . \param elementId [in] Another to compare with (the right-hand operand of the comparison operation). \returns A Boolean value that is equal to true if the value of this is less than another ; otherwise, the operator returns false. */ bool operator < (const OdPrcObjectId& elementId) const; /** \details Checks whether the is NULL. \return A Boolean value that is equal to true if the is empty (NULL); otherwise, the operator returns false. */ bool operator !() const { return isNull(); } //DOM-IGNORE-BEGIN /**\details Requests the stub object associated with the . \returns A raw pointer to the stub object associated with the . \remarks This method is for PRC SDK internal use only. Please do NOT use it in your applications. */ inline operator OdDbStub*() const { return (OdDbStub*) m_Id; } //DOM-IGNORE-END /** \details Requests the database that contains the PRC entity the refers to. \returns A raw pointer to the database that contains the PRC entity the refers to. The database is represented by an object of the OdDbBaseDatabase or any derived class. \remarks The method returns a NULL value if the is not associated with a database. The OdDbBaseDatabase is a type definition wrapper for the OdRxObject class. \sa * OdDbBaseDatabase type definition documentation. * OdRxObject Class documentation. * Overview of Classes that Implement RTTI in Kernel SDK documentation. */ OdDbBaseDatabase* database() const; /**!DOM \details Returns the original database with which the PRC object identifier is associated. If the object associated with the identifier has been redirected to a host database from an externally referenced database, the method returns a pointer to the externally referenced database. Otherwise, it returns a pointer to the database with which identifier is associated. */ //OdBmDatabase* originalDatabase () const; /**!DOM \details If the identifier has been redirected from another database (for an example, an external reference), the method returns the actual identifier from the original database. */ //void convertToRedirectedId (); /**!DOM \details Returns true if an object associated with the identifier has been erased. */ //bool isErased () const; /**!DOM \details Returns true if an PRC object, associated with the identifier, or any object from its ownership hierarchy, has been erased. */ //bool isEffectivelyErased () const; /** \details Requests the database handle of the object referenced by the . \returns An OdDbHandle object that represents the database handle. \remarks The method returns NULL if no database object is referenced by the . If the is redirected from another database (for example, an external reference), the method returns the handle from the original database. */ const OdDbHandle& getHandle() const; /**!DOM \details Returns the database handle of the object referenced by the identifier. \remarks Returns NULL if no database object is referenced by the identifier. If this identifier has been redirected from another database (for example, an external reference), the method returns the handle from the original database. */ //const OdDbHandle& getNonForwardedHandle () const; /**!DOM \details Opens the database object associated with the identifier. \param pObj [out] Smart pointer to the object to be opened. \param openMode [in] Mode in which the object must be opened. \param openErasedOne [in] Specifies whether erased objects are also opened (true) or not (false). \returns Returns eOk if successful, otherwise returns an Error Code. \remarks openMode must be one of the following: Identifier Value Description kNotOpen -1 Object is open for reading. kForRead 0 Object is open for reading. kForWrite 1 Object is open for reading and/or writing. kForNotify 2 Object is open for notifying.
*/ //OdResult openObject ( // OdBmObjectPtr& pObj, // OdBm::OpenMode openMode = OdBm::kForRead, // bool openErasedOne = false) const; /** \details Opens the database object associated with the . \param pObj [out] A smart pointer that acts as a placeholder for the opened object. \param openMode [in] A value that defines the for the opened object. \param openErasedOne [in] A flag that determines whether the method opens erased objects as well (when the flag value is equal to true) or not (when the flag value is equal to false). \returns The eOk value if the object is successfully opened; otherwise, the method returns an appropriate error code. \remarks The value (openMode parameter) must be one of the following:
Identifier Value Description
kNotOpen -1 The object is not open.
kForRead 0 The object is open for reading.
kForWrite 1 The object is open for reading and/or writing.
kForNotify 2 The object is open for notifications.
*/ OdResult openObject( OdRxObjectPtr& pObj, OpenMode openMode = kForRead, bool openErasedOne = false) const; /** \details Opens the database object associated with the . \param openMode [in] A value that defines the for the opened object. \param openErasedOne [in] A flag that determines whether the method opens erased objects as well (when the flag value is equal to true) or not (when the flag value is equal to false). \returns A smart pointer to the opened object if it is successfully opened; otherwise, the method returns a NULL pointer. \remarks The value (openMode parameter) must be one of the following:
Identifier Value Description
kNotOpen -1 The object is not open.
kForRead 0 The object is open for reading.
kForWrite 1 The object is open for reading and/or writing.
kForNotify 2 The object is open for notifications.
*/ OdRxObjectPtr openObject( OpenMode openMode = kForRead, bool openErasedOne = false) const; /** \details Safely opens the database object associated with the . \param openMode [in] A value that defines the for the opened object. \param openErasedOne [in] A flag that determines whether the method opens erased objects as well (when the flag value is equal to true) or not (when the flag value is equal to false). \returns A smart pointer to the opened object if it is successfully opened; otherwise, the method returns a NULL pointer. \remarks The value (openMode parameter) must be one of the following:
Identifier Value Description
kNotOpen -1 The object is not open.
kForRead 0 The object is open for reading.
kForWrite 1 The object is open for reading and/or writing.
kForNotify 2 The object is open for notifications.
The method throws one of the following exceptions:
Exception Name Exception Context
eNullObjectId The identifier is null.
ePermanentlyErased The object was not opened (the openErasedOne parameter is equal to true).
eWasErased The object was not opened (the openErasedOne parameter is equal to false).
*/ OdRxObjectPtr safeOpenObject(OpenMode openMode = kForRead, bool openErasedOne = false) const; protected: friend class OdPrcStub; OdDbStub* m_Id; }; /** \details A data type that represents an array of . */ typedef OdArray OdPrcObjectIdArray; #endif // _PRCOBJECTID_