- Timestamp:
- 08/13/12 09:49:32 (12 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/DimState.h
r14123 r14351 22 22 23 23 protected: 24 typedef std::function< void(const EventImp &)> callback;24 typedef std::function<int(const EventImp &)> callback; 25 25 26 26 callback fCallback; … … 36 36 } 37 37 38 void Callback(const EventImp &evt) 39 { 40 if (fCallback) 41 fCallback(evt); 42 } 43 44 virtual void Handler(const EventImp &evt) 38 int Callback(const EventImp &evt) 39 { 40 return fCallback ? fCallback(evt) : StateMachineImp::kSM_KeepState; 41 } 42 43 virtual int Handler(const EventImp &evt) 45 44 { 46 45 HandlerImp(evt); 47 Callback(evt);46 return Callback(evt); 48 47 } 49 48 … … 145 144 } 146 145 147 voidHandleDesc(const EventImp &evt)146 int HandleDesc(const EventImp &evt) 148 147 { 149 148 if (evt.GetSize()>0) … … 154 153 CallbackStates(); 155 154 } 155 156 return StateMachineImp::kSM_KeepState; 156 157 } 157 158 … … 200 201 201 202 202 voidHandleServiceDesc(const EventImp &evt)203 int HandleServiceDesc(const EventImp &evt) 203 204 { 204 205 descriptions.clear(); … … 212 213 213 214 CallbackDescriptions(); 215 216 return StateMachineImp::kSM_KeepState; 214 217 } 215 218 }; … … 217 220 class DimVersion : public DimState 218 221 { 219 voidHandler(const EventImp &evt)222 int Handler(const EventImp &evt) 220 223 { 221 224 HandlerImp(evt); … … 225 228 cur.second=kOffline; 226 229 227 Callback(evt);230 return Callback(evt); 228 231 } 229 232 … … 251 254 std::map<std::string, callback> fCallbacks; 252 255 253 voidHandler(const EventImp &evt)256 int Handler(const EventImp &evt) 254 257 { 255 258 HandlerImp(evt); … … 262 265 const size_t p0 = msg.find_first_of(':'); 263 266 if (p0==std::string::npos) 264 return ;267 return StateMachineImp::kSM_KeepState; 265 268 266 269 // Evaluate scriptdepth … … 272 275 const size_t p1 = msg.find_last_of('['); 273 276 if (p1==std::string::npos) 274 return ;277 return StateMachineImp::kSM_KeepState; 275 278 276 279 const size_t p2 = msg.find_first_of(':', p0+1); … … 282 285 shortmsg.erase(p0, p3-p0); 283 286 284 Callback(evt);287 const int rc = Callback(evt); 285 288 286 289 const auto func = fCallbacks.find(file); 287 290 if (func==fCallbacks.end()) 288 return ;291 return rc; 289 292 290 293 // Call callback 291 func->second(evt);294 return func->second(evt); 292 295 } 293 296 … … 340 343 fCallbackServerEvent(evt); 341 344 } 342 virtual voidHandlerServer(const EventImp &evt)345 virtual int HandlerServer(const EventImp &evt) 343 346 { 344 347 HandlerServerImp(evt); 345 348 CallbackServerEvent(evt); 349 350 return StateMachineImp::kSM_KeepState; 346 351 } 347 352 … … 424 429 } 425 430 */ 426 virtual voidHandlerServiceList(const EventImp &evt)431 virtual int HandlerServiceList(const EventImp &evt) 427 432 { 428 433 HandlerServiceListImp(evt); 429 434 //CallbackServiceEvent(evt); 435 436 return StateMachineImp::kSM_KeepState; 430 437 } 431 438 -
trunk/FACT++/src/RemoteControl.h
r14135 r14351 249 249 } 250 250 251 voidHandle(const EventImp &evt, const string &service)251 int Handle(const EventImp &evt, const string &service) 252 252 { 253 253 const lock_guard<mutex> lock(fMutex); … … 261 261 it->second.second = static_cast<Event>(evt); 262 262 } 263 264 return StateMachineImp::kSM_KeepState; 263 265 } 264 266 -
trunk/FACT++/src/StateMachineImp.h
r14124 r14351 21 21 enum DefaultStates_t 22 22 { 23 kSM_KeepState = -42, ///< 23 24 kSM_NotReady = -1, ///< Mainloop not running, state machine stopped 24 25 kSM_Ready = 0, ///< Mainloop running, state machine in operation … … 68 69 virtual void UnLock() { } 69 70 70 int Wrapper(const std::function< void(const EventImp &)> &f, const EventImp &imp)71 int Wrapper(const std::function<int(const EventImp &)> &f, const EventImp &imp) 71 72 { 72 f(imp);73 return GetCurrentState();73 const int rc = f(imp); 74 return rc==kSM_KeepState ? GetCurrentState() : rc; 74 75 } 75 76 … … 94 95 ~StateMachineImp(); 95 96 96 std::function<int(const EventImp &)> Wrap(const std::function< void(const EventImp &)> &func)97 std::function<int(const EventImp &)> Wrap(const std::function<int(const EventImp &)> &func) 97 98 { 98 99 return bind(&StateMachineImp::Wrapper, this, func, std::placeholders::_1);
Note:
See TracChangeset
for help on using the changeset viewer.