1 // Created on: 1995-03-13
2 // Created by: Christian CAILLET
3 // Copyright (c) 1995-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 #ifndef _XSControl_Controller_HeaderFile
18 #define _XSControl_Controller_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <TCollection_AsciiString.hxx>
24 #include <TColStd_SequenceOfTransient.hxx>
25 #include <TColStd_HSequenceOfHAsciiString.hxx>
26 #include <TColStd_SequenceOfInteger.hxx>
27 #include <Interface_HArray1OfHAsciiString.hxx>
28 #include <MMgt_TShared.hxx>
29 #include <Standard_CString.hxx>
30 #include <Standard_Integer.hxx>
31 #include <Standard_Boolean.hxx>
32 #include <IFSelect_ReturnStatus.hxx>
33 class MoniTool_Profile;
34 class IFSelect_WorkLibrary;
35 class Interface_Protocol;
36 class IFSelect_Signature;
37 class Transfer_ActorOfTransientProcess;
38 class Transfer_ActorOfFinderProcess;
39 class Dico_DictionaryOfTransient;
40 class Standard_DomainError;
41 class XSControl_WorkSession;
42 class Interface_InterfaceModel;
43 class Standard_Transient;
44 class Transfer_FinderProcess;
46 class Interface_CheckIterator;
49 class XSControl_Controller;
50 DEFINE_STANDARD_HANDLE(XSControl_Controller, MMgt_TShared)
52 //! This class allows a general X-STEP engine to run generic
53 //! functions on any interface norm, in the same way. It includes
54 //! the transfer operations. I.e. it gathers the already available
55 //! general modules, the engine has just to know it
57 //! The important point is that a given X-STEP Controller is
58 //! attached to a given couple made of an Interface Norm (such as
59 //! IGES-5.1) and an application data model (CasCade Shapes for
62 //! A Controller brings a Profile, this allows to have several
63 //! variants on the same basic definition, for instance keep the
64 //! norm definition but give several transfer actors, etc
66 //! Finally, Controller can be gathered in a general dictionary then
67 //! retreived later by a general call (method Recorded)
69 //! It does not manage the produced data, but the Actors make the
70 //! link between the norm and the application
71 class XSControl_Controller : public MMgt_TShared
78 //! if a name is empty, the formerly set one remains
79 //! Remark : Does not call Record or AutoRecord
80 Standard_EXPORT void SetNames (const Standard_CString longname, const Standard_CString shortname);
82 //! Records <me> is a general dictionary under Short and Long
83 //! Names (see method Name)
84 Standard_EXPORT void AutoRecord() const;
86 //! Records <me> in a general dictionary under a name
87 //! Error if <name> already used for another one
88 Standard_EXPORT void Record (const Standard_CString name) const;
90 //! Returns the Controller attached to a given name
91 //! Returns a Null Handle if <name> is unknown
92 Standard_EXPORT static Handle(XSControl_Controller) Recorded (const Standard_CString name);
94 //! Returns the list of names of recorded norms, according to mode
95 //! = 0 (D) : all the recorded names
96 //! < 0 : for each distinct norm, its resource (short) name
97 //! > 0 : for each distinct norm, its complete (long) name
98 Standard_EXPORT static Handle(TColStd_HSequenceOfHAsciiString) ListRecorded (const Standard_Integer mode = 0);
100 //! Returns a name, as given when initializing :
101 //! rsc = False (D) : True Name attached to the Norm (long name)
102 //! rsc = True : Name of the ressource set (i.e. short name)
103 Standard_EXPORT Standard_CString Name (const Standard_Boolean rsc = Standard_False) const;
105 //! Returns the Profile
106 //! It starts with a first configuration Base (empty) and the
107 //! following options :
108 //! protocol for the Protocol
109 //! sign-type for the SignType (Default Signature for Type)
110 //! access for the WorkLibrary
111 //! tr-read for ActorRead (import processor)
112 //! tr-write for ActorWrite (export processor)
113 Standard_EXPORT Handle(MoniTool_Profile) Profile() const;
115 //! Considers the current state of the Controller as defining a
116 //! configuration, newly created or already existing
117 Standard_EXPORT void DefineProfile (const Standard_CString confname);
119 //! Sets the Controller in a given Configuration of its Profile
120 //! Calls SettingProfile (which can be redefined)
122 //! Returns True if done, False if <confname> unknown
123 Standard_EXPORT Standard_Boolean SetProfile (const Standard_CString confname);
125 //! This method is called by SetProfile, it can be redefined
126 //! for specific sub-class of Controller
127 //! The default does nothing
128 Standard_EXPORT virtual Standard_Boolean SettingProfile (const Standard_CString confname);
130 //! Applies a Configuration of the Profile to the WorkSession
131 //! I.E. calls SetProfile then fills WorkSession with definitions
132 Standard_EXPORT Standard_Boolean ApplyProfile (const Handle(XSControl_WorkSession)& WS, const Standard_CString confname);
134 //! Called by ApplyProfile, can be redefined for specific
135 //! sub-class of Controller
136 //! The default does nothing
137 Standard_EXPORT virtual Standard_Boolean ApplyingProfile (const Handle(XSControl_WorkSession)& WS, const Standard_CString confname);
139 //! Returns the Protocol attached to the Norm (from field)
140 Standard_EXPORT Handle(Interface_Protocol) Protocol() const;
142 //! Returns the SignType attached to the norm (from field)
143 Standard_EXPORT Handle(IFSelect_Signature) SignType() const;
145 //! Returns the WorkLibrary attached to the Norm. Remark that it
146 //! has to be in phase with the Protocol (read from field)
147 Standard_EXPORT Handle(IFSelect_WorkLibrary) WorkLibrary() const;
149 //! Creates a new empty Model ready to receive data of the Norm
150 //! Used to write data from Imagine to an interface file
151 Standard_EXPORT virtual Handle(Interface_InterfaceModel) NewModel() const = 0;
153 //! Returns the Actor for Read attached to the pair (norm,appli)
154 //! It can be adapted for data of the input Model, as required
155 //! Can be read from field then adapted with Model as required
156 Standard_EXPORT virtual Handle(Transfer_ActorOfTransientProcess) ActorRead (const Handle(Interface_InterfaceModel)& model) const = 0;
158 //! Returns the Actor for Write attached to the pair (norm,appli)
159 //! Read from field. Can be redefined
160 Standard_EXPORT virtual Handle(Transfer_ActorOfFinderProcess) ActorWrite() const;
162 //! Updates static values
163 //! <mode> precises the kind of updating : (see Items from Static)
164 //! -1 : a precise static item : criter = its name
165 //! 0 : all items of a family : criter = the family name
166 //! 1 : all items which match regexp name : criter = regexp name
167 //! By default (criter empty) should consider all relevant statics
168 //! If <name> is defined, can consider only this static item
169 //! The provided default method does nothing, to be redefined
170 Standard_EXPORT virtual void UpdateStatics (const Standard_Integer mode, const Standard_CString criter = "") const;
172 //! Sets mininum and maximum values for modetrans (write)
173 //! Erases formerly recorded bounds and values
174 //! Actually only for shape
175 //! Then, for each value a little help can be attached
176 Standard_EXPORT void SetModeWrite (const Standard_Integer modemin, const Standard_Integer modemax, const Standard_Boolean shape = Standard_True);
178 //! Attaches a short line of help to a value of modetrans (write)
179 Standard_EXPORT void SetModeWriteHelp (const Standard_Integer modetrans, const Standard_CString help, const Standard_Boolean shape = Standard_True);
181 //! Returns recorded min and max values for modetrans (write)
182 //! Actually only for shapes
183 //! Returns True if bounds are set, False else (then, free value)
184 Standard_EXPORT Standard_Boolean ModeWriteBounds (Standard_Integer& modemin, Standard_Integer& modemax, const Standard_Boolean shape = Standard_True) const;
186 //! Tells if a value of <modetrans> is a good value(within bounds)
187 //! Actually only for shapes
188 Standard_EXPORT Standard_Boolean IsModeWrite (const Standard_Integer modetrans, const Standard_Boolean shape = Standard_True) const;
190 //! Returns the help line recorded for a value of modetrans
191 //! empty if help not defined or not within bounds or if values are free
192 Standard_EXPORT Standard_CString ModeWriteHelp (const Standard_Integer modetrans, const Standard_Boolean shape = Standard_True) const;
194 //! Tells if <obj> (an application object) is a valid candidate
195 //! for a transfer to a Model.
196 //! By default, asks the ActorWrite if known (through a
197 //! TransientMapper). Can be redefined
198 Standard_EXPORT virtual Standard_Boolean RecognizeWriteTransient (const Handle(Standard_Transient)& obj, const Standard_Integer modetrans = 0) const;
200 //! Takes one Transient Object and transfers it to an
201 //! InterfaceModel (already created, e.g. by NewModel)
202 //! (result is recorded in the model by AddWithRefs)
203 //! FP records produced results and checks
205 //! Default uses ActorWrite; can be redefined as necessary
206 //! Returned value is a status, as follows :
207 //! 0 OK , 1 No Result , 2 Fail (e.g. exception raised)
208 //! -1 bad conditions , -2 bad model or null model
209 //! For type of object not recognized : should return 1
210 Standard_EXPORT virtual IFSelect_ReturnStatus TransferWriteTransient (const Handle(Standard_Transient)& obj, const Handle(Transfer_FinderProcess)& FP, const Handle(Interface_InterfaceModel)& model, const Standard_Integer modetrans = 0) const;
212 //! Tells if a shape is valid for a transfer to a model
213 //! Asks the ActorWrite (through a ShapeMapper)
214 Standard_EXPORT virtual Standard_Boolean RecognizeWriteShape (const TopoDS_Shape& shape, const Standard_Integer modetrans = 0) const;
216 //! Takes one Shape and transfers it to an
217 //! InterfaceModel (already created, e.g. by NewModel)
218 //! Default uses ActorWrite; can be redefined as necessary
219 //! Returned value is a status, as follows :
220 //! Done OK , Void : No Result , Fail : Fail (e.g. exception)
221 //! Error : bad conditions , bad model or null model
222 //! Resolution of file clusters
223 //! According to each norm, there can (or not) be files of which
224 //! definition is not complete but refers to other files : this defines
226 //! It can then be resolved by two calls :
227 //! - ClusterContext prepares the resolution, specific of each case
228 //! - ResolveCluster performs the resolution, its result consists in
229 //! having all data gathered in one final model
230 Standard_EXPORT virtual IFSelect_ReturnStatus TransferWriteShape (const TopoDS_Shape& shape, const Handle(Transfer_FinderProcess)& FP, const Handle(Interface_InterfaceModel)& model, const Standard_Integer modetrans = 0) const;
232 //! Prepares and returns a context to resolve a cluster
233 //! All data to be used are detained by the WorkSession
234 //! The definition of this context is free and proper to each case
235 //! remark that it is aimed to be used in ResolveCluster
237 //! The context must be prepared, but resolution must not have
240 //! If no cluster has to be resolved, should return a null handle
241 //! This is the default case, which can be redefined
242 Standard_EXPORT virtual Handle(Standard_Transient) ClusterContext (const Handle(XSControl_WorkSession)& WS) const;
244 //! Performs the resolution itself, from the starting data and
245 //! the cluster context
247 //! Can fill a CheckList as necessary (especially when one or
248 //! more references remain unresolved)
250 //! Default does nothing and returns an empty CheckList
251 Standard_EXPORT virtual Interface_CheckIterator ResolveCluster (const Handle(XSControl_WorkSession)& WS, const Handle(Standard_Transient)& context) const;
253 //! Adds an item in the control list
254 //! A control item of a controller is accessed by its name which
255 //! is specific of a kind of item (i.e. a kind of functionnality)
256 //! Adds or replaces if <name> is already recorded
257 Standard_EXPORT void AddControlItem (const Handle(Standard_Transient)& item, const Standard_CString name);
259 //! Returns a control item from its name, Null if <name> unknown
260 //! To be used then, it just remains to be down-casted
261 Standard_EXPORT Handle(Standard_Transient) ControlItem (const Standard_CString name) const;
263 //! Records the name of a Static to be traced for a given use
264 Standard_EXPORT void TraceStatic (const Standard_CString name, const Standard_Integer use);
266 //! Records a Session Item, to be added for customisation of the
267 //! Work Session. It must have a specific name.
268 //! <setapplied> is used if <item> is a GeneralModifier, to decide
269 //! to which hook list it will be applied, if not empty (else,
270 //! not applied to any hook list)
271 //! ACTUAL : only one hook list is managed : "send"
272 //! Remark : this method is to be called at Create time, the
273 //! recorded items will be used by Customise
274 //! Warning : if <name> conflicts, the last recorded item is kept
275 Standard_EXPORT void AddSessionItem (const Handle(Standard_Transient)& item, const Standard_CString name, const Standard_CString setapplied = "");
277 //! Returns an item given its name to record in a Session
278 //! If <name> is unknown, returns a Null Handle
279 Standard_EXPORT Handle(Standard_Transient) SessionItem (const Standard_CString name) const;
281 //! Returns True if <item> is recorded as <setapplied = True>
282 Standard_EXPORT Standard_Boolean IsApplied (const Handle(Standard_Transient)& item) const;
284 //! Customises a WorkSession, by adding to it the recorded items
285 //! (by AddSessionItem), then by calling a specific method
286 //! Customising, set by default to do nothing
287 Standard_EXPORT virtual void Customise (Handle(XSControl_WorkSession)& WS);
289 //! Specific customisation method, which can be redefined
290 //! Default does nothing
291 Standard_EXPORT void Customising (Handle(XSControl_WorkSession)& WS);
293 Standard_EXPORT Handle(Dico_DictionaryOfTransient) AdaptorSession() const;
298 DEFINE_STANDARD_RTTIEXT(XSControl_Controller,MMgt_TShared)
303 //! Initializing with names
304 //! <longname> is for the complete, official, long name
305 //! <shortname> is for the short name used for resources
306 Standard_EXPORT XSControl_Controller(const Standard_CString longname, const Standard_CString shortname);
308 TCollection_AsciiString theShortName;
309 TCollection_AsciiString theLongName;
310 Handle(IFSelect_WorkLibrary) theAdaptorLibrary;
311 Handle(Interface_Protocol) theAdaptorProtocol;
312 Handle(IFSelect_Signature) theSignType;
313 Handle(Transfer_ActorOfTransientProcess) theAdaptorRead;
314 Handle(Transfer_ActorOfFinderProcess) theAdaptorWrite;
315 Handle(Dico_DictionaryOfTransient) theAdaptorSession;
321 Handle(MoniTool_Profile) theProfile;
322 Handle(Dico_DictionaryOfTransient) theItems;
323 TColStd_SequenceOfTransient theAdaptorApplied;
324 Handle(TColStd_HSequenceOfHAsciiString) theAdaptorHooks;
325 TColStd_SequenceOfTransient theParams;
326 TColStd_SequenceOfInteger theParamUses;
327 Handle(Interface_HArray1OfHAsciiString) theModeWriteShapeN;
338 #endif // _XSControl_Controller_HeaderFile