1 -- File: IFSelect_ModelCopier.cdl
2 -- Created: Thu Aug 26 17:47:09 1993
3 -- Author: Christian CAILLET
5 ---Copyright: Matra Datavision 1993
8 class ModelCopier from IFSelect inherits TShared
10 ---Purpose : This class performs the Copy operations involved by the
11 -- description of a ShareOut (evaluated by a ShareOutResult)
12 -- plus, if there are, the Modifications on the results, with
13 -- the help of Modifiers. Each Modifier can work on one or more
14 -- resulting packets, accoding its criteria : it operates on a
15 -- Model once copied and filled with the content of the packet.
18 -- - Model Modifiers, inheriting from the specific class Modifier
19 -- able to run on the content of a Model (header or entities),
20 -- activated by the ModelCopier itself
21 -- - File Modifiers, inheriting directly from GeneralModifier,
22 -- intended to be activated under the control of a WorkLibrary,
23 -- once the Model has been produced (i.e. to act on output
24 -- format, or other specific file features)
26 -- The Copy operations can be :
27 -- - immediately put to files : for each packet, a Model is
28 -- created and filled, then the file is output, at that's all
29 -- - memorized : for each packet, a Model is created and filled,
30 -- it is memorized with the corresponding file name.
31 -- it is possible to query the result of memorization (list of
32 -- produced Models and their file names)
33 -- -> it is also possible to send it into the files :
34 -- once files are written, the result is cleared
36 -- In addition, a list of really written files is managed :
37 -- A first call to BeginSentFiles clears the list and commands,
38 -- either to begin a new list, or to stop recording it. A call
39 -- to SentFiles returns the list (if recording has been required)
40 -- This list allows to globally exploit the set of produced files
42 -- Remark : For operations which concern specific Entities, see
43 -- also in package IFAdapt : a sub-class of ModelCopier allows
44 -- to work with EntityModifier, in addition to Modifier itself
45 -- which still applies to a whole copied Model.
47 uses AsciiString from TCollection,
48 HSequenceOfInteger from TColStd, HArray1OfInteger from TColStd,
49 SequenceOfAsciiString, HSequenceOfHAsciiString from TColStd,
50 InterfaceModel, Protocol, Graph, EntityIterator, CopyTool, CheckIterator,
51 ShareOutResult, ShareOut, WorkLibrary, GeneralModifier, Modifier,
52 SequenceOfGeneralModifier, SequenceOfInterfaceModel,
53 AppliedModifiers, SequenceOfAppliedModifiers
57 Create returns mutable ModelCopier;
58 ---Purpose : Creates an empty ModelCopier
60 SetShareOut (me : mutable; sho : ShareOut);
61 ---Purpose : Sets the ShareOut, which is used to define Modifiers to apply
63 ClearResult (me : mutable);
64 ---Purpose : Clears the list of produced Models
66 AddFile (me : mutable; filename : AsciiString from TCollection;
67 content : InterfaceModel) returns Boolean;
68 ---Purpose : Records a new File to be sent, as a couple
69 -- (Name as AsciiString, Content as InterfaceModel)
70 -- Returns True if Done, False if <filename> is already attached
73 NameFile (me : mutable; num : Integer; filename : AsciiString)
75 ---Purpose : Changes the Name attached to a File which was formerly defined
76 -- by a call to AddFile
77 -- Returns True if Done, False else : if <num> out of range or if
78 -- the new <filename> is already attached to another File
79 -- Remark : Giving an empty File Name is equivalent to ClearFile
81 ClearFile (me : mutable; num : Integer) returns Boolean;
82 ---Purpose : Clears the Name attached to a File which was formerly defined
83 -- by a call to AddFile. This Clearing can be undone by a call to
84 -- NameFile (with same <num>)
85 -- Returns True if Done, False else : if <num> is out of range
87 SetAppliedModifiers (me : mutable; num : Integer;
88 applied : mutable AppliedModifiers) returns Boolean;
89 ---Purpose : Sets a list of File Modifiers to be applied on a file
91 ClearAppliedModifiers (me : mutable; num : Integer) returns Boolean;
92 ---Purpose : Clears the list of File Modifiers to be applied on a file
95 Copy (me : mutable; eval : in out ShareOutResult;
96 WL : WorkLibrary; protocol : Protocol)
97 returns CheckIterator;
98 ---Purpose : Performs the Copy Operations, which include the Modifications
99 -- defined by the list of Modifiers. Memorizes the result, as a
100 -- list of InterfaceModels with the corresponding FileNames
101 -- They can then be sent, by the method Send, or queried
102 -- Copy calls internal method Copying.
103 -- Returns the produced CheckList
105 Copying (me : mutable; eval : in out ShareOutResult;
106 WL : WorkLibrary; protocol : Protocol; TC : in out CopyTool)
107 returns CheckIterator is protected;
108 ---Purpose : Internal routine which does the effective Copy. It allows to
109 -- work, either with a standard CopyTool, or a specialised one
110 -- Copying itself is done by <WL> which uses a CopyTool
112 SendCopied (me : mutable; WL : WorkLibrary; protocol : Protocol)
113 returns CheckIterator;
114 ---Purpose : Sends the formerly defined results (see method Copy) to files,
116 -- Remark : A Null File Name cause file to be not produced
118 Send (me : mutable; eval : in out ShareOutResult;
119 WL : WorkLibrary; protocol : Protocol)
120 returns CheckIterator;
121 ---Purpose : Performs the Copy Operations (which include the Modifications)
122 -- and Sends the result on files, without memorizing it.
123 -- (the memorized result is ignored : neither queried not filled)
125 Sending (me : mutable; eval : in out ShareOutResult;
126 WL : WorkLibrary; protocol : Protocol; TC : in out CopyTool)
127 returns CheckIterator is protected;
128 ---Purpose : Internal routine which does the effective Send. It allows to
129 -- work, either with a standard CopyTool, or a specialised one
131 SendAll (me : mutable; filename : CString; G : Graph;
132 WL : WorkLibrary; protocol : Protocol)
133 returns CheckIterator;
134 ---Purpose : Sends a model (defined in <G>) into one file, without managing
135 -- remaining data, already sent files, etc. Applies the Model and
137 -- Returns True if well done, False else
139 SendSelected (me : mutable; filename : CString; G : Graph;
140 WL : WorkLibrary; protocol : Protocol;
141 iter : EntityIterator)
142 returns CheckIterator;
143 ---Purpose : Sends a part of a model into one file. Model is gotten from
144 -- <G>, the part is defined in <iter>.
145 -- Remaining data are managed and can be later be worked on.
146 -- Returns True if well done, False else
148 CopiedModel (me; G : Graph;
151 topcopy : EntityIterator;
152 filename : AsciiString from TCollection;
153 dispnum, numod : Integer;
154 TC : in out CopyTool;
155 newmod : out mutable InterfaceModel;
156 applied : out mutable AppliedModifiers;
157 checks : out CheckIterator)
159 ---Purpose : Performs the Copy of a unitary Packet
160 -- Input parameters are :
161 -- <G> is the graph which defines the starting entities, it
162 -- contains the original InterfaceModel
163 -- <WL> performs the copy by using <TC>
164 -- <protocol> is the used protocol (can be usefull for Modifiers)
165 -- <topcopy> is the list of Entities which are the Roots of the
166 -- packet to be copied
167 -- <filename> is the name of the file which will receive it
168 -- <dispid> is the Identifier of the Dispatch which have produced
169 -- this packet, <numod> is the rank of the packet for this
171 -- <TC> is a CopyTool, which performs the copy
173 -- Returned values (as arguments) are :
174 -- <newmod> is the result of the copy, as a new InterfaceModel on
175 -- which Model Modifiers have already been applied (if there are)
176 -- <applied> determines the File Modifiers which remain to be
177 -- applied (when the file itself will be output) : for each File
178 -- Modifier recorded in <me>, <applied>'s Value is :
179 -- - Null if this Modifier has not to be applied
180 -- - an empty list if this Modifier has to be applied without
181 -- distinguishing specific entities
182 -- - a list of numbers of entities in <model> if this Modifier
183 -- concerns particularly these entities (which are the results
184 -- of copying the result of its input selection)
185 -- <checks> is the produced Check List (by Modifiers as required)
187 -- Warning : File Modifiers are evaluated at the time of Copy itself
188 -- If their list is changed between this Copy and the Sending
189 -- itself of the file, these changes are ignored
191 CopiedRemaining (me : mutable; G : Graph;
193 TC : in out CopyTool;
194 newmod : out mutable InterfaceModel);
195 ---Purpose : Produces a Model copied from the Remaining List as <newmod>
196 -- <newmod> is a Null Handle if this list is empty
197 -- <WL> performs the copy by using <TC>
198 -- <TC> is assumed to have been defined with the starting model
199 -- same as defined by <G>.
201 SetRemaining (me; CG : in out Graph) returns Boolean;
202 ---Purpose : Updates Graph status for remaining data, for each entity :
203 -- - Entities just Sent to file or Copied (by CopiedRemaining)
204 -- have their status set to 1
205 -- - the other keep their former status (1 for Send/Copied,
207 -- These status are computed by Copying/Sending/CopiedRemaining
208 -- Then, SetRemaining updates graph status, and mustr be called
209 -- just after one of these method has been called
210 -- Returns True if done, False if remaining info if not in phase
211 -- which the Graph (not same counts of items)
214 NbFiles (me) returns Integer;
215 ---Purpose : Returns the count of Files produced, i.e. the count of Models
216 -- memorized (produced by the mmethod Copy) with their file names
218 FileName (me; num : Integer) returns AsciiString from TCollection;
219 ---Purpose : Returns the File Name for a file given its rank
220 -- It is empty after a call to ClearFile on same <num>
222 FileModel (me; num : Integer) returns mutable InterfaceModel;
223 ---Purpose : Returns the content of a file before sending, under the form
224 -- of an InterfaceModel, given its rank
226 AppliedModifiers (me; num : Integer) returns mutable AppliedModifiers;
227 ---Purpose : Returns the list of File Modifiers to be applied on a file
228 -- when it will be sent, as computed by CopiedModel :
229 -- If it is a null handle, no File Modifier has to be applied.
232 BeginSentFiles (me : mutable; sho : mutable ShareOut; record : Boolean);
233 ---Purpose : Begins a sequence of recording the really sent files
234 -- <sho> : the default file numbering is cleared
235 -- If <record> is False, clears the list and stops recording
236 -- If <record> is True, clears the list and commands recording
237 -- Creation time corresponds to "stop recording"
239 AddSentFile (me : mutable; filename : CString);
240 ---Purpose : Adds the name of a just sent file, if BeginSentFiles
241 -- has commanded recording; else does nothing
242 -- It is called by methods SendCopied Sending
244 SentFiles (me) returns HSequenceOfHAsciiString from TColStd;
245 ---Purpose : Returns the list of recorded names of sent files. Can be empty
246 -- (if no file has been sent). Returns a Null Handle if
247 -- BeginSentFiles has stopped recording.
251 thefilemodels : SequenceOfInterfaceModel;
252 thefilenames : SequenceOfAsciiString;
253 theapplieds : SequenceOfAppliedModifiers;
254 theshareout : ShareOut; -- for copy-send operation (names, modifiers)
255 theremain : HArray1OfInteger;
256 thesentfiles : HSequenceOfHAsciiString;