/////////////////////////////////////////////////////////////////////////////// // 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 __OD_GS_FILER_H__ #define __OD_GS_FILER_H__ #include "TD_PackPush.h" #include "OdStreamBuf.h" #include "Gs/GsExport.h" #include "OdBinaryData.h" #include "OdVector.h" #include "IntArray.h" #include "UInt8Array.h" #include "UInt32Array.h" #include "UInt16Array.h" #include "GsMarkerArray.h" #include "DbStubPtrArray.h" #include "Ge/GePoint3dArray.h" #include "Ge/GePoint2d.h" #include "UInt64Array.h" class OdGePoint2d; class OdGeVector2d; class OdGePoint3d; class OdGeVector3d; class OdGeMatrix3d; class OdGeExtents3d; class OdDbStub; typedef OdRxObject OdDbBaseDatabase; class OdGsView; class OdGsModel; class OdGsCache; class OdGsDCRect; class OdGsDCRectDouble; typedef OdArray > OdFloatArray; typedef OdArray > OdGePoint2dArray; /** \details OdGsFiler abstract extension interface. */ class GS_TOOLKIT_EXPORT OdGsFilerExtension { public: /** \details Extension type. */ enum Type { kSubstitutor, // State saver substitutions processor. kArbitraryData, // Arbitrary data container. kPointersRegistrator, // Registered pointers container. kStreamAccessor, // File stream accessor. kIdSaver, // Local cache object Id's processor. kLoadingReactor, // Local cache loading reactor. kNumExtensions // Number of registered extension types. }; public: /** \details Destructor for the OdGsFilerExtension class. */ virtual ~OdGsFilerExtension() {} /** \details Returns extension type. */ virtual Type type() const = 0; }; /** \details Graphics system filer interface. */ class GS_TOOLKIT_EXPORT OdGsFiler : public OdRxObject { public: ODRX_DECLARE_MEMBERS(OdGsFiler); /** \details Default constructor for the OdGsFiler class. */ OdGsFiler() { } /** \details Destructor for the OdGsFiler class. */ virtual ~OdGsFiler() { } public: /** \details Type of graphics system filer. */ enum class FilerType { kLocalCacheSaver, // Saves/loads local object caches, without separate cache sections. kCacheStateSaver // Saves/loads entire graphics cache state (GSS) }; public: // File version control /** \details Retrieves a file version for this filer. \returns one of the following values: * 100 - file version 1 * 200 - file version 2 */ virtual OdUInt32 version() const = 0; /** \details Sets a file version for this filer. \param nVersion [in] File version. See Version enum. */ virtual void setVersion(OdUInt32 nVersion) = 0; // Filer type control /** \details Retrieves type of this filer. */ virtual FilerType filerType() const = 0; // Extensions /** \details Checks does graphics system filer supports extension. \param type [in] Extension type. \returns true if extension supported or false elsewhere. */ virtual bool hasExtension(OdGsFilerExtension::Type /*type*/) const { return false; } /** \details Returns graphics system filer extension. \param type [in] Extension type. \returns graphics system filer extension or nullptr elsewhere. */ virtual OdGsFilerExtension *getExtension(OdGsFilerExtension::Type /*type*/) const { return nullptr; } /** \details Install graphics system filer extension to this filer object. \param pExtension [in] Graphics system filer extension. \returns true if extension installed correctly or false elsewhere. */ virtual bool installExtension(OdGsFilerExtension */*pExtension*/ ) { return false; } /** \details Uninstall graphics system filer extension from this filer object. \param type [in] Extension type. \returns true if extension uninstalled correctly or false elsewhere. */ virtual bool uninstallExtension(OdGsFilerExtension::Type /*type*/) { return false; } // Process handles /** \details Writes database handle to the stream. \param pHandle [in] Pointer to database handle. */ virtual void wrHandle(OdDbStub *pHandle) = 0; /** \details Retrieves a pointer to database handle. */ virtual OdDbStub *rdHandle() const = 0; // Process classes /** \details Writes a name of the class associated with passed object to the stream. \param pObj [in] Pointer to database handle. */ virtual void wrClass(OdRxObject *pObj) = 0; /** \details Retrieves a smart pointer to a class at current stream position. \returns smart pointer to a class by read class name, if class not found by class name this method returns a smart pointer to a not valid class. */ virtual OdRxObjectPtr rdClass() const = 0; // Process raw data /** \details Writes raw data to the stream. \param pData [in] Pointer to data (in bytes). \param nDataSize [in] Data size. */ virtual void wrRawData(const void *pData, OdUInt32 nDataSize) = 0; /** \details Reads raw data from the stream. \param pData [out] Pointer to data (in bytes). \param nDataSize [in] Data size. */ virtual void rdRawData(void *pData, OdUInt32 nDataSize) const = 0; // Process data primitives /** \details Writes data of bool type to the stream. \param bVal [in] Data to write. */ virtual void wrBool(bool bVal); /** \details Reads data of bool type from the stream. \returns read bool value. */ virtual bool rdBool() const; /** \details Writes data of int type to the stream. \param val [in] Data to write. */ virtual void wrInt(int val); /** \details Reads data of int type from the stream. \returns read int value. */ virtual int rdInt() const; /** \details Writes data of unsigned int type to the stream. \param val [in] Data to write. */ virtual void wrUInt(unsigned int val); /** \details Reads data of unsigned int type from the stream. \returns read unsigned int value. */ virtual unsigned int rdUInt() const; /** \details Writes data of char type to the stream. \param val [in] Data to write. */ virtual void wrChar(char val); /** \details Reads data of char type from the stream. \returns read char value. */ virtual char rdChar() const; /** \details Writes data of OdUInt8 type (unsigned int 8 bits) to the stream. \param val [in] Data to write. */ virtual void wrUInt8(OdUInt8 val); /** \details Reads data of OdUInt8 type (unsigned int 8 bits) from the stream. \returns read OdUInt8 value. */ virtual OdUInt8 rdUInt8() const; /** \details Writes data of OdInt16 type (int 16 bits) to the stream. \param val [in] Data to write. */ virtual void wrInt16(OdInt16 val); /** \details Reads data of OdInt16 type (int 16 bits) from the stream. \returns read OdInt16 value. */ virtual OdInt16 rdInt16() const; /** \details Writes data of OdUInt16 type (unsigned int 16 bits) to the stream. \param val [in] Data to write. */ virtual void wrUInt16(OdUInt16 val); /** \details Reads data of OdUInt16 type (unsigned int 16 bits) from the stream. \returns read OdUInt16 value. */ virtual OdUInt16 rdUInt16() const; /** \details Writes data of OdInt32 type (int 32 bits) to the stream. \param val [in] Data to write. */ virtual void wrInt32(OdInt32 val); /** \details Reads data of OdInt32 type (int 32 bits) from the stream. \returns read OdInt32 value. */ virtual OdInt32 rdInt32() const; /** \details Writes data of OdUInt32 type (unsigned int 32 bits) to the stream. \param val [in] Data to write. */ virtual void wrUInt32(OdUInt32 val); /** \details Reads data of OdUInt32 type (unsigned int 32 bits) from the stream. \returns read OdUInt32 value. */ virtual OdUInt32 rdUInt32() const; /** \details Reads data of OdInt64 type (int 64 bits) from the stream. \returns read OdInt64 value. */ virtual void wrInt64(OdInt64 val); /** \details Reads data of OdInt64 type (int 64 bits) from the stream. \returns read OdInt64 value. */ virtual OdInt64 rdInt64() const; /** \details Writes data of OdUInt64 type (unsigned int 64 bits) to the stream. \param val [in] Data to write. */ virtual void wrUInt64(OdUInt64 val); /** \details Reads data of OdUInt64 type (unsigned int 64 bits) from the stream. \returns read OdUInt64 value. */ virtual OdUInt64 rdUInt64() const; /** \details Writes data of OdIntPtr type (integer that is able to store a pointer (32 or 64 depending on platform)) to the stream. \param val [in] Data to write. */ virtual void wrIntPtr(OdIntPtr val); /** \details Reads data of rdIntPtr type (integer that is able to store a pointer (32 or 64 depending on platform)) from the stream. \returns read OdIntPtr value. */ virtual OdIntPtr rdIntPtr() const; /** \details Writes data defined by the passed pointer. Internally type is cast to OdIntPtr. \param pPtr [in] Pointer to the data to write. */ void wrPtr(const void *pPtr) { wrIntPtr((OdIntPtr)pPtr); } /** \details Reads the data and returns pointer to it. Length of the read data equals to OdIntPtr data type length. */ void *rdPtr() const { return (void*)rdIntPtr(); } /** \details Writes color value defined by the ODCOLORREF macro. \param val [in] Value to write. */ virtual void wrCOLORREF(ODCOLORREF val); /** \details Reads the color data defined by the ODCOLORREF macro. Length of the read data equals to OdUInt32 data type length. */ virtual ODCOLORREF rdCOLORREF() const; /** \details Writes data of float type to the stream. \param val [in] Data to write. */ virtual void wrFloat(float val); /** \details Reads data of float type from the stream. \returns read float value. */ virtual float rdFloat() const; /** \details Writes data of double type to the stream. \param val [in] Data to write. */ virtual void wrDouble(double val); /** \details Reads data of double type from the stream. \returns read double value. */ virtual double rdDouble() const; /** \details Writes data of OdGePoint2d type (2-dimensional point) to the stream. \param pt [in] Data to write. */ virtual void wrPoint2d(const OdGePoint2d &pt); /** \details Reads data of OdGePoint2d type from the stream. \param pt [out] Receives 2D point. */ virtual void rdPoint2d(OdGePoint2d &pt) const; /** \details Writes data of OdGeVector2d type (2-dimensional vector) to the stream. \param vec [in] Data to write. */ virtual void wrVector2d(const OdGeVector2d &vec); /** \details Reads data of OdGeVector2d type from the stream. \param vec [out] Receives 2D vector. */ virtual void rdVector2d(OdGeVector2d &vec) const; /** \details Writes data of OdGePoint3d type (3-dimensional point) to the stream. \param pt [in] Data to write. */ virtual void wrPoint3d(const OdGePoint3d &pt); /** \details Reads data of OdGePoint3d type from the stream. \param pt [out] Receives 3D point. */ virtual void rdPoint3d(OdGePoint3d &pt) const; /** \details Writes data of OdGeVector3d type (3-dimensional vector) to the stream. \param vec [in] Data to write. */ virtual void wrVector3d(const OdGeVector3d &vec); /** \details Reads data of OdGeVector3d type from the stream. \param vec [out] Receives 3D vector. */ virtual void rdVector3d(OdGeVector3d &vec) const; /** \details Writes data of OdGeMatrix3d type (3-dimensional transformation matrix) to the stream. \param mat [in] Data to write. */ virtual void wrMatrix3d(const OdGeMatrix3d &mat); /** \details Reads data of OdGeMatrix3d type from the stream. \param mat [out] Receives 3D transformation matrix. */ virtual void rdMatrix3d(OdGeMatrix3d &mat) const; /** \details Writes data of OdGeExtents3d type (3-dimensional extents) to the stream. \param ext [in] Data to write. */ virtual void wrExtents3d(const OdGeExtents3d &ext); /** \details Reads data of OdGeExtents3d type from the stream. \param ext [out] Receives 3D extents. */ virtual void rdExtents3d(OdGeExtents3d &ext) const; /** \details Writes data of OdAnsiString type (ANSI string) to the stream. \param str [in] Data to write. */ virtual void wrAnsiString(const OdAnsiString &str); /** \details Reads data of OdAnsiString type from the stream. \param str [out] Receives ANSI string. */ virtual void rdAnsiString(OdAnsiString &str) const; /** \details Reads and returns data of OdAnsiString type from the stream. */ OdAnsiString rdAnsiStringRet() const { OdAnsiString str; rdAnsiString(str); return str; } /** \details Writes data of OdString type (string) to the stream. \param str [in] Data to write. */ virtual void wrString(const OdString &str); /** \details Reads data of OdString type (string) from the stream. \param str [out] Receives a string. */ virtual void rdString(OdString &str) const; /** \details Reads and returns data of OdString type from the stream. */ OdString rdStringRet() const { OdString str; rdString(str); return str; } /** \details Writes an array of OdUInt8 values (unsigned int 8 bits) to the stream. \param arr [in] Array to write. */ virtual void wrUInt8Array (const OdUInt8Array& arr); /** \details Writes an array of OdUInt16 values (unsigned int 16 bits) to the stream. \param arr [in] Array to write. */ virtual void wrUInt16Array(const OdUInt16Array& arr); /** \details Writes an array of OdUInt16 values (unsigned int 16 bits) to the stream. \param count [in] Count of elements in the array. \param arr [in] Array to write. */ virtual void wrUInt16Array(OdUInt32 count, const OdUInt16* arr); /** \details Writes an array of OdUInt32 values (unsigned int 32 bits) to the stream. \param arr [in] Array to write. */ virtual void wrUInt32Array(const OdUInt32Array& arr); /** \details Writes a vector of OdUInt32 values (unsigned int 32 bits) to the stream. \param arr [in] Vector to write. */ virtual void wrUInt32Array(const OdUInt32Vector& arr); /** \details Writes an array of OdUInt64 values (unsigned int 64 bits) to the stream. \param arr [in] Array to write. */ virtual void wrUInt64Array(const OdUInt64Array& arr); /** \details Writes a vector of OdUInt64 values (unsigned int 64 bits) to the stream. \param vec [in] Vector to write. */ virtual void wrUInt64Array(const OdUInt64Vector& vec); /** \details Writes an array of OdUInt64 values (unsigned int 16 bits) to the stream. \param count [in] Count of elements in the array. \param arr [in] Array to write. */ virtual void wrUInt64Array(OdUInt32 count, const OdUInt64* arr); /** \details Writes an array of integer values to the stream. \param arr [in] Array to write. */ virtual void wrIntArray (const OdIntArray& arr); /** \details Writes an array of float values to the stream. \param arr [in] Array to write. */ virtual void wrFloatArray (const OdFloatArray& arr); /** \details Writes an array of float values to the stream. \param count [in] Count of elements in the array. \param arr [in] Array to write. */ virtual void wrFloatArray (OdUInt32 count, const float* arr); /** \details Writes an array of 2D points to the stream. \param arr [in] Array to write. */ virtual void wrPoint2dArray (const OdGePoint2dArray& arr); /** \details Writes an array of 3D points to the stream. \param arr [in] Array to write. */ virtual void wrPoint3dArray (const OdGePoint3dArray& arr); /** \details Writes an array of pointers to database-resident objects to the stream. \param arr [in] Array to write. */ virtual void wrDbStubPtrArray(const OdDbStubPtrArray& arr); /** \details Writes an array of 2D device rectangles to the stream. \param rc [in] Array to write. */ virtual void wrGsDCRect (const OdGsDCRect& rc); /** \details Writes an array of 2D device rectangles (with coordinates represented by values of the double type) to the stream. \param rcd [in] Array to write. */ virtual void wrGsDCRectDouble(const OdGsDCRectDouble& rcd); /** \details Reads an array of OdUInt8 values (unsigned int 8 bits) from the stream. \param arr [out] Receives an array of OdUInt8 values. */ virtual void rdUInt8Array (OdUInt8Array& arr); /** \details Reads an array of OdUInt16 values (unsigned int 16 bits) from the stream. \param arr [out] Receives an array of OdUInt16 values. */ virtual void rdUInt16Array(OdUInt16Array& arr); /** \details Reads an array of OdUInt16 values (unsigned int 16 bits) from the stream. \param count [in] Count of elements in the array. \param arr [out] Receives an array of OdUInt16 values. */ virtual void rdUInt16Array(OdUInt32 count, OdUInt16* arr); /** \details Reads an array of OdUInt32 values (unsigned int 32 bits) from the stream. \param arr [out] Receives an array of OdUInt32 values. */ virtual void rdUInt32Array(OdUInt32Array& arr); /** \details Reads a vector of OdUInt32 values (unsigned int 32 bits) from the stream. \param arr [out] Receives a vector of OdUInt32 values. */ virtual void rdUInt32Array(OdUInt32Vector& arr); /** \details Reads an array of OdUInt64 values (unsigned int 64 bits) from the stream. \param arr [out] Receives an array of OdUInt64 values. */ virtual void rdUInt64Array(OdUInt64Array& arr); /** \details Reads a vector of OdUInt64 values (unsigned int 64 bits) from the stream. \param arr [out] Receives a vector of OdUInt64 values. */ virtual void rdUInt64Array(OdUInt64Vector& vec); /** \details Reads an array of OdUInt64 values (unsigned int 64 bits) from the stream. \param count [in] Count of elements in the array. \param arr [out] Receives an array of OdUInt64 values. */ virtual void rdUInt64Array(OdUInt32 count, OdUInt64* arr); /** \details Reads an array of integer values from the stream. \param arr [out] Receives an array of integer values. */ virtual void rdIntArray (OdIntArray& arr); /** \details Reads an array of float values from the stream. \param arr [out] Receives an array of float values. */ virtual void rdFloatArray (OdFloatArray& arr); /** \details Reads an array of float values from the stream. \param count [in] Count of elements in the array. \param arr [out] Receives an array of float values. */ virtual void rdFloatArray (OdUInt32 count, float* arr); /** \details Reads an array of 2D points from the stream. \param arr [out] Receives an array of 2D points. */ virtual void rdPoint2dArray (OdGePoint2dArray& arr); /** \details Reads an array of 3D points from the stream. \param arr [out] Receives an array of 3D points. */ virtual void rdPoint3dArray (OdGePoint3dArray& arr); /** \details Reads an array of pointers to database-resident objects from the stream. \param arr [out] Receives an array of pointers to database-resident objects. */ virtual void rdDbStubPtrArray(OdDbStubPtrArray& arr); /** \details Reads an array of 2D device rectangles from the stream. \param arr [out] Receives an array of 2D device rectangles. */ virtual void rdGsDCRect (OdGsDCRect& dcrc); /** \details Reads an array of 2D device rectangles (with coordinates represented by values of the double type) from the stream. \param arr [out] Receives an array of 2D device rectangles (with coordinates represented by values of the double type). */ virtual void rdGsDCRectDouble(OdGsDCRectDouble& dcrcd); }; typedef OdSmartPtr OdGsFilerPtr; #define OdGsFiler_wrArray(filer, arry, wrFunc) \ { \ filer.wrUInt32(arry.size()); \ for (OdUInt32 nVal = 0; nVal < arry.size(); nVal++) \ filer.wrFunc(arry.getPtr()[nVal]); \ } #define OdGsFilerPtr_wrArray(pFiler, arry, wrFunc) \ OdGsFiler_wrArray((*pFiler), arry, wrFunc) #define OdGsFiler_wrArrayRaw(filer, arry, typSz) \ { \ filer.wrUInt32(arry.size()); \ if (!arry.isEmpty()) \ filer.wrRawData(arry.getPtr(), arry.size() * typSz); \ } #define OdGsFilerPtr_wrArrayRaw(pFiler, arry, typSz) \ OdGsFiler_wrArrayRaw((*pFiler), arry, typSz) #define OdGsFiler_rdArray(filer, arry, rdFunc) \ { \ arry.clear(); \ OdUInt32 nElems = filer.rdUInt32(); \ arry.setPhysicalLength(nElems); \ for (OdUInt32 nElem = 0; nElem < nElems; nElem++) \ arry.push_back(filer.rdFunc()); \ } #define OdGsFilerPtr_rdArray(pFiler, arry, rdFunc) \ OdGsFiler_rdArray((*pFiler), arry, rdFunc) #define OdGsFiler_rdArrayArg(filer, arry, rdFunc) \ { \ OdUInt32 nElems = filer.rdUInt32(); \ arry.resize(nElems); \ for (OdUInt32 nElem = 0; nElem < nElems; nElem++) \ filer.rdFunc(arry[nElem]); \ } #define OdGsFilerPtr_rdArrayArg(pFiler, arry, rdFunc) \ OdGsFiler_rdArrayArg((*pFiler), arry, rdFunc) #define OdGsFiler_rdArrayRaw(filer, arry, typSz) \ { \ OdUInt32 nElems = filer.rdUInt32(); \ arry.resize(nElems); \ if (nElems) \ filer.rdRawData(arry.asArrayPtr(), nElems * typSz); \ } #define OdGsFilerPtr_rdArrayRaw(pFiler, arry, typSz) \ OdGsFiler_rdArrayRaw((*pFiler), arry, typSz) /** \details State saver substitutions processor GsFiler extension. */ class GS_TOOLKIT_EXPORT OdGsFilerExtensionSubstitutor : public OdGsFilerExtension { public: /** \details Abstract substitution processing method. */ struct SubstitutionActuator { /** \details Address subsitution function pointer. */ typedef void (*SetPtrFunc)(void *pPlace, const void *pValue); /** \details Default constructor for the SubstitutionActuator structure. */ SubstitutionActuator() { } /** \details Destructor for the SubstitutionActuator class. */ virtual ~SubstitutionActuator() { } /** \details Substitution application method. \param pPlace [in] Address where substitution should be applied. \param pValue [in] Address of value to be applied. \param pSetFunc [in] Address application function. */ virtual void applySubstitution(void *pPlace, const void *pValue, SetPtrFunc pSetFunc) { pSetFunc(pPlace, pValue); } }; /** \details Substitutions processor interface. */ struct Substitutor { /** \details Register known substitution. \param pValue [in] Address of value for which new value should be applied. \param pSubstitution [in] Address of value to be applied. \param size [in] Size of value to be applied. \param bRegister [in] Store substitution in substitutions collection. \param bImmediate [in] Apply substitution immediately if this is possible. */ virtual void registerSubstitution(const void *pValue, const void *pSubstitution, OdUInt32 size = sizeof(OdIntPtr), bool bRegister = true, bool bImmediate = false) = 0; /** \details Register substitution request. \param pPlace [in] Address where substitution should be applied. \param pValue [in] Address of value for which new value should be applied. \param size [in] Size of value place where subtitution will be applied. \param bRegister [in] Store substitution request in substitutions collection. \param bImmediate [in] Apply substitution immediately if this is possible. */ virtual void requestSubstitution(void *pPlace, const void *pValue, OdUInt32 size = sizeof(OdIntPtr), bool bRegister = true, bool bImmediate = true) = 0; /** \details Register substitution request for smart pointer. \param pPlace [in] Address where substitution should be applied. \param pValue [in] Address of value for which new value should be applied. \param bRegister [in] Store substitution request in substitutions collection. \param bImmediate [in] Apply substitution immediately if this is possible. */ virtual void requestSubstitution(OdBaseObjectPtr *pPlace, const void *pValue, bool bRegister = true, bool bImmediate = true) = 0; /** \details Register substitution with non-default behavior. \param pPlace [in] Address where substitution should be applied. \param pActuator [in] Substitution processing method. \param pValue [in] Address of value for which new value should be applied. \param size [in] Size of value place where subtitution will be applied. \param bRegister [in] Store substitution request in substitutions collection. \param bImmediate [in] Apply substitution immediately if this is possible. */ virtual void requestSubstitution(void *pPlace, OdGsFilerExtensionSubstitutor::SubstitutionActuator *pActuator, const void *pValue, OdUInt32 size = sizeof(OdIntPtr), bool bRegister = true, bool bImmediate = true) = 0; /** \details Clear substitutions. \param pValue [in] Address of value for which substitutions collection should be cleared or null to clear all. \param size [in] Size of value which should be cleared. */ virtual void clearSubstitutions(const void *pValue = NULL, OdUInt32 size = 0) = 0; /** \details Run substitutions. \param pValue [in] Address of value for which substitutions process should be executed or null to process all. \param size [in] Size of value for which substitutions should be executed. \param bClear [in] Clear substitutions collection after processing if true or keep if false. */ virtual void runSubstitutions(const void *pValue = NULL, OdUInt32 size = 0, bool bClear = true) = 0; }; public: /** \details Returns extension type. */ virtual Type type() const { return kSubstitutor; } /** \details Cast extension from extensions base class. \param pExt [in] Pointer to base extension interface. */ static OdGsFilerExtensionSubstitutor *cast(OdGsFilerExtension *pExt) { return static_cast(pExt); } /** \details Cast extension from extensions base class. \param pExt [in] Pointer to base extension interface. */ static const OdGsFilerExtensionSubstitutor *cast(const OdGsFilerExtension *pExt) { return static_cast(pExt); } // Substitutions processing /** \details Substitutions processor interface. \returns substitutions processor interface. */ virtual Substitutor *subst() const = 0; /** \details Apply collected substitutions. \param bClear [in] Clear substitutions collection after applying. */ virtual void makeSubstitutions(bool bClear = true) const = 0; /** \details Returns substitutions processor interface as OdRxObject pointer. */ virtual OdRxObjectPtr getSubstitutor() const = 0; /** \details Sets external substitions processor interface. \param pSubst [in] Substitutions processor interface pointer. */ virtual void setSubstitutor(OdRxObject *pSubst) = 0; }; /** \details Arbitrary data container GsFiler extension. */ class GS_TOOLKIT_EXPORT OdGsFilerExtensionArbitraryData : public OdGsFilerExtension { public: /** \details Returns extension type. */ virtual Type type() const { return kArbitraryData; } /** \details Cast extension from extensions base class. \param pExt [in] Pointer to base extension interface. */ static OdGsFilerExtensionArbitraryData *cast(OdGsFilerExtension *pExt) { return static_cast(pExt); } /** \details Cast extension from extensions base class. \param pExt [in] Pointer to base extension interface. */ static const OdGsFilerExtensionArbitraryData *cast(const OdGsFilerExtension *pExt) { return static_cast(pExt); } // Arbitrary data /** \details Sets arbitrary data. \param pName [in] Dictionary entry name. \param pObject [in] Object which should be stored at specified name. */ virtual void setArbitraryData(const OdChar *pName, OdRxObject *pObject) = 0; /** \details Returns arbitrary data. \param pName [in] Dictionary entry name. \returns stored object pointer or null object pointer if name not exists. */ virtual OdRxObjectPtr getArbitraryData(const OdChar *pName) const = 0; /** \details Checks does arbitrary data registered. \param pName [in] Dictionary entry name. \returns true if specified name exists or false elsewhere. */ virtual bool hasArbitraryData(const OdChar *pName) const = 0; /** \details Clears arbitrary data dictionary. */ virtual void clearArbitraryData() = 0; }; /** \details Registered pointers container GsFiler extension. */ class GS_TOOLKIT_EXPORT OdGsFilerExtensionPointersRegistrator : public OdGsFilerExtension { public: /** \details Returns extension type. */ virtual Type type() const { return kPointersRegistrator; } /** \details Cast extension from extensions base class. \param pExt [in] Pointer to base extension interface. */ static OdGsFilerExtensionPointersRegistrator *cast(OdGsFilerExtension *pExt) { return static_cast(pExt); } /** \details Cast extension from extensions base class. \param pExt [in] Pointer to base extension interface. */ static const OdGsFilerExtensionPointersRegistrator *cast(const OdGsFilerExtension *pExt) { return static_cast(pExt); } // Pointers registration /** \details Register pointer. \param pPtr [in] Pointer which should be registered. */ virtual void registerPtr(const void *pPtr) = 0; /** \details Unregister pointer. \param pPtr [in] Pointer which should be unregistered. */ virtual void unregisterPtr(const void *pPtr) = 0; /** \details Checks does specified pointer registered. \param pPtr [in] Pointer to be checked. \returns true if specified pointer registered or false elsewhere. */ virtual bool isPtrRegistered(const void *pPtr) const = 0; /** \details Clears registered pointers collection. */ virtual void clearRegisteredPtrs() = 0; }; /** \details File stream accessor GsFiler extension. */ class GS_TOOLKIT_EXPORT OdGsFilerExtensionStreamAccessor : public OdGsFilerExtension { public: /** \details Returns extension type. */ virtual Type type() const { return kStreamAccessor; } /** \details Cast extension from extensions base class. \param pExt [in] Pointer to base extension interface. */ static OdGsFilerExtensionStreamAccessor *cast(OdGsFilerExtension *pExt) { return static_cast(pExt); } /** \details Cast extension from extensions base class. \param pExt [in] Pointer to base extension interface. */ static const OdGsFilerExtensionStreamAccessor *cast(const OdGsFilerExtension *pExt) { return static_cast(pExt); } /** \details Attaches a specified stream. \param pStream [in] Pointer to a stream to set. */ virtual void setStream(OdStreamBuf *pStream) = 0; /** \details Retrieves a smart pointer to current stream. */ virtual OdStreamBufPtr getStream() const = 0; }; /** \details Managed OdGsFiler object Id. */ struct GS_TOOLKIT_EXPORT OdGsFilerObjectId { public: /** \details Type of object Id. */ enum class ObjectType { kUnknown, // Unknown object type. // GsFiler storeable // Gs side (DBRO object connections) kMetafile, // Metafile connection node. kMaterial, // Material node. kLayer, // Layer node. kBlock, // Block node. // Gs-side (block references) kReference, // Reference implementation. kRefLinker, // Block reference linker. // Vectorizer side (Internal connections) kVisualStyle, // Visual Style. kRasterImage, // Vectorizer-side raster image cache. kTtfCache, // TTF cache. kGroup, // Vectorizer-side group definition. kInternalLayer, // Vectorizer-size layer definition (isn't linked with Gs layer node). // GsFiler non-storeable // Vectorizer side (Internal connections which is not stored by GsFiler separately) kInternalMf, // Server-side metafile connection. kInternalMatItem, // Material item links vectorizer cache with GsMaterialNode. // Renderer side (RuntimeId connections) kRenderMf, // Client-side graphic metafile. kRenderMaterial, // Client-side material. kRenderTexture, // Client-side texture. kRenderVs, // Client-side visual style. kRenderGroup, // Client-side group definition. kRenderLayer // Client-side layer definition. }; /** \details Type of Id. */ enum class IdType { kNoId = 0, // No Id type. kPersistentId, // Persistent Id. kTransientId, // Transient Id. kIndex // Index value. }; /** \details Transient object type. */ typedef void TransientType; protected: ObjectType m_type; OdUInt32 m_flags; OdUInt64 m_id; OdUInt64 m_subId; OdUInt64 m_index; protected: /** \details Compares OdGsFilerObjectId objects. \param oId [in] Second OdGsFilerObjectId object. \returns -1 if this object less than second, 0 if objects equal or 1 if this object greater than second. */ int diff(const OdGsFilerObjectId &oId) const { if (m_type < oId.m_type) return -1; else if (m_type > oId.m_type) return 1; if (m_id < oId.m_id) return -1; else if (m_id > oId.m_id) return 1; if (m_subId < oId.m_subId) return -1; else if (m_subId > oId.m_subId) return 1; if (m_index < oId.m_index) return -1; else if (m_index > oId.m_index) return 1; if (m_flags < oId.m_flags) return -1; else if (m_flags > oId.m_flags) return 1; return 0; } public: bool operator ==(const OdGsFilerObjectId &oId) const { return diff(oId) == 0; } bool operator !=(const OdGsFilerObjectId &oId) const { return diff(oId) != 0; } bool operator <(const OdGsFilerObjectId &oId) const { return diff(oId) < 0; } bool operator >(const OdGsFilerObjectId &oId) const { return diff(oId) > 0; } bool operator <=(const OdGsFilerObjectId &oId) const { return diff(oId) <= 0; } bool operator >=(const OdGsFilerObjectId &oId) const { return diff(oId) >= 0; } protected: void setIdType(IdType idType) { m_flags = (m_flags & ~3) | static_cast(idType); } IdType getIdType() const { return static_cast(m_flags & 3); } void setSubIdType(IdType idType) { m_flags = (m_flags & ~(3 << 2)) | (static_cast(idType) << 2); } IdType getSubIdType() const { return static_cast((m_flags >> 2) & 3); } void setIndexType(IdType idType) { m_flags = (m_flags & ~(3 << 4)) | (static_cast(idType) << 4); } IdType getIndexType() const { return static_cast((m_flags >> 4) & 3); } public: /** \details Default constructor for the OdGsFilerObjectId structure. */ OdGsFilerObjectId() : m_type(ObjectType::kUnknown), m_flags(0) , m_id(0), m_subId(0), m_index(0) { } /** \details Simple PersistentId-oriented constructor for the OdGsFilerObjectId structure. \param objType [in] Type of managed object. \param pDbId [in] Persistent database object Id. */ OdGsFilerObjectId(ObjectType objType, const OdDbStub *pDbId) : m_type(objType), m_flags(0), m_id(reinterpret_cast(pDbId)), m_subId(0), m_index(0) { if (pDbId) setIdType(IdType::kPersistentId); } /** \details Simple TransientId-oriented constructor for the OdGsFilerObjectId structure. \param objType [in] Type of managed object. \param pId [in] Transient object Id. */ OdGsFilerObjectId(ObjectType objType, const TransientType *pId) : m_type(objType), m_flags(0), m_id(reinterpret_cast(pId)), m_subId(0), m_index(0) { if (pId) setIdType(IdType::kTransientId); } /** \details Simple Index-oriented constructor for the OdGsFilerObjectId structure. \param objType [in] Type of managed object. \param nIndex [in] Index value. */ OdGsFilerObjectId(ObjectType objType, OdUInt32 nIndex) : m_type(objType), m_flags(0), m_id(nIndex), m_subId(0), m_index(0) { setIdType(IdType::kIndex); } /** \details Simple Index-oriented constructor for the OdGsFilerObjectId structure. \param objType [in] Type of managed object. \param nIndex [in] Index value. */ OdGsFilerObjectId(ObjectType objType, OdUInt64 nIndex) : m_type(objType), m_flags(0), m_id(nIndex), m_subId(0), m_index(0) { setIdType(IdType::kIndex); } /** \details Two-factor PersistentId-oriented constructor with secondary Id for the OdGsFilerObjectId structure. \param objType [in] Type of managed object. \param pDbId1 [in] Primary persistent database object Id. \param pDbId2 [in] Secondary persistent database object Id. */ OdGsFilerObjectId(ObjectType objType, const OdDbStub *pDbId1, const OdDbStub *pDbId2) : m_type(objType), m_flags(0), m_id(reinterpret_cast(pDbId1)) , m_subId(reinterpret_cast(pDbId2)), m_index(0) { if (pDbId1) setIdType(IdType::kPersistentId); if (pDbId2) setSubIdType(IdType::kPersistentId); } /** \details Two-factor PersistentId-oriented constructor with index for the OdGsFilerObjectId structure. \param objType [in] Type of managed object. \param pDbId [in] Persistent database object Id. \param nIndex [in] Numeric index. */ OdGsFilerObjectId(ObjectType objType, const OdDbStub *pDbId, OdUInt32 nIndex) : m_type(objType), m_flags(0), m_id(reinterpret_cast(pDbId)), m_subId(nIndex), m_index(0) { if (pDbId) setIdType(IdType::kPersistentId); setSubIdType(IdType::kIndex); } /** \details Two-factor PersistentId-oriented constructor with index for the OdGsFilerObjectId structure. \param objType [in] Type of managed object. \param pDbId [in] Persistent database object Id. \param nIndex [in] Numeric index. */ OdGsFilerObjectId(ObjectType objType, const OdDbStub *pDbId, OdUInt64 nIndex) : m_type(objType), m_flags(0), m_id(reinterpret_cast(pDbId)), m_subId(nIndex), m_index(0) { if (pDbId) setIdType(IdType::kPersistentId); setSubIdType(IdType::kIndex); } /** \details Checks does object Id set. \returns true if object Id set or false elsewhere. */ bool hasObject() const { return m_type != ObjectType::kUnknown; } /** \details Sets type of object Id. \param objType [in] Type of managed object. */ void setObjectType(ObjectType objType) { m_type = objType; } /** \details Returns type of object Id. */ ObjectType objectType() const { return m_type; } /** \details Returns complexity of OdGsFilerObjectId object from 0 to 3. */ int complexity() const { return ((getIdType() != IdType::kNoId) ? 1 : 0) + ((getSubIdType() != IdType::kNoId) ? 1 : 0) + ((getIndexType() != IdType::kNoId) ? 1 : 0); } /** \details Checks does OdGsFilerObjectId contains at least one actual identifier. */ bool isEmpty() const { return !m_flags; } /** \details Returns serialized flags state for further storing. */ OdUInt8 serializeFlags() const { return static_cast(m_flags); } /** \details Restores flags state from serialized value. \param nFlags [in] Serialized flags. */ void deserializeFlags(OdUInt8 nFlags) { m_flags = nFlags; } /** \details Returns type of primary Id. */ IdType idType() const { return getIdType(); } /** \details Sets primary Id as persistent object Id. \param pDbId [in] Persistent database object Id. */ void setPersistentId(const OdDbStub *pDbId) { m_id = reinterpret_cast(pDbId); setIdType(pDbId ? IdType::kPersistentId : IdType::kNoId); } /** \details Sets primary Id as transient object Id. \param pId [in] Transient object Id. */ void setTransientId(const TransientType *pId) { m_id = reinterpret_cast(pId); setIdType(pId ? IdType::kTransientId : IdType::kNoId); } /** \details Sets primary Id as numeric index. \param nIndex [in] Index value. */ void setIdIndex(OdUInt32 nIndex) { m_id = nIndex; setIdType(IdType::kIndex); } /** \details Sets primary Id as numeric index. \param nIndex [in] Index value. */ void setIdIndex(OdUInt64 nIndex) { m_id = nIndex; setIdType(IdType::kIndex); } /** \details Returns primary Id as peristent object Id. */ OdDbStub *idAsPersistent() const { return reinterpret_cast(m_id); } /** \details Returns primary Id as transient object Id. */ TransientType *idAsTransient() const { return reinterpret_cast(m_id); } /** \details Returns primary Id as numeric index. */ OdUInt32 idAsIndex32() const { return static_cast(m_id); } /** \details Returns primary Id as numeric index. */ OdUInt64 idAsIndex64() const { return m_id; } /** \details Returns type of secondary Id. */ IdType subIdType() const { return getSubIdType(); } /** \details Sets secondary Id as persistent object Id. \param pDbId [in] Persistent database object Id. */ void setPersistentSubId(const OdDbStub *pDbId) { m_subId = reinterpret_cast(pDbId); setSubIdType(pDbId ? IdType::kPersistentId : IdType::kNoId); } /** \details Sets secondary Id as transient object Id. \param pId [in] Transient object Id. */ void setTransientSubId(const TransientType *pId) { m_subId = reinterpret_cast(pId); setSubIdType(pId ? IdType::kTransientId : IdType::kNoId); } /** \details Sets secondary Id as numeric index. \param nIndex [in] Index value. */ void setSubIndex(OdUInt32 nIndex) { m_subId = nIndex; setSubIdType(IdType::kIndex); } /** \details Sets secondary Id as numeric index. \param nIndex [in] Index value. */ void setSubIndex(OdUInt64 nIndex) { m_subId = nIndex; setSubIdType(IdType::kIndex); } /** \details Returns secondary Id as peristent object Id. */ OdDbStub *subIdAsPersistent() const { return reinterpret_cast(m_subId); } /** \details Returns secondary Id as transient object Id. */ TransientType *subIdAsTransient() const { return reinterpret_cast(m_subId); } /** \details Returns secondary Id as numeric index. */ OdUInt32 subIdAsIndex32() const { return static_cast(m_subId); } /** \details Returns secondary Id as numeric index. */ OdUInt64 subIdAsIndex64() const { return m_subId; } /** \details Returns type of index. */ IdType indexType() const { return getIndexType(); } /** \details Sets numeric index. \param nIndex [in] Index value. */ void setIndex(OdUInt32 nIndex) { m_index = nIndex; setIndexType(IdType::kIndex); } /** \details Sets numeric index. \param nIndex [in] Index value. */ void setIndex(OdUInt64 nIndex) { m_index = nIndex; setIndexType(IdType::kIndex); } /** \details Resets numeric index. */ void resetIndex() { m_index = 0; setIndexType(IdType::kNoId); } /** \details Returns numeric index. */ OdUInt32 indexAs32() const { return static_cast(m_index); } /** \details Returns numeric index. */ OdUInt64 indexAs64() const { return m_index; } }; /** \details This template class is a specialization of the OdArray class for OdGsFilerObjectId objects. */ typedef OdArray> OdGsFilerObjectIdArray; /** \details Local cache object Id's processor GsFiler extension. */ class GS_TOOLKIT_EXPORT OdGsFilerExtensionIdSaver : public OdGsFilerExtension { public: /** \details Extended version of abstract substitution processing method. */ struct SubstitutionActuator : public OdGsFilerExtensionSubstitutor::SubstitutionActuator { /** \details Default constructor for the SubstitutionActuator structure. */ SubstitutionActuator() { } /** \details Destructor for the SubstitutionActuator class. */ virtual ~SubstitutionActuator() { } /** \details Self object deletion method. \param pArg [in] Optional argument. */ virtual void selfDelete(const void* /*pArg*/) { } //DOM-IGNORE-BEGIN //"hides overloaded virtual function" fix using OdGsFilerExtensionSubstitutor::SubstitutionActuator::applySubstitution; //DOM-IGNORE-END /** \details Substitution application method. \param pPlace [in] Address where substitution should be applied. \param pValue [in] Address of value to be applied. \param pSetFunc [in] Address application function. \param pArg [in] Optional argument. */ virtual void applySubstitution(void *pPlace, const void *pValue, SetPtrFunc pSetFunc, const void* /*pArg*/) // Compatibility interface with old OdGsFilerExtensionSubstitutor implementation { static_cast(this)->applySubstitution(pPlace, pValue, pSetFunc); } }; /** \details Id writing type. */ enum class WrIdType { kWriteOnly = 0, // Write only without registration. kRequest, // Request object writing. kProcessed // Id writing processed. }; public: /** \details Returns extension type. */ virtual Type type() const { return kIdSaver; } /** \details Cast extension from extensions base class. \param pExt [in] Pointer to base extension interface. */ static OdGsFilerExtensionIdSaver *cast(OdGsFilerExtension *pExt) { return static_cast(pExt); } /** \details Cast extension from extensions base class. \param pExt [in] Pointer to base extension interface. */ static const OdGsFilerExtensionIdSaver *cast(const OdGsFilerExtension *pExt) { return static_cast(pExt); } // Active model storage /** \details Store current OdGsModel for further processing. \param pModel [in] Pointer to current OdGsModel. */ virtual void setActiveModel(OdGsModel *pModel) = 0; /** \details Returns pointer to current OdGsModel if it is set or null elsewhere. */ virtual OdGsModel *activeModel() const = 0; // Temporary objects linker /** \details Store object in internal collection by speicified object Id as key. \param gsId [in] Object Id. \param pObject [in] Object pointer to store. */ virtual void linkObject(const OdGsFilerObjectId &gsId, const OdRxObject *pObject) = 0; /** \details Remove object from internal collection by speicified object Id as key. \param gsId [in] Object Id. */ virtual void unlinkObject(const OdGsFilerObjectId &gsId) = 0; /** \details Checks does object stored under specified object Id key. \param gsId [in] Object Id. \returns true if object exists or false elsewhere. */ virtual bool hasLinkedObject(const OdGsFilerObjectId &gsId) const = 0; /** \details Gets object stored under specified object Id key. \param gsId [in] Object Id. \returns object pointer if object presents or nullptr elsewhere. */ virtual OdRxObject *linkedObject(const OdGsFilerObjectId &gsId) const = 0; // Writer /** \details Register object Id, planned for writing. \param gsId [in] Object Id. \param pLinkedObject [in] Optional linked object, requested for writing. */ virtual void regWrId(OdGsFilerObjectId &gsId, const void *pLinkedObject = nullptr) = 0; /** \details Register object Id, planned for writing. \param gsId [in] Object Id. \param pLinkedObject [in] Optional linked object, requested for writing. \returns processed object Id. */ OdGsFilerObjectId regWrId(const OdGsFilerObjectId &gsId, const void *pLinkedObject = nullptr) { OdGsFilerObjectId procId(gsId); regWrId(procId, pLinkedObject); return procId; } /** \details Returns linked object, requested for writing.. \param gsId [in] Object Id. */ virtual void *linkedWrIdObject(const OdGsFilerObjectId &gsId) const = 0; /** \details Write object Id. \param pFiler [in] Filer object where to write object Id. \param gsId [in] Object Id. \param pLinkedObject [in] Optional linked object, requested for writing. \param wrIdType [in] Type of Id processing. */ virtual void wrId(OdGsFiler *pFiler, const OdGsFilerObjectId &gsId, const void *pLinkedObject = nullptr, WrIdType wrIdType = WrIdType::kRequest) = 0; /** \details Requests writing of specified object Id. \param gsId [in] Object Id. \param pLinkedObject [in] Optional linked object, requested for writing. */ virtual void wrRequest(const OdGsFilerObjectId &gsId, const void *pLinkedObject = nullptr) = 0; /** \details Marks specified object Id as processed. \param gsId [in] Object Id. \param pLinkedObject [in] Optional linked object, requested for writing. */ virtual void processedWrId(const OdGsFilerObjectId &gsId, const void *pLinkedObject = nullptr) = 0; /** \details Checks does specified object Id is written or not. \param gsId [in] Object Id. \param pLinkedObject [in] Optional linked object, requested for writing. \returns true if object Id is writter or false elsewhere. */ virtual bool isWrittenId(const OdGsFilerObjectId &gsId, const void *pLinkedObject = nullptr) const = 0; /** \details Clear written object Id's. \param pFillArray [out] Optional array where requested for writing object Id's should be placed. */ virtual void clearWrIds(OdGsFilerObjectIdArray *pFillArray = nullptr) = 0; // Loader combined with substitutor /** \details Reads object Id from filler object. \param pFiler [in] Filer object. \returns object Id. */ virtual OdGsFilerObjectId rdId(OdGsFiler *pFiler) = 0; /** \details Reads object Id from filler object and substitute runtime object Id at specified address immediately or later. \param pFiler [in] Filer object. \param pPlace [in] Address where read runtime object object Id substitution should be applied. \param size [in] Size of memory place for substitution. \returns object Id. */ virtual OdGsFilerObjectId rdId(OdGsFiler *pFiler, void *pPlace, OdUInt32 size = sizeof(OdIntPtr)) = 0; /** \details Reads object Id from filler object and substitute runtime object Id at specified address immediately or later. \param pFiler [in] Filer object. \param pValue [in] Value where read runtime object object Id substitution should be applied. \returns object Id. */ OdGsFilerObjectId rdId(OdGsFiler *pFiler, OdUInt64 &pValue) { return rdId(pFiler, &pValue, sizeof(OdUInt64)); } /** \details Request object Id reading and apply substitution of runtime object Id at specified address immediately or later. \param gsId [in] Object Id. \param pPlace [in] Address where read runtime object object Id substitution should be applied. \param size [in] Size of memory place for substitution. \param pActiator [in] Optional non-default substitution processing method. \param pArg [in] Optional argument for substitution processing method. */ virtual void requestId(const OdGsFilerObjectId &gsId, void *pPlace, OdUInt32 size = sizeof(OdIntPtr), SubstitutionActuator *pActuator = nullptr, const void *pArg = nullptr) = 0; /** \details Register readed object Id and provide value for requested substitutions. \param gsId [in] Object Id. \param pValue [in] Address of substitution value. \param size [in] Size of substitution value. */ virtual void registerId(const OdGsFilerObjectId &gsId, const void *pValue, OdUInt32 size) = 0; /** \details Register readed object Id and provide value for requested substitutions. \param gsId [in] Object Id. \param pValue [in] Substitution value as OdUInt64. */ void registerId(const OdGsFilerObjectId &gsId, OdUInt64 pValue) { registerId(gsId, &pValue, sizeof(OdUInt64)); } /** \details Register readed object Id and provide value for requested substitutions. \param gsId [in] Object Id. \param pValue [in] Substitution value as pointer. */ void registerId(const OdGsFilerObjectId &gsId, const void *pValue) { registerId(gsId, &pValue, sizeof(OdIntPtr)); } /** \details Checks does any additional object Id's reading requested or not. \param pFillArray [out] Optional array where requested for reading object Id's should be placed. \returns true if any additional object Id's reading requested or false elsewhere. */ virtual bool referencedIds(OdGsFilerObjectIdArray *pFillArray = nullptr) = 0; }; /** \details Local cache loading reactor. */ class GS_TOOLKIT_EXPORT OdGsFilerLoadingReactor { public: struct GsLoadContext { void *m_pContext; void *m_pObject; }; public: /** \details Process loading of requested graphics system object. \param gsId [in] Object Id. \param pContext [in] Internal loading context pointer. \returns true if reading success or false elsewhere. */ virtual bool loadGsObject(const OdGsFilerObjectId &gsId, const void *pContext) = 0; }; /** \details Local cache loading reactor GsFiler extension. */ class GS_TOOLKIT_EXPORT OdGsFilerExtensionLoadingReactor : public OdGsFilerExtension { public: /** \details Returns extension type. */ virtual Type type() const { return kLoadingReactor; } /** \details Cast extension from extensions base class. \param pExt [in] Pointer to base extension interface. */ static OdGsFilerExtensionLoadingReactor *cast(OdGsFilerExtension *pExt) { return static_cast(pExt); } /** \details Cast extension from extensions base class. \param pExt [in] Pointer to base extension interface. */ static const OdGsFilerExtensionLoadingReactor *cast(const OdGsFilerExtension *pExt) { return static_cast(pExt); } /** \details Setup local cache loading reactor. \param pReactor [in] Local cache loading reactor pointer. */ virtual void setupReactor(OdGsFilerLoadingReactor *pReactor) = 0; /** \details Returns local cache loading reactor. */ virtual OdGsFilerLoadingReactor *reactor() const = 0; /** \details Process loading of requested graphics system object. \param gsId [in] Object Id. \param pContext [in] Internal loading context pointer. \returns true if reading success or false elsewhere. */ virtual bool loadGsObject(const OdGsFilerObjectId &gsId, const void *pContext) = 0; }; /** \details Virtual filer interface which is should be implemented on graphics system device side for local cache storing support. */ class GS_TOOLKIT_EXPORT OdGsFilerDeviceInterface { public: /** \details Represents a file version. */ enum Version { kV1 = 100, // First version. kVLast = kV1 // Last version. }; public: /** \details Prepare OdGsFiler for reading or writing. reads or writes file header. \param pFiler [in] Filer object. \param pLoadingReactor [in] Loading reactor object or null. In case if loading reactor specified - loading process initiated, or writing process elsewhere. \returns true if reading or writing success or false elsewhere. */ virtual bool prepareGsFiler(OdGsFiler* /*pFiler*/, OdGsFilerLoadingReactor* /*pLoadingReactor*/ = nullptr) { return false; } /** \details Flush OdGsFiler after reading or writing process. Clears all collections, caches and extensions. \param pFiler [in] Filer object. */ virtual void flushGsFiler(OdGsFiler* /*pFiler*/) {} /** \details Collect list of save objects for specified database object Id. \param pFiler [in] Filer object. \param pObject [in] Database object Id. \param pModel [in] Actual graphics system model. \param objectIds [out] Result objects list. \returns true if object could be written or false elsewhere. */ virtual bool prepareSaveObjects(OdGsFiler* /*pFiler*/, OdDbStub* /*pObject*/, OdGsModel* /*pModel*/, OdGsFilerObjectIdArray& /*objectIds*/) { return false; } /** \details Stores object into filer object. \param pFiler [in] Filer object. \param objectId [in] Object Id. \param objectIds [out] List of additional objects requested for save. \returns true if object written or false elsewhere. */ virtual bool saveObject(OdGsFiler* /*pFiler*/, const OdGsFilerObjectId& /*objectId*/, OdGsFilerObjectIdArray& /*objectIds*/) { return false; } /** \details Loads object from filer object. \param pFiler [in] Filer object. \param objectId [in] Object Id. \param objectIds [out] List of additional objects requested for read. \returns true if object loaded or false elsewhere. */ virtual bool loadObject(OdGsFiler* /*pFiler*/, const OdGsFilerObjectId& /*objectId*/, OdGsFilerObjectIdArray& /*objectIds*/, const void* /*pContext*/) { return false; } /** \details Loads referenced object from filer object. \param pFiler [in] Filer object. \param objectId [in] Referenced object Id. \param objectIds [out] List of additional objects requested for read. \returns true if referenced object loaded or false elsewhere. */ virtual bool loadReferenced(OdGsFiler* /*pFiler*/, const OdGsFilerObjectId& /*objectId*/, OdGsFilerObjectIdArray& /*objectIds*/, const void* /*pContext*/) { return false; } }; /** \details State saving OdGsFiler extension. */ class GS_TOOLKIT_EXPORT OdGsFilerGSS : public OdGsFiler { public: /** \details Represents a file section. */ enum Section { kEOFSection = -1, // EOF // V1 sections kHeaderSection = 0, // File header kDatabaseLinkSection, // Database linkage section kGsModuleSection, // Gs Module section kDeviceSection, // Gs Device section kClientDeviceSection, // Client Gs Device section kViewSection, // Gs View section kClientViewSection, // Client Gs View section kModelSection, // Gs Model section kClientModelSection, // Client Gs Model section kNodeSection, // Gs Node section kClientNodeSection, // Client Gs Node section kMetafileSection, // Gs Metafile section kClientMetafileSection, // Client Gs Metafile section kClientMaterialSection, // Client Gs Material section kBlockRefImplSection, // Block reference cache implementation section kLinkedDeviceSection, // Linked Gs Device section kRenditionSection, // Client visual rendition section // V2 sections kRuntimeChangesSection // Runtime Gs modifications section }; /** \details Represents a file version. */ enum Version { kV1 = 100, kV2 = 200, kVLast = kV2 }; public: // Attach stream and initiate read/write process /** \details Attaches a specified stream and opens it for read and potentially write operations. \param pStream [in] Pointer to a stream to set. \param bWrite [in] Flag that specifies whether to open stream for write operations. */ virtual bool setStream(OdStreamBuf *pStream, bool bWrite = false) = 0; /** \details Retrieves a smart pointer to current stream. */ virtual OdStreamBufPtr getStream() const = 0; // Setup working database /** \details Sets a specified database. \param pDb [in] Pointer to a database to set. */ virtual void setDatabase(const OdDbBaseDatabase *pDb) = 0; /** \details Retrieves a pointer to a database that is used for this stream. */ virtual OdDbBaseDatabase *getDatabase() const = 0; // Filer type control /** \details Retrieves type of this filer. */ virtual FilerType filerType() const { return FilerType::kCacheStateSaver; } // Database hash control /** \details Writes database hash. \param pDb [in] Pointer to a database. */ virtual void wrDbHash(const OdDbBaseDatabase *pDb) = 0; /** \details Checks readed database hash. \param pDb [in] Pointer to a database. \returns true if hashes same or false elsewhere. */ virtual bool checkDbHash(const OdDbBaseDatabase *pDb) = 0; // Setup sections for writing /** \details Sets sections for write operations. \param nSections [in] Sections to set for writing. */ virtual void setWriteSections(OdUInt64 nSections) = 0; /** \details Sets the specified section for write operations. \param section [in] Section to set. \param bSet [in] Flag that specifies whether to write to the section. */ virtual void setWriteSection(Section section, bool bSet) = 0; /** \details Checks whether the specified section is opened for write operations. \param section [in] Section to check. \returns true if write operations are enabled for the section, false otherwise. */ virtual bool isWriteSection(Section section) const = 0; // Setup sections for reading /** \details Sets sections for read operations. \param nSections [in] Sections to set for reading. */ virtual void setReadSections(OdUInt64 nSections) = 0; /** \details Sets the specified section for read operations. \param section [in] Section to set. \param bSet [in] Flag that specifies whether to read the section. */ virtual void setReadSection(Section section, bool bSet) = 0; /** \details Checks whether the specified section is opened for read operations. \param section [in] Section to check. \returns true if read operations are enabled for the section, false otherwise. */ virtual bool isReadSection(Section section) const = 0; // Section writing /** \details Begins writing to the section. \param section [in] File section. */ virtual void wrSectionBegin(Section section) = 0; /** \details Ends writing to the section. \param section [in] File section. */ virtual void wrSectionEnd(Section section) = 0; /** \details Writes the end of file (EOF) section. */ virtual void wrEOFSection() = 0; // Section reading /** \details Reads sections one by one and returns a current section for which read access is not enabled or the EOF section. */ virtual Section rdSection() const = 0; /** \details Retrieves the current section. */ virtual Section curSection() const = 0; /** \details Skips the current section and makes the following section current. */ virtual void skipSection() const = 0; /** \details Return to the previous section and makes it current. */ virtual void rdBackSection() const = 0; /** \details Checks whether currently read section is the end of file (EOF) section. \returns true if current section is EOF section, false otherwise. */ virtual bool checkEOF() const = 0; // Substitutions processing /** \details Substitutions processor interface. \returns substitutions processor interface. */ virtual OdGsFilerExtensionSubstitutor::Substitutor *subst() const = 0; /** \details Apply collected substitutions. \param bClear [in] Clear substitutions collection after applying. */ virtual void makeSubstitutions(bool bClear = true) const = 0; /** \details Returns substitutions processor interface as OdRxObject pointer. */ virtual OdRxObjectPtr getSubstitutor() const = 0; /** \details Sets external substitions processor interface. \param pSubst [in] Substitutions processor interface pointer. */ virtual void setSubstitutor(OdRxObject *pSubst) = 0; // Arbitrary data /** \details Sets arbitrary data. \param pName [in] Dictionary entry name. \param pObject [in] Object which should be stored at specified name. */ virtual void setArbitraryData(const OdChar *pName, OdRxObject *pObject) = 0; /** \details Returns arbitrary data. \param pName [in] Dictionary entry name. \returns stored object pointer or null object pointer if name not exists. */ virtual OdRxObjectPtr getArbitraryData(const OdChar *pName) const = 0; /** \details Checks does arbitrary data registered. \param pName [in] Dictionary entry name. \returns true if specified name exists or false elsewhere. */ virtual bool hasArbitraryData(const OdChar *pName) const = 0; /** \details Clears arbitrary data dictionary. */ virtual void clearArbitraryData() = 0; // Pointers registration /** \details Register pointer. \param pPtr [in] Pointer which should be registered. */ virtual void registerPtr(const void *pPtr) = 0; /** \details Unregister pointer. \param pPtr [in] Pointer which should be unregistered. */ virtual void unregisterPtr(const void *pPtr) = 0; /** \details Checks does specified pointer registered. \param pPtr [in] Pointer to be checked. \returns true if specified pointer registered or false elsewhere. */ virtual bool isPtrRegistered(const void *pPtr) const = 0; /** \details Clears registered pointers collection. */ virtual void clearRegisteredPtrs() = 0; /** \details Cast extended filer from base filer interface. \param pFiler [in] Pointer to base filer interface. */ static OdGsFilerGSS *cast(OdGsFiler *pFiler) { return static_cast(pFiler); } /** \details Cast extended filer from base filer interface. \param pFiler [in] Pointer to base filer interface. */ static const OdGsFilerGSS *cast(const OdGsFiler *pFiler) { return static_cast(pFiler); } /** \details Creates a filer object and returns a smart pointer to it. \param pStream [in] Pointer to a stream buffer. \param bForWrite [in] Flag that specifies whether to open filer for write operations. \param pDb [in] Pointer to a database. \param nVersion [in] File version. */ static OdSmartPtr createObject(OdStreamBuf *pStream, bool bForWrite, const OdDbBaseDatabase *pDb, OdUInt32 nVersion = kVLast); }; /** \details A data type that represents a smart pointer to an object. */ typedef OdSmartPtr OdGsFilerGSSPtr; /** \details OdGsFilerGSS creation protocol extension. */ class GS_TOOLKIT_EXPORT OdGsFilerCreatorPE : public OdRxObject { public: ODRX_DECLARE_MEMBERS(OdGsFilerCreatorPE); public: /** \details Creates a GS filer object and returns a smart pointer to it. \param pStream [in] Pointer to a stream buffer. \param bForWrite [in] Flag that specifies whether to open filer for write operations. \param pDb [in] Pointer to a database. */ virtual OdGsFilerPtr createGsFiler(OdStreamBuf *pStream, bool bForWrite, const OdDbBaseDatabase *pDb) = 0; }; /** \details A data type that represents a smart pointer to an object. */ typedef OdSmartPtr OdGsFilerCreatorPEPtr; /** \details Database hash computation protocol extension. */ class GS_TOOLKIT_EXPORT OdGsFilerDbHashPE : public OdRxObject { public: ODRX_DECLARE_MEMBERS(OdGsFilerDbHashPE); public: /** \details Computes database hash. \param pDb [in] Pointer to a database. \returns database hash. */ virtual OdBinaryData computeDbHash(const OdDbBaseDatabase *pDb) = 0; }; /** \details A data type that represents a smart pointer to an object. */ typedef OdSmartPtr OdGsFilerDbHashPEPtr; #include "TD_PackPop.h" #endif // __OD_GS_FILER_H__