| 1 | -- Created on: 1992-11-17 |
| 2 | -- Created by: Christian CAILLET |
| 3 | -- Copyright (c) 1992-1999 Matra Datavision |
| 4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
| 5 | -- |
| 6 | -- The content of this file is subject to the Open CASCADE Technology Public |
| 7 | -- License Version 6.5 (the "License"). You may not use the content of this file |
| 8 | -- except in compliance with the License. Please obtain a copy of the License |
| 9 | -- at http://www.opencascade.org and read it completely before using this file. |
| 10 | -- |
| 11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
| 12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
| 13 | -- |
| 14 | -- The Original Code and all software distributed under the License is |
| 15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
| 16 | -- Initial Developer hereby disclaims all such warranties, including without |
| 17 | -- limitation, any warranties of merchantability, fitness for a particular |
| 18 | -- purpose or non-infringement. Please see the License for the specific terms |
| 19 | -- and conditions governing the rights and limitations under the License. |
| 20 | |
| 21 | |
| 22 | |
| 23 | class ShareOut from IFSelect inherits TShared |
| 24 | |
| 25 | ---Purpose : This class gathers the informations required to produce one or |
| 26 | -- several file(s) from the content of an InterfaceModel (passing |
| 27 | -- through the creation of intermediate Models). |
| 28 | -- |
| 29 | -- It can correspond to a complete Divide up of a set of Entities |
| 30 | -- intended to be exhaustive and to limit duplications. Or to a |
| 31 | -- simple Extraction of some Entities, in order to work on them. |
| 32 | -- |
| 33 | -- A ShareOut is composed of a list of Dispatches. |
| 34 | -- To Each Dispatch in the ShareOut, is bound an Id. Number |
| 35 | -- This Id. Number allows to identify a Display inside the |
| 36 | -- ShareOut in a stable way (for instance, to attach file names) |
| 37 | -- |
| 38 | -- ShareOut can be seen as a "passive" description, activated |
| 39 | -- through a ShareOutResult, which gives the InterfaceModel on |
| 40 | -- which to work, as a unique source. Thus it is easy to change |
| 41 | -- it without coherence problems |
| 42 | -- |
| 43 | -- Services about it are provided by the class ShareOutResult |
| 44 | -- which is a service class : simulation (list of files and of |
| 45 | -- entities per file; "forgotten" entities; duplicated entities), |
| 46 | -- exploitation (generation of derivated Models, each of them |
| 47 | -- generating an output file) |
| 48 | |
| 49 | uses SequenceOfInteger from TColStd, CString, |
| 50 | HAsciiString from TCollection, AsciiString from TCollection, |
| 51 | Dispatch, TSeqOfDispatch, |
| 52 | GeneralModifier, Modifier, SequenceOfGeneralModifier |
| 53 | |
| 54 | raises InterfaceError, OutOfRange |
| 55 | |
| 56 | is |
| 57 | |
| 58 | Create returns mutable ShareOut; |
| 59 | ---Purpose : Creates an empty ShareOut |
| 60 | |
| 61 | Clear (me : mutable; onlydisp : Boolean); |
| 62 | ---Purpose : Removes in one operation all the Dispatches with their Idents |
| 63 | -- Also clears all informations about Names, and all Results but |
| 64 | -- naming informations which are : |
| 65 | -- - kept if <onlydisp> is True. |
| 66 | -- - cleared if <onlydisp> is False (complete clearing) |
| 67 | -- If <onlydisp> is True, that's all. Else, clears also Modifiers |
| 68 | |
| 69 | ClearResult (me : mutable; alsoname : Boolean); |
| 70 | ---Purpose : Clears all data produced (apart from Dispatches, etc...) |
| 71 | -- if <alsoname> is True, all is cleared. Else, informations |
| 72 | -- about produced Names are kept (to maintain unicity of naming |
| 73 | -- across clearings) |
| 74 | |
| 75 | RemoveItem (me : mutable; item : Transient) returns Boolean; |
| 76 | ---Purpose : Removes an item, which can be, either a Dispatch (removed from |
| 77 | -- the list of Dispatches), or a GeneralModifier (removed from |
| 78 | -- the list of Model Modifiers or from the list of File Modifiers |
| 79 | -- according to its type). |
| 80 | -- Returns True if done, False if has not been found or if it is |
| 81 | -- neither a Dispatch, nor a Modifier. |
| 82 | |
| 83 | |
| 84 | LastRun (me) returns Integer; |
| 85 | ---Purpose : Returns the rank of last run item (ClearResult resets it to 0) |
| 86 | |
| 87 | SetLastRun (me : mutable; last : Integer); |
| 88 | ---Purpose : Records a new alue for the rank of last run item |
| 89 | |
| 90 | NbDispatches (me) returns Integer; |
| 91 | ---Purpose : Returns the count of Dispatches |
| 92 | |
| 93 | DispatchRank (me; disp : Dispatch) returns Integer; |
| 94 | ---Purpose : Returns the Rank of a Dispatch, given its Value (Handle). |
| 95 | -- Returns 0 if the Dispatch is unknown in the ShareOut |
| 96 | |
| 97 | Dispatch (me; num : Integer) returns mutable Dispatch |
| 98 | ---Purpose : Returns a Dispatch, given its rank in the list |
| 99 | raises OutOfRange; |
| 100 | -- Error if <num> is out of range |
| 101 | ---C++ : return const & |
| 102 | |
| 103 | AddDispatch (me : mutable; disp : mutable Dispatch) |
| 104 | ---Purpose : Adds a Dispatch to the list |
| 105 | raises InterfaceError; |
| 106 | -- Error if the Dispatch is attached to a ShareOut other than "me" |
| 107 | |
| 108 | RemoveDispatch (me : mutable; rank : Integer) returns Boolean; |
| 109 | ---Purpose : Removes a Dispatch, given its rank in the list |
| 110 | -- Returns True if done, False if rank is not between |
| 111 | -- (LastRun + 1) and (NbDispatches) |
| 112 | |
| 113 | -- -- Modifiers to be applied -- -- |
| 114 | |
| 115 | AddModifier (me : mutable; modifier : mutable GeneralModifier; |
| 116 | atnum : Integer); |
| 117 | ---Purpose : Sets a Modifier to be applied on all Dispatches to be run |
| 118 | -- If <modifier> is a ModelModifier, adds it to the list of |
| 119 | -- Model Modifiers; else to the list of File Modifiers |
| 120 | -- By default (atnum = 0) at the end of the list, else at <atnum> |
| 121 | -- Each Modifier is used, after each copy of a packet of Entities |
| 122 | -- into a Model : its criteria are checked and if they are OK, |
| 123 | -- the method Perform of this Modifier is run. |
| 124 | |
| 125 | AddModifier (me : mutable; modifier : mutable GeneralModifier; |
| 126 | dispnum : Integer; atnum : Integer); |
| 127 | ---Purpose : Sets a Modifier to be applied on the Dispatch <dispnum> |
| 128 | -- If <modifier> is a ModelModifier, adds it to the list of |
| 129 | -- Model Modifiers; else to the list of File Modifiers |
| 130 | -- This is the same list as for all Dispatches, but the |
| 131 | -- Modifier is qualified to be applied to one Dispatch only |
| 132 | -- Then, <atnum> refers to the entire list |
| 133 | -- By default (atnum = 0) at the end of the list, else at <atnum> |
| 134 | -- Remark : if the Modifier was already in the list and if |
| 135 | -- <atnum> = 0, the Modifier is not moved, but only qualified |
| 136 | -- for a Dispatch |
| 137 | |
| 138 | |
| 139 | AddModif (me : mutable; modifier : mutable GeneralModifier; |
| 140 | formodel : Boolean; atnum : Integer = 0); |
| 141 | ---Purpose : Adds a Modifier to the list of Modifiers : Model Modifiers if |
| 142 | -- <formodel> is True, File Modifiers else (internal). |
| 143 | |
| 144 | NbModifiers (me; formodel : Boolean) returns Integer; |
| 145 | ---Purpose : Returns count of Modifiers (which apply to complete Models) : |
| 146 | -- Model Modifiers if <formodel> is True, File Modifiers else |
| 147 | |
| 148 | GeneralModifier (me; formodel : Boolean; num : Integer) |
| 149 | returns mutable GeneralModifier; |
| 150 | ---Purpose : Returns a Modifier of the list, given its rank : |
| 151 | -- Model Modifiers if <formodel> is True, File Modifiers else |
| 152 | |
| 153 | ModelModifier (me; num : Integer) returns mutable Modifier; |
| 154 | ---Purpose : Returns a Modifier of the list of Model Modifiers, duely casted |
| 155 | |
| 156 | ModifierRank (me; modifier : GeneralModifier) returns Integer; |
| 157 | ---Purpose : Gives the rank of a Modifier in the list, 0 if not in the list |
| 158 | -- Model Modifiers if <modifier> is kind of ModelModifer, |
| 159 | -- File Modifiers else |
| 160 | |
| 161 | RemoveModifier (me : mutable; formodel : Boolean; num : Integer) |
| 162 | returns Boolean; |
| 163 | ---Purpose : Removes a Modifier, given it rank in the list : |
| 164 | -- Model Modifiers if <formodel> is True, File Modifiers else |
| 165 | -- Returns True if done, False if <num> is out of range |
| 166 | |
| 167 | ChangeModifierRank (me : mutable; formodel : Boolean; befor,after : Integer) |
| 168 | returns Boolean; |
| 169 | ---Purpose : Changes the rank of a modifier in the list : |
| 170 | -- Model Modifiers if <formodel> is True, File Modifiers else |
| 171 | -- from <before> to <after> |
| 172 | -- Returns True if done, False else (before or after out of range) |
| 173 | |
| 174 | -- -- Names for produced Files -- -- |
| 175 | |
| 176 | SetRootName (me : mutable; num : Integer; name : mutable HAsciiString) |
| 177 | returns Boolean; |
| 178 | ---Purpose : Attaches a Root Name to a Dispatch given its rank, as an |
| 179 | -- HAsciiString (standard form). A Null Handle resets this name. |
| 180 | -- Returns True if OK, False if this Name is already attached, |
| 181 | -- for a Dispatch or for Default, or <num> out of range |
| 182 | |
| 183 | HasRootName (me; num : Integer) returns Boolean; |
| 184 | ---Purpose : Returns True if the Dispatch of rank <num> has an attached |
| 185 | -- Root Name. False else, or if num is out of range |
| 186 | |
| 187 | RootName (me; num : Integer) returns mutable HAsciiString from TCollection; |
| 188 | ---Purpose : Returns the Root bound to a Dispatch, given its rank |
| 189 | -- Returns a Null Handle if not defined |
| 190 | |
| 191 | RootNumber (me; name : HAsciiString) returns Integer; |
| 192 | ---Purpose : Returns an integer value about a given root name : |
| 193 | -- - positive : it's the rank of the Dispatch which has this name |
| 194 | -- - null : this root name is unknown |
| 195 | -- - negative (-1) : this root name is the default root name |
| 196 | |
| 197 | SetPrefix (me : mutable; pref : HAsciiString from TCollection); |
| 198 | ---Purpose : Defines or Changes the general Prefix (which is prepended to |
| 199 | -- complete file name generated). If this method is not call, |
| 200 | -- Prefix remains empty |
| 201 | |
| 202 | SetDefaultRootName (me : mutable; defrt : HAsciiString from TCollection) |
| 203 | returns Boolean; |
| 204 | ---Purpose : Defines or Changes the Default Root Name to a new value (which |
| 205 | -- is used for dispatches which have no attached root name). |
| 206 | -- If this method is not called, DefaultRootName remains empty |
| 207 | -- Returns True if OK, False if this Name is already attached, |
| 208 | -- for a Dispatch or for Default |
| 209 | |
| 210 | SetExtension (me : mutable; ext : HAsciiString from TCollection); |
| 211 | ---Purpose : Defines or Changes the general Extension (which is appended to |
| 212 | -- complete file name generated). If this method is not call, |
| 213 | -- Extension remains empty |
| 214 | |
| 215 | Prefix (me) returns HAsciiString from TCollection; |
| 216 | ---Purpose : Returns the general Prefix. Can be empty. |
| 217 | |
| 218 | DefaultRootName (me) returns HAsciiString from TCollection; |
| 219 | ---Purpose : Returns the Default Root Name. Can be empty. |
| 220 | |
| 221 | Extension (me) returns HAsciiString from TCollection; |
| 222 | ---Purpose : Returns the general Extension. Can be empty (not recommanded) |
| 223 | |
| 224 | FileName (me : mutable; dnum, pnum : Integer; nbpack : Integer = 0) |
| 225 | returns AsciiString from TCollection; |
| 226 | ---Purpose : Computes the complete file name for a Packet of a Dispatch, |
| 227 | -- given Dispatch Number (Rank), Packet Number, and Count of |
| 228 | -- Packets generated by this Dispatch (0 if unknown) |
| 229 | -- |
| 230 | -- File Name is made of following strings, concatenated : |
| 231 | -- General Prefix, Root Name for Dispatch, Packet Suffix, and |
| 232 | -- General Extension. If no Root Name is specified for a |
| 233 | -- Dispatch, DefaultRootName is considered (and pnum is not used, |
| 234 | -- but <thenbdefs> is incremented and used |
| 235 | -- Error if no Root is defined for this <idnum> |
| 236 | |
| 237 | fields |
| 238 | |
| 239 | thedisps : TSeqOfDispatch; |
| 240 | themodelmodifiers : SequenceOfGeneralModifier; |
| 241 | thefilemodifiers : SequenceOfGeneralModifier; |
| 242 | thepref : HAsciiString from TCollection; |
| 243 | thedefrt : HAsciiString from TCollection; |
| 244 | theext : HAsciiString from TCollection; |
| 245 | thenbdefs : Integer; |
| 246 | thelastrun : Integer; |
| 247 | |
| 248 | end ShareOut; |