1 // Created on: 1993-02-02
2 // Created by: Christian CAILLET
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Interface_GeneralModule_HeaderFile
18 #define _Interface_GeneralModule_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Transient.hxx>
24 #include <Standard_Integer.hxx>
25 #include <Standard_Boolean.hxx>
26 class Interface_InterfaceModel;
27 class Interface_EntityIterator;
28 class Interface_ShareTool;
29 class Interface_Check;
30 class Interface_CopyTool;
31 class TCollection_HAsciiString;
34 class Interface_GeneralModule;
35 DEFINE_STANDARD_HANDLE(Interface_GeneralModule, Standard_Transient)
37 //! This class defines general services, which must be provided
38 //! for each type of Entity (i.e. of Transient Object processed
39 //! by an Interface) : Shared List, Check, Copy, Delete, Category
41 //! To optimise processing (e.g. firstly bind an Entity to a Module
42 //! then calls Module), each recognized Entity Type corresponds
43 //! to a Case Number, determined by the Protocol each class of
44 //! GeneralModule belongs to.
45 class Interface_GeneralModule : public Standard_Transient
51 //! Specific filling of the list of Entities shared by an Entity
52 //! <ent>, according a Case Number <CN> (formerly computed by
53 //! CaseNum), considered in the context of a Model <model>
54 //! Default calls FillSharedCase (i.e., ignores the model)
55 //! Can be redefined to use the model for working
56 Standard_EXPORT virtual void FillShared (const Handle(Interface_InterfaceModel)& model, const Standard_Integer CN, const Handle(Standard_Transient)& ent, Interface_EntityIterator& iter) const;
58 //! Specific filling of the list of Entities shared by an Entity
59 //! <ent>, according a Case Number <CN> (formerly computed by
60 //! CaseNum). Can use the internal utility method Share, below
61 Standard_EXPORT virtual void FillSharedCase (const Standard_Integer CN, const Handle(Standard_Transient)& ent, Interface_EntityIterator& iter) const = 0;
63 //! Adds an Entity to a Shared List (uses GetOneItem on <iter>)
64 Standard_EXPORT void Share (Interface_EntityIterator& iter, const Handle(Standard_Transient)& shared) const;
66 //! List the Implied References of <ent> considered in the context
67 //! of a Model <model> : i.e. the Entities which are Referenced
68 //! while not considered as Shared (not copied if <ent> is,
69 //! references not renewed by CopyCase but by ImpliedCase, only
70 //! if referenced Entities have been Copied too)
71 //! FillShared + ListImplied give the complete list of References
72 //! Default calls ListImpliedCase (i.e. ignores the model)
73 //! Can be redefined to use the model for working
74 Standard_EXPORT virtual void ListImplied (const Handle(Interface_InterfaceModel)& model, const Standard_Integer CN, const Handle(Standard_Transient)& ent, Interface_EntityIterator& iter) const;
76 //! List the Implied References of <ent> (see above)
77 //! are Referenced while not considered as Shared (not copied if
78 //! <ent> is, references not renewed by CopyCase but by
79 //! ImpliedCase, only if referenced Entities have been Copied too)
80 //! FillSharedCase + ListImpliedCase give the complete list of
81 //! Referenced Entities
82 //! The provided default method does nothing (Implied References
83 //! are specific of a little amount of Entity Classes).
84 Standard_EXPORT virtual void ListImpliedCase (const Standard_Integer CN, const Handle(Standard_Transient)& ent, Interface_EntityIterator& iter) const;
86 //! Specific Checking of an Entity <ent>
87 //! Can check context queried through a ShareTool, as required
88 Standard_EXPORT virtual void CheckCase (const Standard_Integer CN, const Handle(Standard_Transient)& ent, const Interface_ShareTool& shares, Handle(Interface_Check)& ach) const = 0;
90 //! Specific answer to the question "is Copy properly implemented"
91 //! Remark that it should be in phase with the implementation of
92 //! NewVoid+CopyCase/NewCopyCase
93 //! Default returns always False, can be redefined
94 Standard_EXPORT virtual Standard_Boolean CanCopy (const Standard_Integer CN, const Handle(Standard_Transient)& ent) const;
96 //! Dispatches an entity
97 //! Returns True if it works by copy, False if it just duplicates
98 //! the starting Handle
100 //! Dispatching means producing a new entity, image of the
101 //! starting one, in order to be put into a new Model, this Model
102 //! being itself the result of a dispatch from an original Model
104 //! According to the cases, dispatch can either
105 //! * just return <entto> as equating <entfrom>
106 //! -> the new model designates the starting entity : it is
107 //! lighter, but the dispatched entity being shared might not be
108 //! modified for dispatch
109 //! * copy <entfrom> to <entto>
110 //! by calling NewVoid+CopyCase (two steps) or NewCopiedCase (1)
111 //! -> the dispatched entity is a COPY, hence it can be modified
113 //! The provided default just duplicates the handle without
114 //! copying, then returns False. Can be redefined
115 Standard_EXPORT virtual Standard_Boolean Dispatch (const Standard_Integer CN, const Handle(Standard_Transient)& entfrom, Handle(Standard_Transient)& entto, Interface_CopyTool& TC) const;
117 //! Creates a new void entity <entto> according to a Case Number
118 //! This entity remains to be filled, by reading from a file or
119 //! by copying from another entity of same type (see CopyCase)
120 Standard_EXPORT virtual Standard_Boolean NewVoid (const Standard_Integer CN, Handle(Standard_Transient)& entto) const = 0;
122 //! Specific Copy ("Deep") from <entfrom> to <entto> (same type)
123 //! by using a CopyTool which provides its working Map.
124 //! Use method Transferred from CopyTool to work
125 Standard_EXPORT virtual void CopyCase (const Standard_Integer CN, const Handle(Standard_Transient)& entfrom, const Handle(Standard_Transient)& entto, Interface_CopyTool& TC) const = 0;
127 //! Specific operator (create+copy) defaulted to do nothing.
128 //! It can be redefined : When it is not possible to work in two
129 //! steps (NewVoid then CopyCase). This can occur when there is
130 //! no default constructor : hence the result <entto> must be
131 //! created with an effective definition.
132 //! Remark : if NewCopiedCase is defined, CopyCase has nothing to do
133 //! Returns True if it has produced something, false else
134 Standard_EXPORT virtual Standard_Boolean NewCopiedCase (const Standard_Integer CN, const Handle(Standard_Transient)& entfrom, Handle(Standard_Transient)& entto, Interface_CopyTool& TC) const;
136 //! Specific Copying of Implied References
137 //! A Default is provided which does nothing (must current case !)
138 //! Already copied references (by CopyFrom) must remain unchanged
139 //! Use method Search from CopyTool to work
140 Standard_EXPORT virtual void RenewImpliedCase (const Standard_Integer CN, const Handle(Standard_Transient)& entfrom, const Handle(Standard_Transient)& entto, const Interface_CopyTool& TC) const;
142 //! Prepares an entity to be deleted. What does it mean :
143 //! Basically, any class of entity may define its own destructor
144 //! By default, it does nothing but calling destructors on fields
145 //! With the Memory Manager, it is useless to call destructor,
146 //! it is done automatically when the Handle is nullified(cleared)
147 //! BUT this is ineffective in looping structures (whatever these
148 //! are "Implied" references or not).
150 //! THUS : if no loop may appear in definitions, a class which
151 //! inherits from TShared is correctly managed by automatic way
152 //! BUT if there can be loops (or simply back pointers), they must
153 //! be broken, for instance by clearing fields of one of the nodes
154 //! The default does nothing, to be redefined if a loop can occur
155 //! (Implied generally requires WhenDelete, but other cases can
158 //! Warning : <dispatched> tells if the entity to be deleted has been
159 //! produced by Dispatch or not. Hence WhenDelete must be in
160 //! coherence with Dispatch
161 //! Dispatch can either copy or not.
162 //! If it copies the entity, this one should be deleted
163 //! If it doesn't (i.e. duplicates the handle) nothing to do
165 //! If <dispatch> is False, normal deletion is to be performed
166 Standard_EXPORT virtual void WhenDeleteCase (const Standard_Integer CN, const Handle(Standard_Transient)& ent, const Standard_Boolean dispatched) const;
168 //! Returns a category number which characterizes an entity
169 //! Category Numbers are managed by the class Category
170 //! <shares> can be used to evaluate this number in the context
171 //! Default returns 0 which means "unspecified"
172 Standard_EXPORT virtual Standard_Integer CategoryNumber (const Standard_Integer CN, const Handle(Standard_Transient)& ent, const Interface_ShareTool& shares) const;
174 //! Determines if an entity brings a Name (or widerly, if a Name
175 //! can be attached to it, through the ShareTool
176 //! By default, returns a Null Handle (no name can be produced)
179 //! Warning : While this string may be edited on the spot, if it is a read
180 //! field, the returned value must be copied before.
181 Standard_EXPORT virtual Handle(TCollection_HAsciiString) Name (const Standard_Integer CN, const Handle(Standard_Transient)& ent, const Interface_ShareTool& shares) const;
186 DEFINE_STANDARD_RTTIEXT(Interface_GeneralModule,Standard_Transient)
206 #endif // _Interface_GeneralModule_HeaderFile