Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-29 09:18:05

0001 // Copyright (c) 2020 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _BinMDF_DerivedDriver_HeaderFile
0015 #define _BinMDF_DerivedDriver_HeaderFile
0016 
0017 #include <BinMDF_ADriver.hxx>
0018 
0019 //! A universal driver for the attribute that inherits another attribute with
0020 //! ready to used persistence mechanism implemented (already has a driver to store/retrieve).
0021 class BinMDF_DerivedDriver : public BinMDF_ADriver
0022 {
0023   DEFINE_STANDARD_RTTIEXT(BinMDF_DerivedDriver, BinMDF_ADriver)
0024 public:
0025   //! Creates a derivative persistence driver for theDerivative attribute by reusage of
0026   //! theBaseDriver
0027   //! @param theDerivative an instance of the attribute, just created, detached from any label
0028   //! @param theBaseDriver a driver of the base attribute, called by Paste methods
0029   BinMDF_DerivedDriver(const occ::handle<TDF_Attribute>&  theDerivative,
0030                        const occ::handle<BinMDF_ADriver>& theBaseDriver)
0031       : BinMDF_ADriver(theBaseDriver->MessageDriver()),
0032         myDerivative(theDerivative),
0033         myBaseDirver(theBaseDriver)
0034   {
0035   }
0036 
0037   //! Creates a new instance of the derivative attribute
0038   occ::handle<TDF_Attribute> NewEmpty() const override { return myDerivative->NewEmpty(); }
0039 
0040   //! Reuses the base driver to read the base fields
0041   bool Paste(const BinObjMgt_Persistent&       theSource,
0042              const occ::handle<TDF_Attribute>& theTarget,
0043              BinObjMgt_RRelocationTable&       theRelocTable) const override
0044   {
0045     bool aResult = myBaseDirver->Paste(theSource, theTarget, theRelocTable);
0046     // clang-format off
0047     theTarget->AfterRetrieval(); // to allow synchronization of the derived attribute with the base content
0048     // clang-format on
0049     return aResult;
0050   }
0051 
0052   //! Reuses the base driver to store the base fields
0053   void Paste(const occ::handle<TDF_Attribute>&                        theSource,
0054              BinObjMgt_Persistent&                                    theTarget,
0055              NCollection_IndexedMap<occ::handle<Standard_Transient>>& theRelocTable) const override
0056   {
0057     myBaseDirver->Paste(theSource, theTarget, theRelocTable);
0058   }
0059 
0060 protected:
0061   occ::handle<TDF_Attribute>  myDerivative; //!< the derivative attribute that inherits the base
0062   occ::handle<BinMDF_ADriver> myBaseDirver; //!< the base attribute driver to be reused here
0063 };
0064 
0065 #endif