File indexing completed on 2025-01-18 10:04:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef Message_ExecStatus_HeaderFile
0019 #define Message_ExecStatus_HeaderFile
0020
0021 #include <Message_Status.hxx>
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 class Message_ExecStatus
0041 {
0042 private:
0043
0044
0045 enum StatusMask
0046 {
0047 MType = 0x0000ff00,
0048 MIndex = 0x000000ff
0049 };
0050
0051 static inline int getBitFlag (int theStatus)
0052 {
0053 return 0x1 << (theStatus & MIndex);
0054 }
0055
0056 public:
0057
0058
0059
0060
0061 Message_ExecStatus()
0062 : myDone (Message_None), myWarn (Message_None),
0063 myAlarm (Message_None), myFail (Message_None)
0064 {}
0065
0066
0067 Message_ExecStatus (Message_Status theStatus)
0068 : myDone (Message_None), myWarn (Message_None),
0069 myAlarm (Message_None), myFail (Message_None)
0070 {
0071 Set (theStatus);
0072 }
0073
0074
0075 void Set (Message_Status theStatus)
0076 {
0077 switch (TypeOfStatus (theStatus))
0078 {
0079 case Message_DONE: myDone |= (getBitFlag (theStatus)); break;
0080 case Message_WARN: myWarn |= (getBitFlag (theStatus)); break;
0081 case Message_ALARM: myAlarm |= (getBitFlag (theStatus)); break;
0082 case Message_FAIL: myFail |= (getBitFlag (theStatus)); break;
0083 }
0084 }
0085
0086
0087 Standard_Boolean IsSet (Message_Status theStatus) const
0088 {
0089 switch (TypeOfStatus (theStatus))
0090 {
0091 case Message_DONE: return (myDone & getBitFlag (theStatus)) != 0;
0092 case Message_WARN: return (myWarn & getBitFlag (theStatus)) != 0;
0093 case Message_ALARM: return (myAlarm & getBitFlag (theStatus)) != 0;
0094 case Message_FAIL: return (myFail & getBitFlag (theStatus)) != 0;
0095 }
0096 return Standard_False;
0097 }
0098
0099
0100 void Clear (Message_Status theStatus)
0101 {
0102 switch (TypeOfStatus (theStatus))
0103 {
0104 case Message_DONE: myDone &= ~(getBitFlag (theStatus)); return;
0105 case Message_WARN: myWarn &= ~(getBitFlag (theStatus)); return;
0106 case Message_ALARM:myAlarm &= ~(getBitFlag (theStatus)); return;
0107 case Message_FAIL: myFail &= ~(getBitFlag (theStatus)); return;
0108 }
0109 }
0110
0111
0112
0113
0114
0115
0116
0117 Standard_Boolean IsDone () const { return myDone != Message_None; }
0118 Standard_Boolean IsFail () const { return myFail != Message_None; }
0119 Standard_Boolean IsWarn () const { return myWarn != Message_None; }
0120 Standard_Boolean IsAlarm () const { return myAlarm != Message_None; }
0121
0122
0123 void SetAllDone () { myDone = ~0; }
0124 void SetAllWarn () { myWarn = ~0; }
0125 void SetAllAlarm () { myAlarm = ~0; }
0126 void SetAllFail () { myFail = ~0; }
0127
0128
0129 void ClearAllDone () { myDone = Message_None; }
0130 void ClearAllWarn () { myWarn = Message_None; }
0131 void ClearAllAlarm() { myAlarm = Message_None; }
0132 void ClearAllFail () { myFail = Message_None; }
0133
0134
0135 void Clear ()
0136 {
0137 myDone = myWarn = myAlarm = myFail = Message_None;
0138 }
0139
0140
0141 void Add ( const Message_ExecStatus& theOther )
0142 {
0143 myDone |= theOther.myDone;
0144 myWarn |= theOther.myWarn;
0145 myAlarm |= theOther.myAlarm;
0146 myFail |= theOther.myFail;
0147 }
0148 const Message_ExecStatus& operator |= ( const Message_ExecStatus& theOther )
0149 { Add ( theOther ); return *this; }
0150
0151
0152 void And ( const Message_ExecStatus& theOther )
0153 {
0154 myDone &= theOther.myDone;
0155 myWarn &= theOther.myWarn;
0156 myAlarm &= theOther.myAlarm;
0157 myFail &= theOther.myFail;
0158 }
0159 const Message_ExecStatus& operator &= ( const Message_ExecStatus& theOther )
0160 { And ( theOther ); return *this; }
0161
0162
0163
0164 public:
0165
0166
0167
0168
0169
0170 enum StatusRange
0171 {
0172 FirstStatus = 1,
0173 StatusesPerType = 32,
0174 NbStatuses = 128,
0175 LastStatus = 129
0176 };
0177
0178
0179 static Standard_Integer StatusIndex (Message_Status theStatus)
0180 {
0181 switch (TypeOfStatus (theStatus))
0182 {
0183 case Message_DONE: return 0 * StatusesPerType + LocalStatusIndex(theStatus);
0184 case Message_WARN: return 1 * StatusesPerType + LocalStatusIndex(theStatus);
0185 case Message_ALARM: return 2 * StatusesPerType + LocalStatusIndex(theStatus);
0186 case Message_FAIL: return 3 * StatusesPerType + LocalStatusIndex(theStatus);
0187 }
0188 return 0;
0189 }
0190
0191
0192
0193 static Standard_Integer LocalStatusIndex (Message_Status theStatus)
0194 {
0195 return ((Standard_UInteger )theStatus & (Standard_UInteger )MIndex) + 1;
0196 }
0197
0198
0199 static Message_StatusType TypeOfStatus (Message_Status theStatus)
0200 {
0201 return (Message_StatusType )((Standard_UInteger )theStatus & (Standard_UInteger )MType);
0202 }
0203
0204
0205 static Message_Status StatusByIndex( const Standard_Integer theIndex )
0206 {
0207 Standard_Integer indx = theIndex - 1;
0208 if ( indx < 32 )
0209 return (Message_Status)(Message_DONE + indx);
0210 else if ( indx < 64 )
0211 return (Message_Status)(Message_WARN + ( indx - 32 ));
0212 else if ( indx < 96 )
0213 return (Message_Status)(Message_ALARM + ( indx - 64 ));
0214 else if ( indx < 128 )
0215 return (Message_Status)(Message_FAIL + ( indx - 96 ));
0216 return Message_None;
0217 }
0218
0219
0220
0221 private:
0222 Standard_Integer myDone;
0223 Standard_Integer myWarn;
0224 Standard_Integer myAlarm;
0225 Standard_Integer myFail;
0226 };
0227
0228 #endif