- Timestamp:
- 06/02/12 12:49:38 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/DimState.h
r14015 r14032 6 6 class DimState 7 7 { 8 public: 9 enum 10 { 11 kOffline = -256, 12 kNotAvailable = -257, 13 }; 14 8 15 protected: 9 16 typedef function<void(const EventImp &)> callback; … … 15 22 const bool disconnected = evt.GetSize()==0; 16 23 17 last = info;18 info = make_pair(evt.GetTime(), disconnected ? -256: evt.GetQoS());24 last = cur; 25 cur = make_pair(evt.GetTime(), disconnected ? kOffline : evt.GetQoS()); 19 26 20 27 msg = disconnected ? "" : evt.GetString(); … … 35 42 public: 36 43 DimState(const string &n, const string s="STATE") : server(n), 37 service(n+"/"+s), info(make_pair(Time(), -256)) 44 service(n+"/"+s), 45 last(make_pair(Time(), kOffline)), cur(make_pair(Time(), kOffline)) 38 46 { 39 47 } … … 42 50 } 43 51 44 string server;45 string service;46 47 pair<Time, int > last;48 pair<Time, int > info;52 const string server; 53 const string service; 54 55 pair<Time, int32_t> last; 56 pair<Time, int32_t> cur; 49 57 string msg; 50 58 … … 60 68 } 61 69 62 const Time &time() const { return info.first; }63 const int &state() const { return info.second; }64 65 bool online() const { return info.second>-256; }66 67 virtual State description() const { return State( -257, ""); }70 const Time &time() const { return cur.first; } 71 const int32_t &state() const { return cur.second; } 72 73 bool online() const { return state()>kOffline; } 74 75 virtual State description() const { return State(kNotAvailable, ""); } 68 76 }; 69 77 … … 75 83 out << kBold << s.server; 76 84 77 if (s.state()== -256)85 if (s.state()==DimState::kOffline) 78 86 return out << ": Offline"; 79 87 80 if (rc.index== -257)88 if (rc.index==DimState::kNotAvailable) 81 89 return out; 82 90 … … 117 125 { 118 126 states = State::SplitStates(evt.GetString()); 119 states.push_back(State( -256, "Offline"));127 states.push_back(State(kOffline, "Offline")); 120 128 } 121 129 } … … 127 135 return *it; 128 136 129 return State( -257, "n/a");137 return State(kNotAvailable, "n/a"); 130 138 } 131 139 }; … … 137 145 HandlerImp(evt); 138 146 139 info.second = evt.GetSize()==4 ? evt.GetInt() : -256;140 if ( info.second==0)141 info.second=-256;147 cur.second = evt.GetSize()==4 ? evt.GetInt() : kOffline; 148 if (cur.second==0) 149 cur.second=kOffline; 142 150 143 151 Callback(evt); … … 153 161 154 162 ostringstream out; 155 out << "V" << info.second/100 << 'r' << info.second%100;163 out << "V" << state()/100 << 'r' << state()%100; 156 164 return out.str(); 157 165 }
Note:
See TracChangeset
for help on using the changeset viewer.