|
|
|||
File indexing completed on 2026-09-25 09:20:36
0001 // Copyright (c) 2020 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _Message_ProgressRange_HeaderFile 0015 #define _Message_ProgressRange_HeaderFile 0016 0017 #include <Standard_TypeDef.hxx> 0018 0019 class Message_ProgressScope; 0020 0021 //! Auxiliary class representing a part of the global progress scale allocated by 0022 //! a step of the progress scope, see Message_ProgressScope::Next(). 0023 //! 0024 //! A range object takes responsibility of advancing the progress by the size of 0025 //! allocated step, which is then performed depending on how it is used: 0026 //! 0027 //! - If Message_ProgressScope object is created using this range as argument, then 0028 //! this respondibility is taken over by that scope. 0029 //! 0030 //! - Otherwise, a range advances progress directly upon destruction. 0031 //! 0032 //! A range object can be copied, the responsibility for progress advancement is 0033 //! then taken by the copy. 0034 //! The same range object may be used (either copied or used to create scope) only once. 0035 //! Any consequent attempts to use range will give no result on the progress; 0036 //! in debug mode, an assert message will be generated. 0037 //! 0038 //! @sa Message_ProgressScope for more details 0039 class Message_ProgressRange 0040 { 0041 public: 0042 //! Constructor of the empty range 0043 Message_ProgressRange() 0044 : myParentScope(nullptr), 0045 myStart(0.), 0046 myDelta(0.), 0047 myWasUsed(false) 0048 { 0049 } 0050 0051 //! Copy constructor disarms the source 0052 Message_ProgressRange(const Message_ProgressRange& theOther) 0053 : myParentScope(theOther.myParentScope), 0054 myStart(theOther.myStart), 0055 myDelta(theOther.myDelta), 0056 myWasUsed(theOther.myWasUsed) 0057 { 0058 // discharge theOther 0059 theOther.myWasUsed = true; 0060 } 0061 0062 //! Copy assignment disarms the source 0063 Message_ProgressRange& operator=(const Message_ProgressRange& theOther) 0064 { 0065 myParentScope = theOther.myParentScope; 0066 myStart = theOther.myStart; 0067 myDelta = theOther.myDelta; 0068 myWasUsed = theOther.myWasUsed; 0069 theOther.myWasUsed = true; 0070 return *this; 0071 } 0072 0073 //! Returns true if ProgressIndicator signals UserBreak 0074 bool UserBreak() const; 0075 0076 //! Returns false if ProgressIndicator signals UserBreak 0077 bool More() const { return !UserBreak(); } 0078 0079 //! Returns true if this progress range is attached to some indicator. 0080 bool IsActive() const; 0081 0082 //! Closes the current range and advances indicator 0083 void Close(); 0084 0085 //! Destructor 0086 ~Message_ProgressRange() { Close(); } 0087 0088 private: 0089 //! Constructor is private 0090 Message_ProgressRange(const Message_ProgressScope& theParent, double theStart, double theDelta) 0091 : myParentScope(&theParent), 0092 myStart(theStart), 0093 myDelta(theDelta), 0094 myWasUsed(false) 0095 { 0096 } 0097 0098 private: 0099 const Message_ProgressScope* myParentScope; //!< Pointer to parent scope 0100 double myStart; //!< Start point on the global scale 0101 double myDelta; //!< Step of incrementation on the global scale 0102 0103 mutable bool myWasUsed; //!< Flag indicating that this range 0104 //! was used to create a new scope 0105 0106 friend class Message_ProgressScope; 0107 }; 0108 0109 #include <Message_ProgressIndicator.hxx> 0110 0111 //================================================================================================= 0112 0113 inline bool Message_ProgressRange::IsActive() const 0114 { 0115 return !myWasUsed && myParentScope && myParentScope->myProgress; 0116 } 0117 0118 //================================================================================================= 0119 0120 inline bool Message_ProgressRange::UserBreak() const 0121 { 0122 return myParentScope && myParentScope->myProgress && myParentScope->myProgress->UserBreak(); 0123 } 0124 0125 //================================================================================================= 0126 0127 inline void Message_ProgressRange::Close() 0128 { 0129 if (!IsActive()) 0130 return; 0131 0132 myParentScope->myProgress->Increment(myDelta, *myParentScope); 0133 myParentScope = nullptr; 0134 myWasUsed = true; 0135 } 0136 0137 #endif // _Message_ProgressRange_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|