TarzaNN
TarzaNN neural network simulator
|
00001 #ifndef NOTIFYSTRATEGYSYNC_H_INCLUDE 00002 #define NOTIFYSTRATEGYSYNC_H_INCLUDE 00003 00004 #include "NotifyStrategyAbstract.h" 00005 #include <QWaitCondition> 00006 00008 class NotifyStrategySync: public NotifyStrategyAbstract{ 00009 public: 00010 NotifyStrategySync(): wasNotifiedFlag(false),run_once(){} 00011 virtual ~NotifyStrategySync(){}; 00012 00013 void updateNN(Observer* sourceFP, bool functional){ //sync 00014 if(functional){ 00015 classAccess.lock(); 00016 wasNotifiedFlag=true; 00017 run_once.wakeAll(); 00018 classAccess.unlock(); 00019 } 00020 } 00021 00022 private: 00023 void reset(){ 00024 wasNotifiedFlag=false; 00025 } 00026 00027 bool wasNotified(){ //sync 00028 00029 bool ret= wasNotifiedFlag; 00030 this->reset(); 00031 return ret; 00032 } 00033 00034 bool wasNotifiedFlag; 00035 QWaitCondition run_once; 00036 QMutex classAccess; 00037 }; 00038 00039 #endif /*NOTIFYSTRATEGYSYNC_H_INCLUDE*/ 00040