GrasperTrans.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_GrasperTrans_h_
00003 #define INCLUDED_GrasperTrans_h_
00004
00005 #include "Behaviors/Transition.h"
00006 #include "Events/GrasperEvent.h"
00007 #include "Events/EventRouter.h"
00008
00009
00010
00011
00012
00013
00014
00015
00016 class GrasperTrans : public Transition {
00017 public:
00018
00019 GrasperTrans(StateNode *destination) :
00020 Transition(destination), errorCode(), valueSupplied(false)
00021 { }
00022
00023
00024 GrasperTrans(StateNode *destination, GrasperRequest::GrasperErrorType_t value) :
00025 Transition(destination), errorCode(value), valueSupplied(true)
00026 { }
00027
00028
00029 GrasperTrans(const std::string &name, StateNode *destination) :
00030 Transition(name,destination), errorCode(), valueSupplied(false)
00031 { }
00032
00033
00034 GrasperTrans(const std::string &name, StateNode *destination, GrasperRequest::GrasperErrorType_t value) :
00035 Transition(name,destination), errorCode(value), valueSupplied(true)
00036 { }
00037
00038 virtual void postStart() {
00039 Transition::postStart();
00040 for ( std::vector<StateNode*>::const_iterator it = srcs.begin(); it != srcs.end(); it++ )
00041 erouter->addListener(this,EventBase::grasperEGID,(size_t)*it);
00042 }
00043
00044 virtual void doEvent() {
00045 const GrasperEvent *graspEvent = dynamic_cast<const GrasperEvent*>(event);
00046 if ( graspEvent != NULL )
00047
00048
00049
00050
00051 if ( !valueSupplied ||
00052 graspEvent->getErrorType() == errorCode ||
00053 (errorCode == GrasperRequest::someError && graspEvent->getErrorType() != GrasperRequest::noError) )
00054 fire(*event);
00055 }
00056
00057
00058 GrasperTrans(const GrasperTrans &src) : Transition(src), errorCode(src.errorCode), valueSupplied(src.valueSupplied) {}
00059
00060
00061 GrasperTrans& operator=(const GrasperTrans& src) {
00062 errorCode = src.errorCode;
00063 valueSupplied = src.valueSupplied;
00064 return *this;
00065 }
00066
00067 protected:
00068 GrasperRequest::GrasperErrorType_t errorCode;
00069 bool valueSupplied;
00070 };
00071
00072 #endif