42cf5bc1 |
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 |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _IFSelect_ShareOut_HeaderFile |
18 | #define _IFSelect_ShareOut_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <IFSelect_TSeqOfDispatch.hxx> |
24 | #include <IFSelect_SequenceOfGeneralModifier.hxx> |
25 | #include <Standard_Integer.hxx> |
26 | #include <MMgt_TShared.hxx> |
27 | #include <Standard_Boolean.hxx> |
28 | class TCollection_HAsciiString; |
29 | class Interface_InterfaceError; |
30 | class Standard_OutOfRange; |
31 | class Standard_Transient; |
32 | class IFSelect_Dispatch; |
33 | class IFSelect_GeneralModifier; |
34 | class IFSelect_Modifier; |
35 | class TCollection_AsciiString; |
36 | |
37 | |
38 | class IFSelect_ShareOut; |
39 | DEFINE_STANDARD_HANDLE(IFSelect_ShareOut, MMgt_TShared) |
40 | |
41 | //! This class gathers the informations required to produce one or |
42 | //! several file(s) from the content of an InterfaceModel (passing |
43 | //! through the creation of intermediate Models). |
44 | //! |
45 | //! It can correspond to a complete Divide up of a set of Entities |
46 | //! intended to be exhaustive and to limit duplications. Or to a |
47 | //! simple Extraction of some Entities, in order to work on them. |
48 | //! |
49 | //! A ShareOut is composed of a list of Dispatches. |
50 | //! To Each Dispatch in the ShareOut, is bound an Id. Number |
51 | //! This Id. Number allows to identify a Display inside the |
52 | //! ShareOut in a stable way (for instance, to attach file names) |
53 | //! |
54 | //! ShareOut can be seen as a "passive" description, activated |
55 | //! through a ShareOutResult, which gives the InterfaceModel on |
56 | //! which to work, as a unique source. Thus it is easy to change |
57 | //! it without coherence problems |
58 | //! |
59 | //! Services about it are provided by the class ShareOutResult |
60 | //! which is a service class : simulation (list of files and of |
61 | //! entities per file; "forgotten" entities; duplicated entities), |
62 | //! exploitation (generation of derivated Models, each of them |
63 | //! generating an output file) |
64 | class IFSelect_ShareOut : public MMgt_TShared |
65 | { |
66 | |
67 | public: |
68 | |
69 | |
70 | //! Creates an empty ShareOut |
71 | Standard_EXPORT IFSelect_ShareOut(); |
72 | |
73 | //! Removes in one operation all the Dispatches with their Idents |
74 | //! Also clears all informations about Names, and all Results but |
75 | //! naming informations which are : |
76 | //! - kept if <onlydisp> is True. |
77 | //! - cleared if <onlydisp> is False (complete clearing) |
78 | //! If <onlydisp> is True, that's all. Else, clears also Modifiers |
79 | Standard_EXPORT void Clear (const Standard_Boolean onlydisp); |
80 | |
81 | //! Clears all data produced (apart from Dispatches, etc...) |
82 | //! if <alsoname> is True, all is cleared. Else, informations |
83 | //! about produced Names are kept (to maintain unicity of naming |
84 | //! across clearings) |
85 | Standard_EXPORT void ClearResult (const Standard_Boolean alsoname); |
86 | |
87 | //! Removes an item, which can be, either a Dispatch (removed from |
88 | //! the list of Dispatches), or a GeneralModifier (removed from |
89 | //! the list of Model Modifiers or from the list of File Modifiers |
90 | //! according to its type). |
91 | //! Returns True if done, False if has not been found or if it is |
92 | //! neither a Dispatch, nor a Modifier. |
93 | Standard_EXPORT Standard_Boolean RemoveItem (const Handle(Standard_Transient)& item); |
94 | |
95 | //! Returns the rank of last run item (ClearResult resets it to 0) |
96 | Standard_EXPORT Standard_Integer LastRun() const; |
97 | |
98 | //! Records a new alue for the rank of last run item |
99 | Standard_EXPORT void SetLastRun (const Standard_Integer last); |
100 | |
101 | //! Returns the count of Dispatches |
102 | Standard_EXPORT Standard_Integer NbDispatches() const; |
103 | |
104 | //! Returns the Rank of a Dispatch, given its Value (Handle). |
105 | //! Returns 0 if the Dispatch is unknown in the ShareOut |
106 | Standard_EXPORT Standard_Integer DispatchRank (const Handle(IFSelect_Dispatch)& disp) const; |
107 | |
108 | //! Returns a Dispatch, given its rank in the list |
109 | Standard_EXPORT const Handle(IFSelect_Dispatch)& Dispatch (const Standard_Integer num) const; |
110 | |
111 | //! Adds a Dispatch to the list |
112 | Standard_EXPORT void AddDispatch (const Handle(IFSelect_Dispatch)& disp); |
113 | |
114 | //! Removes a Dispatch, given its rank in the list |
115 | //! Returns True if done, False if rank is not between |
116 | //! (LastRun + 1) and (NbDispatches) |
117 | Standard_EXPORT Standard_Boolean RemoveDispatch (const Standard_Integer rank); |
118 | |
119 | //! Sets a Modifier to be applied on all Dispatches to be run |
120 | //! If <modifier> is a ModelModifier, adds it to the list of |
121 | //! Model Modifiers; else to the list of File Modifiers |
122 | //! By default (atnum = 0) at the end of the list, else at <atnum> |
123 | //! Each Modifier is used, after each copy of a packet of Entities |
124 | //! into a Model : its criteria are checked and if they are OK, |
125 | //! the method Perform of this Modifier is run. |
126 | Standard_EXPORT void AddModifier (const Handle(IFSelect_GeneralModifier)& modifier, const Standard_Integer atnum); |
127 | |
128 | //! Sets a Modifier to be applied on the Dispatch <dispnum> |
129 | //! If <modifier> is a ModelModifier, adds it to the list of |
130 | //! Model Modifiers; else to the list of File Modifiers |
131 | //! This is the same list as for all Dispatches, but the |
132 | //! Modifier is qualified to be applied to one Dispatch only |
133 | //! Then, <atnum> refers to the entire list |
134 | //! By default (atnum = 0) at the end of the list, else at <atnum> |
135 | //! Remark : if the Modifier was already in the list and if |
136 | //! <atnum> = 0, the Modifier is not moved, but only qualified |
137 | //! for a Dispatch |
138 | Standard_EXPORT void AddModifier (const Handle(IFSelect_GeneralModifier)& modifier, const Standard_Integer dispnum, const Standard_Integer atnum); |
139 | |
140 | //! Adds a Modifier to the list of Modifiers : Model Modifiers if |
141 | //! <formodel> is True, File Modifiers else (internal). |
142 | Standard_EXPORT void AddModif (const Handle(IFSelect_GeneralModifier)& modifier, const Standard_Boolean formodel, const Standard_Integer atnum = 0); |
143 | |
144 | //! Returns count of Modifiers (which apply to complete Models) : |
145 | //! Model Modifiers if <formodel> is True, File Modifiers else |
146 | Standard_EXPORT Standard_Integer NbModifiers (const Standard_Boolean formodel) const; |
147 | |
148 | //! Returns a Modifier of the list, given its rank : |
149 | //! Model Modifiers if <formodel> is True, File Modifiers else |
150 | Standard_EXPORT Handle(IFSelect_GeneralModifier) GeneralModifier (const Standard_Boolean formodel, const Standard_Integer num) const; |
151 | |
152 | //! Returns a Modifier of the list of Model Modifiers, duely casted |
153 | Standard_EXPORT Handle(IFSelect_Modifier) ModelModifier (const Standard_Integer num) const; |
154 | |
155 | //! Gives the rank of a Modifier in the list, 0 if not in the list |
156 | //! Model Modifiers if <modifier> is kind of ModelModifer, |
157 | //! File Modifiers else |
158 | Standard_EXPORT Standard_Integer ModifierRank (const Handle(IFSelect_GeneralModifier)& modifier) const; |
159 | |
160 | //! Removes a Modifier, given it rank in the list : |
161 | //! Model Modifiers if <formodel> is True, File Modifiers else |
162 | //! Returns True if done, False if <num> is out of range |
163 | Standard_EXPORT Standard_Boolean RemoveModifier (const Standard_Boolean formodel, const Standard_Integer num); |
164 | |
165 | //! Changes the rank of a modifier in the list : |
166 | //! Model Modifiers if <formodel> is True, File Modifiers else |
167 | //! from <before> to <after> |
168 | //! Returns True if done, False else (before or after out of range) |
169 | Standard_EXPORT Standard_Boolean ChangeModifierRank (const Standard_Boolean formodel, const Standard_Integer befor, const Standard_Integer after); |
170 | |
171 | //! Attaches a Root Name to a Dispatch given its rank, as an |
172 | //! HAsciiString (standard form). A Null Handle resets this name. |
173 | //! Returns True if OK, False if this Name is already attached, |
174 | //! for a Dispatch or for Default, or <num> out of range |
175 | Standard_EXPORT Standard_Boolean SetRootName (const Standard_Integer num, const Handle(TCollection_HAsciiString)& name); |
176 | |
177 | //! Returns True if the Dispatch of rank <num> has an attached |
178 | //! Root Name. False else, or if num is out of range |
179 | Standard_EXPORT Standard_Boolean HasRootName (const Standard_Integer num) const; |
180 | |
181 | //! Returns the Root bound to a Dispatch, given its rank |
182 | //! Returns a Null Handle if not defined |
183 | Standard_EXPORT Handle(TCollection_HAsciiString) RootName (const Standard_Integer num) const; |
184 | |
185 | //! Returns an integer value about a given root name : |
186 | //! - positive : it's the rank of the Dispatch which has this name |
187 | //! - null : this root name is unknown |
188 | //! - negative (-1) : this root name is the default root name |
189 | Standard_EXPORT Standard_Integer RootNumber (const Handle(TCollection_HAsciiString)& name) const; |
190 | |
191 | //! Defines or Changes the general Prefix (which is prepended to |
192 | //! complete file name generated). If this method is not call, |
193 | //! Prefix remains empty |
194 | Standard_EXPORT void SetPrefix (const Handle(TCollection_HAsciiString)& pref); |
195 | |
196 | //! Defines or Changes the Default Root Name to a new value (which |
197 | //! is used for dispatches which have no attached root name). |
198 | //! If this method is not called, DefaultRootName remains empty |
199 | //! Returns True if OK, False if this Name is already attached, |
200 | //! for a Dispatch or for Default |
201 | Standard_EXPORT Standard_Boolean SetDefaultRootName (const Handle(TCollection_HAsciiString)& defrt); |
202 | |
203 | //! Defines or Changes the general Extension (which is appended to |
204 | //! complete file name generated). If this method is not call, |
205 | //! Extension remains empty |
206 | Standard_EXPORT void SetExtension (const Handle(TCollection_HAsciiString)& ext); |
207 | |
208 | //! Returns the general Prefix. Can be empty. |
209 | Standard_EXPORT Handle(TCollection_HAsciiString) Prefix() const; |
210 | |
211 | //! Returns the Default Root Name. Can be empty. |
212 | Standard_EXPORT Handle(TCollection_HAsciiString) DefaultRootName() const; |
213 | |
214 | //! Returns the general Extension. Can be empty (not recommanded) |
215 | Standard_EXPORT Handle(TCollection_HAsciiString) Extension() const; |
216 | |
217 | //! Computes the complete file name for a Packet of a Dispatch, |
218 | //! given Dispatch Number (Rank), Packet Number, and Count of |
219 | //! Packets generated by this Dispatch (0 if unknown) |
220 | //! |
221 | //! File Name is made of following strings, concatenated : |
222 | //! General Prefix, Root Name for Dispatch, Packet Suffix, and |
223 | //! General Extension. If no Root Name is specified for a |
224 | //! Dispatch, DefaultRootName is considered (and pnum is not used, |
225 | //! but <thenbdefs> is incremented and used |
226 | //! Error if no Root is defined for this <idnum> |
227 | Standard_EXPORT TCollection_AsciiString FileName (const Standard_Integer dnum, const Standard_Integer pnum, const Standard_Integer nbpack = 0); |
228 | |
229 | |
230 | |
231 | |
92efcf78 |
232 | DEFINE_STANDARD_RTTIEXT(IFSelect_ShareOut,MMgt_TShared) |
42cf5bc1 |
233 | |
234 | protected: |
235 | |
236 | |
237 | |
238 | |
239 | private: |
240 | |
241 | |
242 | IFSelect_TSeqOfDispatch thedisps; |
243 | IFSelect_SequenceOfGeneralModifier themodelmodifiers; |
244 | IFSelect_SequenceOfGeneralModifier thefilemodifiers; |
245 | Handle(TCollection_HAsciiString) thepref; |
246 | Handle(TCollection_HAsciiString) thedefrt; |
247 | Handle(TCollection_HAsciiString) theext; |
248 | Standard_Integer thenbdefs; |
249 | Standard_Integer thelastrun; |
250 | |
251 | |
252 | }; |
253 | |
254 | |
255 | |
256 | |
257 | |
258 | |
259 | |
260 | #endif // _IFSelect_ShareOut_HeaderFile |