|
||||
File indexing completed on 2025-01-18 10:05:29
0001 // Created on: 1992-02-03 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1992-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _Transfer_ProcessForFinder_HeaderFile 0018 #define _Transfer_ProcessForFinder_HeaderFile 0019 0020 #include <TColStd_IndexedMapOfInteger.hxx> 0021 #include <Transfer_HSequenceOfFinder.hxx> 0022 #include <Transfer_TransferMapOfProcessForFinder.hxx> 0023 #include <Message_ProgressRange.hxx> 0024 0025 class Message_Messenger; 0026 class Transfer_Finder; 0027 class Transfer_Binder; 0028 class Transfer_ActorOfProcessForFinder; 0029 class Interface_InterfaceError; 0030 class Transfer_TransferFailure; 0031 class Transfer_FindHasher; 0032 class Transfer_IteratorOfProcessForFinder; 0033 class Message_Msg; 0034 class Interface_Check; 0035 class Standard_Transient; 0036 class Interface_CheckIterator; 0037 0038 0039 class Transfer_ProcessForFinder; 0040 DEFINE_STANDARD_HANDLE(Transfer_ProcessForFinder, Standard_Transient) 0041 0042 0043 class Transfer_ProcessForFinder : public Standard_Transient 0044 { 0045 0046 public: 0047 0048 0049 //! Sets TransferProcess at initial state. Gives an Initial size 0050 //! (indicative) for the Map when known (default is 10000). 0051 //! Sets default trace file as a printer and default trace level 0052 //! (see Message_TraceFile). 0053 Standard_EXPORT Transfer_ProcessForFinder(const Standard_Integer nb = 10000); 0054 0055 //! Sets TransferProcess at initial state. Gives an Initial size 0056 //! (indicative) for the Map when known (default is 10000). 0057 //! Sets a specified printer. 0058 Standard_EXPORT Transfer_ProcessForFinder(const Handle(Message_Messenger)& printer, const Standard_Integer nb = 10000); 0059 0060 //! Resets a TransferProcess as ready for a completely new work. 0061 //! Clears general data (roots) and the Map 0062 Standard_EXPORT void Clear(); 0063 0064 //! Rebuilds the Map and the roots to really remove Unbound items 0065 //! Because Unbind keeps the entity in place, even if not bound 0066 //! Hence, working by checking new items is meaningless if a 0067 //! formerly unbound item is rebound 0068 Standard_EXPORT void Clean(); 0069 0070 //! Resizes the Map as required (if a new reliable value has been 0071 //! determined). Acts only if <nb> is greater than actual NbMapped 0072 Standard_EXPORT void Resize (const Standard_Integer nb); 0073 0074 //! Defines an Actor, which is used for automatic Transfer 0075 //! If already defined, the new Actor is cumulated 0076 //! (see SetNext from Actor) 0077 Standard_EXPORT void SetActor (const Handle(Transfer_ActorOfProcessForFinder)& actor); 0078 0079 //! Returns the defined Actor. Returns a Null Handle if 0080 //! not set. 0081 Standard_EXPORT Handle(Transfer_ActorOfProcessForFinder) Actor() const; 0082 0083 //! Returns the Binder which is linked with a starting Object 0084 //! It can either bring a Result (Transfer done) or none (for a 0085 //! pre-binding). 0086 //! If no Binder is linked with <start>, returns a Null Handle 0087 //! Considers a category number, by default 0 0088 Standard_EXPORT Handle(Transfer_Binder) Find (const Handle(Transfer_Finder)& start) const; 0089 0090 //! Returns True if a Result (whatever its form) is Bound with 0091 //! a starting Object. I.e., if a Binder with a Result set, 0092 //! is linked with it 0093 //! Considers a category number, by default 0 0094 Standard_EXPORT Standard_Boolean IsBound (const Handle(Transfer_Finder)& start) const; 0095 0096 //! Returns True if the result of the transfer of an object is 0097 //! already used in other ones. If it is, Rebind cannot change it. 0098 //! Considers a category number, by default 0 0099 Standard_EXPORT Standard_Boolean IsAlreadyUsed (const Handle(Transfer_Finder)& start) const; 0100 0101 //! Creates a Link a starting Object with a Binder. This Binder 0102 //! can either bring a Result (effective Binding) or none (it can 0103 //! be set later : pre-binding). 0104 //! Considers a category number, by default 0 0105 Standard_EXPORT void Bind (const Handle(Transfer_Finder)& start, const Handle(Transfer_Binder)& binder); 0106 0107 //! Changes the Binder linked with a starting Object for its 0108 //! unitary transfer. This it can be useful when the exact form 0109 //! of the result is known once the transfer is widely engaged. 0110 //! This can be done only on first transfer. 0111 //! Considers a category number, by default 0 0112 Standard_EXPORT void Rebind (const Handle(Transfer_Finder)& start, const Handle(Transfer_Binder)& binder); 0113 0114 //! Removes the Binder linked with a starting object 0115 //! If this Binder brings a non-empty Check, it is replaced by 0116 //! a VoidBinder. Also removes from the list of Roots as required. 0117 //! Returns True if done, False if <start> was not bound 0118 //! Considers a category number, by default 0 0119 Standard_EXPORT Standard_Boolean Unbind (const Handle(Transfer_Finder)& start); 0120 0121 //! Returns a Binder for a starting entity, as follows : 0122 //! Tries to Find the already bound one 0123 //! If none found, creates a VoidBinder and Binds it 0124 Standard_EXPORT Handle(Transfer_Binder) FindElseBind (const Handle(Transfer_Finder)& start); 0125 0126 //! Sets Messenger used for outputting messages. 0127 Standard_EXPORT void SetMessenger (const Handle(Message_Messenger)& messenger); 0128 0129 //! Returns Messenger used for outputting messages. 0130 //! The returned object is guaranteed to be non-null; 0131 //! default is Message::Messenger(). 0132 Standard_EXPORT Handle(Message_Messenger) Messenger() const; 0133 0134 //! Sets trace level used for outputting messages: 0135 //! <trace> = 0 : no trace at all 0136 //! <trace> = 1 : handled exceptions and calls to AddError 0137 //! <trace> = 2 : also calls to AddWarning 0138 //! <trace> = 3 : also traces new Roots 0139 //! (uses method ErrorTrace). 0140 //! Default is 1 : Errors traced 0141 Standard_EXPORT void SetTraceLevel (const Standard_Integer tracelev); 0142 0143 //! Returns trace level used for outputting messages. 0144 Standard_EXPORT Standard_Integer TraceLevel() const; 0145 0146 //! New name for AddFail (Msg) 0147 Standard_EXPORT void SendFail (const Handle(Transfer_Finder)& start, const Message_Msg& amsg); 0148 0149 //! New name for AddWarning (Msg) 0150 Standard_EXPORT void SendWarning (const Handle(Transfer_Finder)& start, const Message_Msg& amsg); 0151 0152 //! Adds an information message 0153 //! Trace is filled if trace level is at least 3 0154 Standard_EXPORT void SendMsg (const Handle(Transfer_Finder)& start, const Message_Msg& amsg); 0155 0156 //! Adds an Error message to a starting entity (to the check of 0157 //! its Binder of category 0, as a Fail) 0158 Standard_EXPORT void AddFail (const Handle(Transfer_Finder)& start, const Standard_CString mess, const Standard_CString orig = ""); 0159 0160 //! (other name of AddFail, maintained for compatibility) 0161 Standard_EXPORT void AddError (const Handle(Transfer_Finder)& start, const Standard_CString mess, const Standard_CString orig = ""); 0162 0163 //! Adds an Error Message to a starting entity from the definition 0164 //! of a Msg (Original+Value) 0165 Standard_EXPORT void AddFail (const Handle(Transfer_Finder)& start, const Message_Msg& amsg); 0166 0167 //! Adds a Warning message to a starting entity (to the check of 0168 //! its Binder of category 0) 0169 Standard_EXPORT void AddWarning (const Handle(Transfer_Finder)& start, const Standard_CString mess, const Standard_CString orig = ""); 0170 0171 //! Adds a Warning Message to a starting entity from the definition 0172 //! of a Msg (Original+Value) 0173 Standard_EXPORT void AddWarning (const Handle(Transfer_Finder)& start, const Message_Msg& amsg); 0174 0175 Standard_EXPORT void Mend (const Handle(Transfer_Finder)& start, const Standard_CString pref = ""); 0176 0177 //! Returns the Check attached to a starting entity. If <start> 0178 //! is unknown, returns an empty Check 0179 //! Adds a case name to a starting entity 0180 //! Adds a case value to a starting entity 0181 //! Returns the complete case list for an entity. Null Handle if empty 0182 //! In the list of mapped items (between 1 and NbMapped), 0183 //! searches for the first item which follows <num0>(not included) 0184 //! and which has an attribute named <name> 0185 //! Attributes are brought by Binders 0186 //! Hence, allows such an iteration 0187 //! 0188 //! for (num = TP->NextItemWithAttribute(name,0); 0189 //! num > 0; 0190 //! num = TP->NextItemWithAttribute(name,num) { 0191 //! .. process mapped item <num> 0192 //! } 0193 //! Returns the type of an Attribute attached to binders 0194 //! If this name gives no Attribute, returns ParamVoid 0195 //! If this name gives several different types, returns ParamMisc 0196 //! Else, returns the effective type (ParamInteger, ParamReal, 0197 //! ParamIdent, or ParamText) 0198 //! Returns the list of recorded Attribute Names, as a Dictionary 0199 //! of Integer : each value gives the count of items which bring 0200 //! this attribute name 0201 //! By default, considers all the attribute names 0202 //! If <rootname> is given, considers only the attribute names 0203 //! which begin by <rootname> 0204 Standard_EXPORT Handle(Interface_Check) Check (const Handle(Transfer_Finder)& start) const; 0205 0206 //! Binds a starting object with a Transient Result. 0207 //! Uses a SimpleBinderOfTransient to work. If there is already 0208 //! one but with no Result set, sets its Result. 0209 //! Considers a category number, by default 0 0210 Standard_EXPORT void BindTransient (const Handle(Transfer_Finder)& start, const Handle(Standard_Transient)& res); 0211 0212 //! Returns the Result of the Transfer of an object <start> as a 0213 //! Transient Result. 0214 //! Returns a Null Handle if there is no Transient Result 0215 //! Considers a category number, by default 0 0216 //! Warning : Supposes that Binding is done with a SimpleBinderOfTransient 0217 Standard_EXPORT const Handle(Standard_Transient)& FindTransient (const Handle(Transfer_Finder)& start) const; 0218 0219 //! Prepares an object <start> to be bound with several results. 0220 //! If no Binder is yet attached to <obj>, a MultipleBinder 0221 //! is created, empty. If a Binder is already set, it must 0222 //! accept Multiple Binding. 0223 //! Considers a category number, by default 0 0224 Standard_EXPORT void BindMultiple (const Handle(Transfer_Finder)& start); 0225 0226 //! Adds an item to a list of results bound to a starting object. 0227 //! Considers a category number, by default 0, for all results 0228 Standard_EXPORT void AddMultiple (const Handle(Transfer_Finder)& start, const Handle(Standard_Transient)& res); 0229 0230 //! Searches for a transient result attached to a starting object, 0231 //! according to its type, by criterium IsKind(atype) 0232 //! 0233 //! In case of multiple result, explores the list and gives in 0234 //! <val> the first transient result IsKind(atype) 0235 //! Returns True and fills <val> if found 0236 //! Else, returns False (<val> is not touched, not even nullified) 0237 //! 0238 //! This syntactic form avoids to do DownCast : if a result is 0239 //! found with the good type, it is loaded in <val> and can be 0240 //! immediately used, well initialised 0241 Standard_EXPORT Standard_Boolean FindTypedTransient (const Handle(Transfer_Finder)& start, const Handle(Standard_Type)& atype, Handle(Standard_Transient)& val) const; 0242 0243 //! Safe variant for arbitrary type of argument 0244 template <class T> 0245 Standard_Boolean FindTypedTransient (const Handle(Transfer_Finder)& start, const Handle(Standard_Type)& atype, Handle(T)& val) const 0246 { 0247 Handle(Standard_Transient) aVal = val; 0248 return FindTypedTransient (start, atype, aVal) && ! (val = Handle(T)::DownCast(aVal)).IsNull(); 0249 } 0250 0251 //! Searches for a transient result recorded in a Binder, whatever 0252 //! this Binder is recorded or not in <me> 0253 //! 0254 //! This is strictly equivalent to the class method GetTypedResult 0255 //! from class SimpleBinderOfTransient, but is just lighter to call 0256 //! 0257 //! Apart from this, works as FindTypedTransient 0258 Standard_EXPORT Standard_Boolean GetTypedTransient (const Handle(Transfer_Binder)& binder, const Handle(Standard_Type)& atype, Handle(Standard_Transient)& val) const; 0259 0260 //! Safe variant for arbitrary type of argument 0261 template <class T> 0262 Standard_Boolean GetTypedTransient (const Handle(Transfer_Binder)& start, const Handle(Standard_Type)& atype, Handle(T)& val) const 0263 { 0264 Handle(Standard_Transient) aVal = val; 0265 return GetTypedTransient (start, atype, aVal) && ! (val = Handle(T)::DownCast(aVal)).IsNull(); 0266 } 0267 0268 //! Returns the maximum possible value for Map Index 0269 //! (no result can be bound with a value greater than it) 0270 Standard_EXPORT Standard_Integer NbMapped() const; 0271 0272 //! Returns the Starting Object bound to an Index, 0273 Standard_EXPORT const Handle(Transfer_Finder)& Mapped (const Standard_Integer num) const; 0274 0275 //! Returns the Index value bound to a Starting Object, 0 if none 0276 Standard_EXPORT Standard_Integer MapIndex (const Handle(Transfer_Finder)& start) const; 0277 0278 //! Returns the Binder bound to an Index 0279 //! Considers a category number, by default 0 0280 Standard_EXPORT Handle(Transfer_Binder) MapItem (const Standard_Integer num) const; 0281 0282 //! Declares <obj> (and its Result) as Root. This status will be 0283 //! later exploited by RootResult, see below (Result can be 0284 //! produced at any time) 0285 Standard_EXPORT void SetRoot (const Handle(Transfer_Finder)& start); 0286 0287 //! Enable (if <stat> True) or Disables (if <stat> False) Root 0288 //! Management. If it is set, Transfers are considered as stacked 0289 //! (a first Transfer commands other Transfers, and so on) and 0290 //! the Transfers commanded by an external caller are "Root". 0291 //! Remark : SetRoot can be called whatever this status, on every 0292 //! object. 0293 //! Default is set to True. 0294 Standard_EXPORT void SetRootManagement (const Standard_Boolean stat); 0295 0296 //! Returns the count of recorded Roots 0297 Standard_EXPORT Standard_Integer NbRoots() const; 0298 0299 //! Returns a Root Entity given its number in the list (1-NbRoots) 0300 Standard_EXPORT const Handle(Transfer_Finder)& Root (const Standard_Integer num) const; 0301 0302 //! Returns the Binder bound with a Root Entity given its number 0303 //! Considers a category number, by default 0 0304 Standard_EXPORT Handle(Transfer_Binder) RootItem (const Standard_Integer num) const; 0305 0306 //! Returns the index in the list of roots for a starting item, 0307 //! or 0 if it is not recorded as a root 0308 Standard_EXPORT Standard_Integer RootIndex (const Handle(Transfer_Finder)& start) const; 0309 0310 //! Returns Nesting Level of Transfers (managed by methods 0311 //! TranscriptWith & Co). Starts to zero. If no automatic Transfer 0312 //! is used, it remains to zero. Zero means Root Level. 0313 Standard_EXPORT Standard_Integer NestingLevel() const; 0314 0315 //! Resets Nesting Level of Transfers to Zero (Root Level), 0316 //! whatever its current value. 0317 Standard_EXPORT void ResetNestingLevel(); 0318 0319 //! Tells if <start> has been recognized as good candidate for 0320 //! Transfer. i.e. queries the Actor and its Nexts 0321 Standard_EXPORT Standard_Boolean Recognize (const Handle(Transfer_Finder)& start) const; 0322 0323 //! Performs the Transfer of a Starting Object, by calling 0324 //! the method TransferProduct (see below). 0325 //! Mapping and Roots are managed : nothing is done if a Result is 0326 //! already Bound, an exception is raised in case of error. 0327 Standard_EXPORT Handle(Transfer_Binder) Transferring (const Handle(Transfer_Finder)& start, 0328 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0329 0330 //! Same as Transferring but does not return the Binder. 0331 //! Simply returns True in case of success (for user call) 0332 Standard_EXPORT Standard_Boolean Transfer (const Handle(Transfer_Finder)& start, 0333 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0334 0335 //! Allows controls if exceptions will be handled 0336 //! Transfer Operations 0337 //! <err> False : they are not handled with try {} catch {} 0338 //! <err> True : they are 0339 //! Default is False: no handling performed 0340 Standard_EXPORT void SetErrorHandle (const Standard_Boolean err); 0341 0342 //! Returns error handling flag 0343 Standard_EXPORT Standard_Boolean ErrorHandle() const; 0344 0345 //! Method called when trace is asked 0346 //! Calls PrintTrace to display information relevant for starting 0347 //! objects (which can be redefined) 0348 //! <level> is Nesting Level of Transfer (0 = root) 0349 //! <mode> controls the way the trace is done : 0350 //! 0 neutral, 1 for Error, 2 for Warning message, 3 for new Root 0351 Standard_EXPORT void StartTrace (const Handle(Transfer_Binder)& binder, const Handle(Transfer_Finder)& start, const Standard_Integer level, const Standard_Integer mode) const; 0352 0353 //! Prints a short information on a starting object. By default 0354 //! prints its Dynamic Type. Can be redefined 0355 Standard_EXPORT virtual void PrintTrace (const Handle(Transfer_Finder)& start, Standard_OStream& S) const; 0356 0357 //! Returns True if we are surely in a DeadLoop. Evaluation is not 0358 //! exact, it is a "majorant" which must be computed fast. 0359 //! This "majorant" is : <alevel> greater than NbMapped. 0360 Standard_EXPORT Standard_Boolean IsLooping (const Standard_Integer alevel) const; 0361 0362 //! Returns, as an iterator, the log of root transfer, i.e. the 0363 //! created objects and Binders bound to starting roots 0364 //! If withstart is given True, Starting Objects are also returned 0365 Standard_EXPORT Transfer_IteratorOfProcessForFinder RootResult (const Standard_Boolean withstart = Standard_False) const; 0366 0367 //! Returns, as an Iterator, the entire log of transfer (list of 0368 //! created objects and Binders which can bring errors) 0369 //! If withstart is given True, Starting Objects are also returned 0370 Standard_EXPORT Transfer_IteratorOfProcessForFinder CompleteResult (const Standard_Boolean withstart = Standard_False) const; 0371 0372 //! Returns Binders which are neither "Done" nor "Initial", 0373 //! that is Error,Loop or Run (abnormal states at end of Transfer) 0374 //! Starting Objects are given in correspondence in the iterator 0375 Standard_EXPORT Transfer_IteratorOfProcessForFinder AbnormalResult() const; 0376 0377 //! Returns a CheckList as a list of Check : each one is for a 0378 //! starting entity which have either check (warning or fail) 0379 //! messages are attached, or are in abnormal state : that case 0380 //! gives a specific message 0381 //! If <erronly> is True, checks with Warnings only are ignored 0382 Standard_EXPORT Interface_CheckIterator CheckList (const Standard_Boolean erronly) const; 0383 0384 //! Returns, as an Iterator, the log of transfer for one object 0385 //! <level> = 0 : this object only 0386 //! and if <start> is a scope owner (else, <level> is ignored) : 0387 //! <level> = 1 : object plus its immediate scoped ones 0388 //! <level> = 2 : object plus all its scoped ones 0389 Standard_EXPORT Transfer_IteratorOfProcessForFinder ResultOne (const Handle(Transfer_Finder)& start, const Standard_Integer level, const Standard_Boolean withstart = Standard_False) const; 0390 0391 //! Returns a CheckList for one starting object 0392 //! <level> interpreted as by ResultOne 0393 //! If <erronly> is True, checks with Warnings only are ignored 0394 Standard_EXPORT Interface_CheckIterator CheckListOne (const Handle(Transfer_Finder)& start, const Standard_Integer level, const Standard_Boolean erronly) const; 0395 0396 //! Returns True if no check message is attached to a starting 0397 //! object. <level> interpreted as by ResultOne 0398 //! If <erronly> is True, checks with Warnings only are ignored 0399 Standard_EXPORT Standard_Boolean IsCheckListEmpty (const Handle(Transfer_Finder)& start, const Standard_Integer level, const Standard_Boolean erronly) const; 0400 0401 //! Removes Results attached to (== Unbinds) a given object and, 0402 //! according <level> : 0403 //! <level> = 0 : only it 0404 //! <level> = 1 : it plus its immediately owned sub-results(scope) 0405 //! <level> = 2 : it plus all its owned sub-results(scope) 0406 Standard_EXPORT void RemoveResult (const Handle(Transfer_Finder)& start, const Standard_Integer level, const Standard_Boolean compute = Standard_True); 0407 0408 //! Computes a number to be associated to a starting object in 0409 //! a check or a check-list 0410 //! By default, returns 0; can be redefined 0411 Standard_EXPORT virtual Standard_Integer CheckNum (const Handle(Transfer_Finder)& start) const; 0412 0413 0414 0415 0416 DEFINE_STANDARD_RTTI_INLINE(Transfer_ProcessForFinder,Standard_Transient) 0417 0418 protected: 0419 0420 0421 0422 0423 private: 0424 0425 0426 //! Same as Find but stores the last access to the map, for a 0427 //! faster access on next calls (as Bind does too) 0428 //! Considers a category number, by default 0 0429 //! C++ : return const & 0430 Standard_EXPORT Handle(Transfer_Binder) FindAndMask (const Handle(Transfer_Finder)& start); 0431 0432 //! Internal action of Transfer, called by Transferring, with or 0433 //! without ErrorHandle. It invokes the Actor to work (set by 0434 //! SetActor), and tries its Nexts if no result is produced, 0435 //! until a Non Null Binder is produced. 0436 //! But keep in mind that a Null Binder can always be returned 0437 //! if a Starting Entity has not been recognized at all. 0438 Standard_EXPORT Handle(Transfer_Binder) TransferProduct (const Handle(Transfer_Finder)& start, 0439 const Message_ProgressRange& theProgress = Message_ProgressRange()); 0440 0441 Standard_Boolean theerrh; 0442 Standard_Integer thetrace; 0443 Handle(Message_Messenger) themessenger; 0444 Standard_Integer thelevel; 0445 Standard_Integer therootl; 0446 Standard_Boolean therootm; 0447 TColStd_IndexedMapOfInteger theroots; 0448 Handle(Transfer_Finder) thelastobj; 0449 Handle(Transfer_Binder) thelastbnd; 0450 Standard_Integer theindex; 0451 Handle(Transfer_ActorOfProcessForFinder) theactor; 0452 Transfer_TransferMapOfProcessForFinder themap; 0453 0454 0455 }; 0456 0457 0458 0459 0460 0461 0462 0463 #endif // _Transfer_ProcessForFinder_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |