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