1 -- Created on: 1992-11-17
2 -- Created by: Christian CAILLET
3 -- Copyright (c) 1992-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 class ShareOut from IFSelect inherits TShared
19 ---Purpose : This class gathers the informations required to produce one or
20 -- several file(s) from the content of an InterfaceModel (passing
21 -- through the creation of intermediate Models).
23 -- It can correspond to a complete Divide up of a set of Entities
24 -- intended to be exhaustive and to limit duplications. Or to a
25 -- simple Extraction of some Entities, in order to work on them.
27 -- A ShareOut is composed of a list of Dispatches.
28 -- To Each Dispatch in the ShareOut, is bound an Id. Number
29 -- This Id. Number allows to identify a Display inside the
30 -- ShareOut in a stable way (for instance, to attach file names)
32 -- ShareOut can be seen as a "passive" description, activated
33 -- through a ShareOutResult, which gives the InterfaceModel on
34 -- which to work, as a unique source. Thus it is easy to change
35 -- it without coherence problems
37 -- Services about it are provided by the class ShareOutResult
38 -- which is a service class : simulation (list of files and of
39 -- entities per file; "forgotten" entities; duplicated entities),
40 -- exploitation (generation of derivated Models, each of them
41 -- generating an output file)
43 uses SequenceOfInteger from TColStd, CString,
44 HAsciiString from TCollection, AsciiString from TCollection,
45 Dispatch, TSeqOfDispatch,
46 GeneralModifier, Modifier, SequenceOfGeneralModifier
48 raises InterfaceError, OutOfRange
52 Create returns ShareOut;
53 ---Purpose : Creates an empty ShareOut
55 Clear (me : mutable; onlydisp : Boolean);
56 ---Purpose : Removes in one operation all the Dispatches with their Idents
57 -- Also clears all informations about Names, and all Results but
58 -- naming informations which are :
59 -- - kept if <onlydisp> is True.
60 -- - cleared if <onlydisp> is False (complete clearing)
61 -- If <onlydisp> is True, that's all. Else, clears also Modifiers
63 ClearResult (me : mutable; alsoname : Boolean);
64 ---Purpose : Clears all data produced (apart from Dispatches, etc...)
65 -- if <alsoname> is True, all is cleared. Else, informations
66 -- about produced Names are kept (to maintain unicity of naming
69 RemoveItem (me : mutable; item : Transient) returns Boolean;
70 ---Purpose : Removes an item, which can be, either a Dispatch (removed from
71 -- the list of Dispatches), or a GeneralModifier (removed from
72 -- the list of Model Modifiers or from the list of File Modifiers
73 -- according to its type).
74 -- Returns True if done, False if has not been found or if it is
75 -- neither a Dispatch, nor a Modifier.
78 LastRun (me) returns Integer;
79 ---Purpose : Returns the rank of last run item (ClearResult resets it to 0)
81 SetLastRun (me : mutable; last : Integer);
82 ---Purpose : Records a new alue for the rank of last run item
84 NbDispatches (me) returns Integer;
85 ---Purpose : Returns the count of Dispatches
87 DispatchRank (me; disp : Dispatch) returns Integer;
88 ---Purpose : Returns the Rank of a Dispatch, given its Value (Handle).
89 -- Returns 0 if the Dispatch is unknown in the ShareOut
91 Dispatch (me; num : Integer) returns Dispatch
92 ---Purpose : Returns a Dispatch, given its rank in the list
94 -- Error if <num> is out of range
95 ---C++ : return const &
97 AddDispatch (me : mutable; disp : Dispatch)
98 ---Purpose : Adds a Dispatch to the list
99 raises InterfaceError;
100 -- Error if the Dispatch is attached to a ShareOut other than "me"
102 RemoveDispatch (me : mutable; rank : Integer) returns Boolean;
103 ---Purpose : Removes a Dispatch, given its rank in the list
104 -- Returns True if done, False if rank is not between
105 -- (LastRun + 1) and (NbDispatches)
107 -- -- Modifiers to be applied -- --
109 AddModifier (me : mutable; modifier : GeneralModifier;
111 ---Purpose : Sets a Modifier to be applied on all Dispatches to be run
112 -- If <modifier> is a ModelModifier, adds it to the list of
113 -- Model Modifiers; else to the list of File Modifiers
114 -- By default (atnum = 0) at the end of the list, else at <atnum>
115 -- Each Modifier is used, after each copy of a packet of Entities
116 -- into a Model : its criteria are checked and if they are OK,
117 -- the method Perform of this Modifier is run.
119 AddModifier (me : mutable; modifier : GeneralModifier;
120 dispnum : Integer; atnum : Integer);
121 ---Purpose : Sets a Modifier to be applied on the Dispatch <dispnum>
122 -- If <modifier> is a ModelModifier, adds it to the list of
123 -- Model Modifiers; else to the list of File Modifiers
124 -- This is the same list as for all Dispatches, but the
125 -- Modifier is qualified to be applied to one Dispatch only
126 -- Then, <atnum> refers to the entire list
127 -- By default (atnum = 0) at the end of the list, else at <atnum>
128 -- Remark : if the Modifier was already in the list and if
129 -- <atnum> = 0, the Modifier is not moved, but only qualified
133 AddModif (me : mutable; modifier : GeneralModifier;
134 formodel : Boolean; atnum : Integer = 0);
135 ---Purpose : Adds a Modifier to the list of Modifiers : Model Modifiers if
136 -- <formodel> is True, File Modifiers else (internal).
138 NbModifiers (me; formodel : Boolean) returns Integer;
139 ---Purpose : Returns count of Modifiers (which apply to complete Models) :
140 -- Model Modifiers if <formodel> is True, File Modifiers else
142 GeneralModifier (me; formodel : Boolean; num : Integer)
143 returns GeneralModifier;
144 ---Purpose : Returns a Modifier of the list, given its rank :
145 -- Model Modifiers if <formodel> is True, File Modifiers else
147 ModelModifier (me; num : Integer) returns Modifier;
148 ---Purpose : Returns a Modifier of the list of Model Modifiers, duely casted
150 ModifierRank (me; modifier : GeneralModifier) returns Integer;
151 ---Purpose : Gives the rank of a Modifier in the list, 0 if not in the list
152 -- Model Modifiers if <modifier> is kind of ModelModifer,
153 -- File Modifiers else
155 RemoveModifier (me : mutable; formodel : Boolean; num : Integer)
157 ---Purpose : Removes a Modifier, given it rank in the list :
158 -- Model Modifiers if <formodel> is True, File Modifiers else
159 -- Returns True if done, False if <num> is out of range
161 ChangeModifierRank (me : mutable; formodel : Boolean; befor,after : Integer)
163 ---Purpose : Changes the rank of a modifier in the list :
164 -- Model Modifiers if <formodel> is True, File Modifiers else
165 -- from <before> to <after>
166 -- Returns True if done, False else (before or after out of range)
168 -- -- Names for produced Files -- --
170 SetRootName (me : mutable; num : Integer; name : HAsciiString)
172 ---Purpose : Attaches a Root Name to a Dispatch given its rank, as an
173 -- HAsciiString (standard form). A Null Handle resets this name.
174 -- Returns True if OK, False if this Name is already attached,
175 -- for a Dispatch or for Default, or <num> out of range
177 HasRootName (me; num : Integer) returns Boolean;
178 ---Purpose : Returns True if the Dispatch of rank <num> has an attached
179 -- Root Name. False else, or if num is out of range
181 RootName (me; num : Integer) returns HAsciiString from TCollection;
182 ---Purpose : Returns the Root bound to a Dispatch, given its rank
183 -- Returns a Null Handle if not defined
185 RootNumber (me; name : HAsciiString) returns Integer;
186 ---Purpose : Returns an integer value about a given root name :
187 -- - positive : it's the rank of the Dispatch which has this name
188 -- - null : this root name is unknown
189 -- - negative (-1) : this root name is the default root name
191 SetPrefix (me : mutable; pref : HAsciiString from TCollection);
192 ---Purpose : Defines or Changes the general Prefix (which is prepended to
193 -- complete file name generated). If this method is not call,
194 -- Prefix remains empty
196 SetDefaultRootName (me : mutable; defrt : HAsciiString from TCollection)
198 ---Purpose : Defines or Changes the Default Root Name to a new value (which
199 -- is used for dispatches which have no attached root name).
200 -- If this method is not called, DefaultRootName remains empty
201 -- Returns True if OK, False if this Name is already attached,
202 -- for a Dispatch or for Default
204 SetExtension (me : mutable; ext : HAsciiString from TCollection);
205 ---Purpose : Defines or Changes the general Extension (which is appended to
206 -- complete file name generated). If this method is not call,
207 -- Extension remains empty
209 Prefix (me) returns HAsciiString from TCollection;
210 ---Purpose : Returns the general Prefix. Can be empty.
212 DefaultRootName (me) returns HAsciiString from TCollection;
213 ---Purpose : Returns the Default Root Name. Can be empty.
215 Extension (me) returns HAsciiString from TCollection;
216 ---Purpose : Returns the general Extension. Can be empty (not recommanded)
218 FileName (me : mutable; dnum, pnum : Integer; nbpack : Integer = 0)
219 returns AsciiString from TCollection;
220 ---Purpose : Computes the complete file name for a Packet of a Dispatch,
221 -- given Dispatch Number (Rank), Packet Number, and Count of
222 -- Packets generated by this Dispatch (0 if unknown)
224 -- File Name is made of following strings, concatenated :
225 -- General Prefix, Root Name for Dispatch, Packet Suffix, and
226 -- General Extension. If no Root Name is specified for a
227 -- Dispatch, DefaultRootName is considered (and pnum is not used,
228 -- but <thenbdefs> is incremented and used
229 -- Error if no Root is defined for this <idnum>
233 thedisps : TSeqOfDispatch;
234 themodelmodifiers : SequenceOfGeneralModifier;
235 thefilemodifiers : SequenceOfGeneralModifier;
236 thepref : HAsciiString from TCollection;
237 thedefrt : HAsciiString from TCollection;
238 theext : HAsciiString from TCollection;
240 thelastrun : Integer;