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 class Interface_InterfaceModel;
26 class Interface_EntityIterator;
27 class Interface_ShareTool;
28 class Interface_Check;
29 class Interface_CopyTool;
30 class TCollection_HAsciiString;
33 class Interface_GeneralModule;
34 DEFINE_STANDARD_HANDLE(Interface_GeneralModule, Standard_Transient)
36 //! This class defines general services, which must be provided
37 //! for each type of Entity (i.e. of Transient Object processed
38 //! by an Interface) : Shared List, Check, Copy, Delete, Category
40 //! To optimise processing (e.g. firstly bind an Entity to a Module
41 //! then calls Module), each recognized Entity Type corresponds
42 //! to a Case Number, determined by the Protocol each class of
43 //! GeneralModule belongs to.
44 class Interface_GeneralModule : public Standard_Transient
50 //! Specific filling of the list of Entities shared by an Entity
51 //! <ent>, according a Case Number <CN> (formerly computed by
52 //! CaseNum), considered in the context of a Model <model>
53 //! Default calls FillSharedCase (i.e., ignores the model)
54 //! Can be redefined to use the model for working
55 Standard_EXPORT virtual void FillShared (const Handle(Interface_InterfaceModel)& model, const Standard_Integer CN, const Handle(Standard_Transient)& ent, Interface_EntityIterator& iter) const;
57 //! Specific filling of the list of Entities shared by an Entity
58 //! <ent>, according a Case Number <CN> (formerly computed by
59 //! CaseNum). Can use the internal utility method Share, below
60 Standard_EXPORT virtual void FillSharedCase (const Standard_Integer CN, const Handle(Standard_Transient)& ent, Interface_EntityIterator& iter) const = 0;
62 //! Adds an Entity to a Shared List (uses GetOneItem on <iter>)
63 Standard_EXPORT void Share (Interface_EntityIterator& iter, const Handle(Standard_Transient)& shared) const;
65 //! List the Implied References of <ent> considered in the context
66 //! of a Model <model> : i.e. the Entities which are Referenced
67 //! while not considered as Shared (not copied if <ent> is,
68 //! references not renewed by CopyCase but by ImpliedCase, only
69 //! if referenced Entities have been Copied too)
70 //! FillShared + ListImplied give the complete list of References
71 //! Default calls ListImpliedCase (i.e. ignores the model)
72 //! Can be redefined to use the model for working
73 Standard_EXPORT virtual void ListImplied (const Handle(Interface_InterfaceModel)& model, const Standard_Integer CN, const Handle(Standard_Transient)& ent, Interface_EntityIterator& iter) const;
75 //! List the Implied References of <ent> (see above)
76 //! are Referenced while not considered as Shared (not copied if
77 //! <ent> is, references not renewed by CopyCase but by
78 //! ImpliedCase, only if referenced Entities have been Copied too)
79 //! FillSharedCase + ListImpliedCase give the complete list of
80 //! Referenced Entities
81 //! The provided default method does nothing (Implied References
82 //! are specific of a little amount of Entity Classes).
83 Standard_EXPORT virtual void ListImpliedCase (const Standard_Integer CN, const Handle(Standard_Transient)& ent, Interface_EntityIterator& iter) const;
85 //! Specific Checking of an Entity <ent>
86 //! Can check context queried through a ShareTool, as required
87 Standard_EXPORT virtual void CheckCase (const Standard_Integer CN, const Handle(Standard_Transient)& ent, const Interface_ShareTool& shares, Handle(Interface_Check)& ach) const = 0;
89 //! Specific answer to the question "is Copy properly implemented"
90 //! Remark that it should be in phase with the implementation of
91 //! NewVoid+CopyCase/NewCopyCase
92 //! Default returns always False, can be redefined
93 Standard_EXPORT virtual Standard_Boolean CanCopy (const Standard_Integer CN, const Handle(Standard_Transient)& ent) const;
95 //! Dispatches an entity
96 //! Returns True if it works by copy, False if it just duplicates
97 //! the starting Handle
99 //! Dispatching means producing a new entity, image of the
100 //! starting one, in order to be put into a new Model, this Model
101 //! being itself the result of a dispatch from an original Model
103 //! According to the cases, dispatch can either
104 //! * just return <entto> as equating <entfrom>
105 //! -> the new model designates the starting entity : it is
106 //! lighter, but the dispatched entity being shared might not be
107 //! modified for dispatch
108 //! * copy <entfrom> to <entto>
109 //! by calling NewVoid+CopyCase (two steps) or NewCopiedCase (1)
110 //! -> the dispatched entity is a COPY, hence it can be modified
112 //! The provided default just duplicates the handle without
113 //! copying, then returns False. Can be redefined
114 Standard_EXPORT virtual Standard_Boolean Dispatch (const Standard_Integer CN, const Handle(Standard_Transient)& entfrom, Handle(Standard_Transient)& entto, Interface_CopyTool& TC) const;
116 //! Creates a new void entity <entto> according to a Case Number
117 //! This entity remains to be filled, by reading from a file or
118 //! by copying from another entity of same type (see CopyCase)
119 Standard_EXPORT virtual Standard_Boolean NewVoid (const Standard_Integer CN, Handle(Standard_Transient)& entto) const = 0;
121 //! Specific Copy ("Deep") from <entfrom> to <entto> (same type)
122 //! by using a CopyTool which provides its working Map.
123 //! Use method Transferred from CopyTool to work
124 Standard_EXPORT virtual void CopyCase (const Standard_Integer CN, const Handle(Standard_Transient)& entfrom, const Handle(Standard_Transient)& entto, Interface_CopyTool& TC) const = 0;
126 //! Specific operator (create+copy) defaulted to do nothing.
127 //! It can be redefined : When it is not possible to work in two
128 //! steps (NewVoid then CopyCase). This can occur when there is
129 //! no default constructor : hence the result <entto> must be
130 //! created with an effective definition.
131 //! Remark : if NewCopiedCase is defined, CopyCase has nothing to do
132 //! Returns True if it has produced something, false else
133 Standard_EXPORT virtual Standard_Boolean NewCopiedCase (const Standard_Integer CN, const Handle(Standard_Transient)& entfrom, Handle(Standard_Transient)& entto, Interface_CopyTool& TC) const;
135 //! Specific Copying of Implied References
136 //! A Default is provided which does nothing (must current case !)
137 //! Already copied references (by CopyFrom) must remain unchanged
138 //! Use method Search from CopyTool to work
139 Standard_EXPORT virtual void RenewImpliedCase (const Standard_Integer CN, const Handle(Standard_Transient)& entfrom, const Handle(Standard_Transient)& entto, const Interface_CopyTool& TC) const;
141 //! Prepares an entity to be deleted. What does it mean :
142 //! Basically, any class of entity may define its own destructor
143 //! By default, it does nothing but calling destructors on fields
144 //! With the Memory Manager, it is useless to call destructor,
145 //! it is done automatically when the Handle is nullified(cleared)
146 //! BUT this is ineffective in looping structures (whatever these
147 //! are "Implied" references or not).
149 //! THUS : if no loop may appear in definitions, a class which
150 //! inherits from TShared is correctly managed by automatic way
151 //! BUT if there can be loops (or simply back pointers), they must
152 //! be broken, for instance by clearing fields of one of the nodes
153 //! The default does nothing, to be redefined if a loop can occur
154 //! (Implied generally requires WhenDelete, but other cases can
157 //! Warning : <dispatched> tells if the entity to be deleted has been
158 //! produced by Dispatch or not. Hence WhenDelete must be in
159 //! coherence with Dispatch
160 //! Dispatch can either copy or not.
161 //! If it copies the entity, this one should be deleted
162 //! If it doesn't (i.e. duplicates the handle) nothing to do
164 //! If <dispatch> is False, normal deletion is to be performed
165 Standard_EXPORT virtual void WhenDeleteCase (const Standard_Integer CN, const Handle(Standard_Transient)& ent, const Standard_Boolean dispatched) const;
167 //! Returns a category number which characterizes an entity
168 //! Category Numbers are managed by the class Category
169 //! <shares> can be used to evaluate this number in the context
170 //! Default returns 0 which means "unspecified"
171 Standard_EXPORT virtual Standard_Integer CategoryNumber (const Standard_Integer CN, const Handle(Standard_Transient)& ent, const Interface_ShareTool& shares) const;
173 //! Determines if an entity brings a Name (or widerly, if a Name
174 //! can be attached to it, through the ShareTool
175 //! By default, returns a Null Handle (no name can be produced)
178 //! Warning : While this string may be edited on the spot, if it is a read
179 //! field, the returned value must be copied before.
180 Standard_EXPORT virtual Handle(TCollection_HAsciiString) Name (const Standard_Integer CN, const Handle(Standard_Transient)& ent, const Interface_ShareTool& shares) const;
185 DEFINE_STANDARD_RTTIEXT(Interface_GeneralModule,Standard_Transient)
205 #endif // _Interface_GeneralModule_HeaderFile