File indexing completed on 2026-10-05 09:23:10
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 enum StatusMask
0045 {
0046 MType = 0x0000ff00,
0047 MIndex = 0x000000ff
0048 };
0049
0050 static inline int getBitFlag(int theStatus) { return 0x1 << (theStatus & MIndex); }
0051
0052 public:
0053
0054
0055
0056
0057 Message_ExecStatus()
0058 : myDone(Message_None),
0059 myWarn(Message_None),
0060 myAlarm(Message_None),
0061 myFail(Message_None)
0062 {
0063 }
0064
0065
0066 Message_ExecStatus(Message_Status theStatus)
0067 : myDone(Message_None),
0068 myWarn(Message_None),
0069 myAlarm(Message_None),
0070 myFail(Message_None)
0071 {
0072 Set(theStatus);
0073 }
0074
0075
0076 void Set(Message_Status theStatus)
0077 {
0078 switch (TypeOfStatus(theStatus))
0079 {
0080 case Message_DONE:
0081 myDone |= (getBitFlag(theStatus));
0082 break;
0083 case Message_WARN:
0084 myWarn |= (getBitFlag(theStatus));
0085 break;
0086 case Message_ALARM:
0087 myAlarm |= (getBitFlag(theStatus));
0088 break;
0089 case Message_FAIL:
0090 myFail |= (getBitFlag(theStatus));
0091 break;
0092 }
0093 }
0094
0095
0096 bool IsSet(Message_Status theStatus) const
0097 {
0098 switch (TypeOfStatus(theStatus))
0099 {
0100 case Message_DONE:
0101 return (myDone & getBitFlag(theStatus)) != 0;
0102 case Message_WARN:
0103 return (myWarn & getBitFlag(theStatus)) != 0;
0104 case Message_ALARM:
0105 return (myAlarm & getBitFlag(theStatus)) != 0;
0106 case Message_FAIL:
0107 return (myFail & getBitFlag(theStatus)) != 0;
0108 }
0109 return false;
0110 }
0111
0112
0113 void Clear(Message_Status theStatus)
0114 {
0115 switch (TypeOfStatus(theStatus))
0116 {
0117 case Message_DONE:
0118 myDone &= ~(getBitFlag(theStatus));
0119 return;
0120 case Message_WARN:
0121 myWarn &= ~(getBitFlag(theStatus));
0122 return;
0123 case Message_ALARM:
0124 myAlarm &= ~(getBitFlag(theStatus));
0125 return;
0126 case Message_FAIL:
0127 myFail &= ~(getBitFlag(theStatus));
0128 return;
0129 }
0130 }
0131
0132
0133
0134
0135
0136
0137
0138 bool IsDone() const { return myDone != Message_None; }
0139
0140 bool IsFail() const { return myFail != Message_None; }
0141
0142 bool IsWarn() const { return myWarn != Message_None; }
0143
0144 bool IsAlarm() const { return myAlarm != Message_None; }
0145
0146
0147 void SetAllDone() { myDone = ~0; }
0148
0149 void SetAllWarn() { myWarn = ~0; }
0150
0151 void SetAllAlarm() { myAlarm = ~0; }
0152
0153 void SetAllFail() { myFail = ~0; }
0154
0155
0156 void ClearAllDone() { myDone = Message_None; }
0157
0158 void ClearAllWarn() { myWarn = Message_None; }
0159
0160 void ClearAllAlarm() { myAlarm = Message_None; }
0161
0162 void ClearAllFail() { myFail = Message_None; }
0163
0164
0165 void Clear() { myDone = myWarn = myAlarm = myFail = Message_None; }
0166
0167
0168 void Add(const Message_ExecStatus& theOther)
0169 {
0170 myDone |= theOther.myDone;
0171 myWarn |= theOther.myWarn;
0172 myAlarm |= theOther.myAlarm;
0173 myFail |= theOther.myFail;
0174 }
0175
0176 const Message_ExecStatus& operator|=(const Message_ExecStatus& theOther)
0177 {
0178 Add(theOther);
0179 return *this;
0180 }
0181
0182
0183 void And(const Message_ExecStatus& theOther)
0184 {
0185 myDone &= theOther.myDone;
0186 myWarn &= theOther.myWarn;
0187 myAlarm &= theOther.myAlarm;
0188 myFail &= theOther.myFail;
0189 }
0190
0191 const Message_ExecStatus& operator&=(const Message_ExecStatus& theOther)
0192 {
0193 And(theOther);
0194 return *this;
0195 }
0196
0197
0198
0199 public:
0200
0201
0202
0203
0204 enum StatusRange
0205 {
0206 FirstStatus = 1,
0207 StatusesPerType = 32,
0208 NbStatuses = 128,
0209 LastStatus = 129
0210 };
0211
0212
0213 static int StatusIndex(Message_Status theStatus)
0214 {
0215 switch (TypeOfStatus(theStatus))
0216 {
0217 case Message_DONE:
0218 return 0 * StatusesPerType + LocalStatusIndex(theStatus);
0219 case Message_WARN:
0220 return 1 * StatusesPerType + LocalStatusIndex(theStatus);
0221 case Message_ALARM:
0222 return 2 * StatusesPerType + LocalStatusIndex(theStatus);
0223 case Message_FAIL:
0224 return 3 * StatusesPerType + LocalStatusIndex(theStatus);
0225 }
0226 return 0;
0227 }
0228
0229
0230
0231 static int LocalStatusIndex(Message_Status theStatus)
0232 {
0233 return ((unsigned int)theStatus & (unsigned int)MIndex) + 1;
0234 }
0235
0236
0237 static Message_StatusType TypeOfStatus(Message_Status theStatus)
0238 {
0239 return (Message_StatusType)((unsigned int)theStatus & (unsigned int)MType);
0240 }
0241
0242
0243 static Message_Status StatusByIndex(const int theIndex)
0244 {
0245 int indx = theIndex - 1;
0246 if (indx < 32)
0247 return (Message_Status)(Message_DONE + indx);
0248 else if (indx < 64)
0249 return (Message_Status)(Message_WARN + (indx - 32));
0250 else if (indx < 96)
0251 return (Message_Status)(Message_ALARM + (indx - 64));
0252 else if (indx < 128)
0253 return (Message_Status)(Message_FAIL + (indx - 96));
0254 return Message_None;
0255 }
0256
0257
0258
0259 private:
0260 int myDone;
0261 int myWarn;
0262 int myAlarm;
0263 int myFail;
0264 };
0265
0266 #endif