Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:28:26

0001 // Created on: 1993-02-02
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Interface_GeneralModule_HeaderFile
0018 #define _Interface_GeneralModule_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Standard_Transient.hxx>
0024 #include <Standard_Integer.hxx>
0025 class Interface_InterfaceModel;
0026 class Interface_EntityIterator;
0027 class Interface_ShareTool;
0028 class Interface_Check;
0029 class Interface_CopyTool;
0030 class TCollection_HAsciiString;
0031 
0032 //! This class defines general services, which must be provided
0033 //! for each type of Entity (i.e. of Transient Object processed
0034 //! by an Interface) : Shared List, Check, Copy, Delete, Category
0035 //!
0036 //! To optimise processing (e.g. firstly bind an Entity to a Module
0037 //! then calls Module), each recognized Entity Type corresponds
0038 //! to a Case Number, determined by the Protocol each class of
0039 //! GeneralModule belongs to.
0040 class Interface_GeneralModule : public Standard_Transient
0041 {
0042 
0043 public:
0044   //! Specific filling of the list of Entities shared by an Entity
0045   //! <ent>, according a Case Number <CN> (formerly computed by
0046   //! CaseNum), considered in the context of a Model <model>
0047   //! Default calls FillSharedCase (i.e., ignores the model)
0048   //! Can be redefined to use the model for working
0049   Standard_EXPORT virtual void FillShared(const occ::handle<Interface_InterfaceModel>& model,
0050                                           const int                                    CN,
0051                                           const occ::handle<Standard_Transient>&       ent,
0052                                           Interface_EntityIterator&                    iter) const;
0053 
0054   //! Specific filling of the list of Entities shared by an Entity
0055   //! <ent>, according a Case Number <CN> (formerly computed by
0056   //! CaseNum). Can use the internal utility method Share, below
0057   Standard_EXPORT virtual void FillSharedCase(const int                              CN,
0058                                               const occ::handle<Standard_Transient>& ent,
0059                                               Interface_EntityIterator& iter) const = 0;
0060 
0061   //! Adds an Entity to a Shared List (uses GetOneItem on <iter>)
0062   Standard_EXPORT void Share(Interface_EntityIterator&              iter,
0063                              const occ::handle<Standard_Transient>& shared) const;
0064 
0065   //! List the Implied References of <ent> considered in the context
0066   //! of a Model <model> : i.e. the Entities which are Referenced
0067   //! while not considered as Shared (not copied if <ent> is,
0068   //! references not renewed by CopyCase but by ImpliedCase, only
0069   //! if referenced Entities have been Copied too)
0070   //! FillShared + ListImplied give the complete list of References
0071   //! Default calls ListImpliedCase (i.e. ignores the model)
0072   //! Can be redefined to use the model for working
0073   Standard_EXPORT virtual void ListImplied(const occ::handle<Interface_InterfaceModel>& model,
0074                                            const int                                    CN,
0075                                            const occ::handle<Standard_Transient>&       ent,
0076                                            Interface_EntityIterator&                    iter) const;
0077 
0078   //! List the Implied References of <ent> (see above)
0079   //! are Referenced while not considered as Shared (not copied if
0080   //! <ent> is, references not renewed by CopyCase but by
0081   //! ImpliedCase, only if referenced Entities have been Copied too)
0082   //! FillSharedCase + ListImpliedCase give the complete list of
0083   //! Referenced Entities
0084   //! The provided default method does nothing (Implied References
0085   //! are specific of a little amount of Entity Classes).
0086   Standard_EXPORT virtual void ListImpliedCase(const int                              CN,
0087                                                const occ::handle<Standard_Transient>& ent,
0088                                                Interface_EntityIterator&              iter) const;
0089 
0090   //! Specific Checking of an Entity <ent>
0091   //! Can check context queried through a ShareTool, as required
0092   Standard_EXPORT virtual void CheckCase(const int                              CN,
0093                                          const occ::handle<Standard_Transient>& ent,
0094                                          const Interface_ShareTool&             shares,
0095                                          occ::handle<Interface_Check>&          ach) const = 0;
0096 
0097   //! Specific answer to the question "is Copy properly implemented"
0098   //! Remark that it should be in phase with the implementation of
0099   //! NewVoid+CopyCase/NewCopyCase
0100   //! Default returns always False, can be redefined
0101   Standard_EXPORT virtual bool CanCopy(const int                              CN,
0102                                        const occ::handle<Standard_Transient>& ent) const;
0103 
0104   //! Dispatches an entity
0105   //! Returns True if it works by copy, False if it just duplicates
0106   //! the starting Handle
0107   //!
0108   //! Dispatching means producing a new entity, image of the
0109   //! starting one, in order to be put into a new Model, this Model
0110   //! being itself the result of a dispatch from an original Model
0111   //!
0112   //! According to the cases, dispatch can either
0113   //! * just return <entto> as equating <entfrom>
0114   //! -> the new model designates the starting entity : it is
0115   //! lighter, but the dispatched entity being shared might not be
0116   //! modified for dispatch
0117   //! * copy <entfrom> to <entto>
0118   //! by calling NewVoid+CopyCase (two steps) or NewCopiedCase (1)
0119   //! -> the dispatched entity is a COPY, hence it can be modified
0120   //!
0121   //! The provided default just duplicates the handle without
0122   //! copying, then returns False. Can be redefined
0123   Standard_EXPORT virtual bool Dispatch(const int                              CN,
0124                                         const occ::handle<Standard_Transient>& entfrom,
0125                                         occ::handle<Standard_Transient>&       entto,
0126                                         Interface_CopyTool&                    TC) const;
0127 
0128   //! Creates a new void entity <entto> according to a Case Number
0129   //! This entity remains to be filled, by reading from a file or
0130   //! by copying from another entity of same type (see CopyCase)
0131   Standard_EXPORT virtual bool NewVoid(const int                        CN,
0132                                        occ::handle<Standard_Transient>& entto) const = 0;
0133 
0134   //! Specific Copy ("Deep") from <entfrom> to <entto> (same type)
0135   //! by using a CopyTool which provides its working Map.
0136   //! Use method Transferred from CopyTool to work
0137   Standard_EXPORT virtual void CopyCase(const int                              CN,
0138                                         const occ::handle<Standard_Transient>& entfrom,
0139                                         const occ::handle<Standard_Transient>& entto,
0140                                         Interface_CopyTool&                    TC) const = 0;
0141 
0142   //! Specific operator (create+copy) defaulted to do nothing.
0143   //! It can be redefined : When it is not possible to work in two
0144   //! steps (NewVoid then CopyCase). This can occur when there is
0145   //! no default constructor : hence the result <entto> must be
0146   //! created with an effective definition.
0147   //! Remark : if NewCopiedCase is defined, CopyCase has nothing to do
0148   //! Returns True if it has produced something, false else
0149   Standard_EXPORT virtual bool NewCopiedCase(const int                              CN,
0150                                              const occ::handle<Standard_Transient>& entfrom,
0151                                              occ::handle<Standard_Transient>&       entto,
0152                                              Interface_CopyTool&                    TC) const;
0153 
0154   //! Specific Copying of Implied References
0155   //! A Default is provided which does nothing (must current case !)
0156   //! Already copied references (by CopyFrom) must remain unchanged
0157   //! Use method Search from CopyTool to work
0158   Standard_EXPORT virtual void RenewImpliedCase(const int                              CN,
0159                                                 const occ::handle<Standard_Transient>& entfrom,
0160                                                 const occ::handle<Standard_Transient>& entto,
0161                                                 const Interface_CopyTool&              TC) const;
0162 
0163   //! Prepares an entity to be deleted. What does it mean :
0164   //! Basically, any class of entity may define its own destructor
0165   //! By default, it does nothing but calling destructors on fields
0166   //! With the Memory Manager, it is useless to call destructor,
0167   //! it is done automatically when the Handle is nullified(cleared)
0168   //! BUT this is ineffective in looping structures (whatever these
0169   //! are "Implied" references or not).
0170   //!
0171   //! THUS : if no loop may appear in definitions, a class which
0172   //! inherits from TShared is correctly managed by automatic way
0173   //! BUT if there can be loops (or simply back pointers), they must
0174   //! be broken, for instance by clearing fields of one of the nodes
0175   //! The default does nothing, to be redefined if a loop can occur
0176   //! (Implied generally requires WhenDelete, but other cases can
0177   //! occur)
0178   //!
0179   //! Warning : <dispatched> tells if the entity to be deleted has been
0180   //! produced by Dispatch or not. Hence WhenDelete must be in
0181   //! coherence with Dispatch
0182   //! Dispatch can either copy or not.
0183   //! If it copies the entity, this one should be deleted
0184   //! If it doesn't (i.e. duplicates the handle) nothing to do
0185   //!
0186   //! If <dispatch> is False, normal deletion is to be performed
0187   Standard_EXPORT virtual void WhenDeleteCase(const int                              CN,
0188                                               const occ::handle<Standard_Transient>& ent,
0189                                               const bool dispatched) const;
0190 
0191   //! Returns a category number which characterizes an entity
0192   //! Category Numbers are managed by the class Category
0193   //! <shares> can be used to evaluate this number in the context
0194   //! Default returns 0 which means "unspecified"
0195   Standard_EXPORT virtual int CategoryNumber(const int                              CN,
0196                                              const occ::handle<Standard_Transient>& ent,
0197                                              const Interface_ShareTool&             shares) const;
0198 
0199   //! Determines if an entity brings a Name (or widerly, if a Name
0200   //! can be attached to it, through the ShareTool
0201   //! By default, returns a Null Handle (no name can be produced)
0202   //! Can be redefined
0203   //!
0204   //! Warning : While this string may be edited on the spot, if it is a read
0205   //! field, the returned value must be copied before.
0206   Standard_EXPORT virtual occ::handle<TCollection_HAsciiString> Name(
0207     const int                              CN,
0208     const occ::handle<Standard_Transient>& ent,
0209     const Interface_ShareTool&             shares) const;
0210 
0211   DEFINE_STANDARD_RTTIEXT(Interface_GeneralModule, Standard_Transient)
0212 };
0213 
0214 #endif // _Interface_GeneralModule_HeaderFile