Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-04 08:33:22

0001 // Created on: 2004-11-23
0002 // Created by: Pavel TELKOV
0003 // Copyright (c) 2004-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 // The original implementation Copyright: (C) RINA S.p.A
0017 
0018 #ifndef TObj_TReference_HeaderFile
0019 #define TObj_TReference_HeaderFile
0020 
0021 #include <TDF_Attribute.hxx>
0022 #include <TDF_Label.hxx>
0023 
0024 class TObj_Object;
0025 class Standard_GUID;
0026 
0027 /**
0028  * Attribute for storing references to the objects which implement
0029  * TObj_Object interface in the OCAF tree.
0030  * Its persistency mechanism provides transparent method for storing
0031  * cross-model references.
0032  * Each reference, when created, registers itself in the referred object,
0033  * to support back references
0034  */
0035 
0036 class TObj_TReference : public TDF_Attribute
0037 {
0038 public:
0039   //! Standard methods of OCAF attribute
0040 
0041   //! Empty constructor
0042   Standard_EXPORT TObj_TReference();
0043 
0044   //! This method is used in implementation of ID()
0045   static Standard_EXPORT const Standard_GUID& GetID();
0046 
0047   //! Returns the ID of TObj_TReference attribute.
0048   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
0049 
0050 public:
0051   //! Method for create TObj_TReference object
0052 
0053   //! Creates reference on TDF_Label <theLabel> to the object <theObject> and
0054   //! creates backreference from the object <theObject> to <theMaster> one.
0055   static Standard_EXPORT Handle(TObj_TReference) Set(const TDF_Label&           theLabel,
0056                                                      const Handle(TObj_Object)& theObject,
0057                                                      const Handle(TObj_Object)& theMaster);
0058 
0059 public:
0060   //! Methods for setting and obtaining referenced object
0061 
0062   //! Sets the reference to the theObject
0063   Standard_EXPORT void Set(const Handle(TObj_Object)& theObject, const TDF_Label& theMasterLabel);
0064 
0065   //! Sets the reference to the theObject at indicated Label.
0066   //! It is method for persistent only. Don`t use anywhere else.
0067   Standard_EXPORT void Set(const TDF_Label& theLabel, const TDF_Label& theMasterLabel);
0068 
0069   //! Returns the referenced theObject
0070   Standard_EXPORT Handle(TObj_Object) Get() const;
0071 
0072   //! Returns the Label of master object.
0073   TDF_Label GetMasterLabel() const { return myMasterLabel; }
0074 
0075   //! Returns the referred label.
0076   TDF_Label GetLabel() const { return myLabel; }
0077 
0078 public:
0079   //! Redefined OCAF abstract methods
0080 
0081   //! Returns an new empty TObj_TReference attribute. It is used by the
0082   //! copy algorithm.
0083   Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
0084 
0085   //! Restores the backuped contents from <theWith> into this one. It is used
0086   //! when aborting a transaction.
0087   Standard_EXPORT void Restore(const Handle(TDF_Attribute)& theWith) Standard_OVERRIDE;
0088 
0089   //! This method is used when copying an attribute from a source structure
0090   //! into a target structure.
0091   Standard_EXPORT void Paste(const Handle(TDF_Attribute)&       theInto,
0092                              const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
0093 
0094   //! Remove back references of it reference if it is in other document.
0095   virtual Standard_EXPORT void BeforeForget() Standard_OVERRIDE;
0096 
0097   //! It is necessary for tranzaction mechanism (Undo/Redo).
0098   virtual Standard_EXPORT Standard_Boolean
0099     BeforeUndo(const Handle(TDF_AttributeDelta)& theDelta,
0100                const Standard_Boolean            isForced = Standard_False) Standard_OVERRIDE;
0101 
0102   //! It is necessary for tranzaction mechanism (Undo/Redo).
0103   virtual Standard_EXPORT Standard_Boolean
0104     AfterUndo(const Handle(TDF_AttributeDelta)& theDelta,
0105               const Standard_Boolean            isForced = Standard_False) Standard_OVERRIDE;
0106 
0107   //! Check if back reference exists for reference.
0108   virtual Standard_EXPORT void AfterResume() Standard_OVERRIDE;
0109 
0110   //! Called after retrieval reference from file.
0111   virtual Standard_EXPORT Standard_Boolean
0112     AfterRetrieval(const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE;
0113 
0114 private:
0115   //! Fields
0116   TDF_Label myLabel;       //!< Label that indicate referenced object
0117   TDF_Label myMasterLabel; //!< Label of object that have this reference.
0118 
0119 public:
0120   //! CASCADE RTTI
0121   DEFINE_STANDARD_RTTIEXT(TObj_TReference, TDF_Attribute)
0122 };
0123 
0124 //! Define handle class for TObj_TReference
0125 DEFINE_STANDARD_HANDLE(TObj_TReference, TDF_Attribute)
0126 
0127 #endif
0128 
0129 #ifdef _MSC_VER
0130 #pragma once
0131 #endif