Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

MapBuilderNode.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_MapBuilderNode_h_
00003 #define INCLUDED_MapBuilderNode_h_
00004 
00005 #include "Behaviors/StateNode.h"
00006 #include "Crew/MapBuilder.h"
00007 #include "Crew/MapBuilderRequest.h"
00008 
00009 using namespace DualCoding;
00010 
00011 //! Creates a MapBuilderRequest @a mapreq that the user can modify in their doStart() function, then executes the request when doStart() returns
00012 class MapBuilderNode : public StateNode {
00013 public:
00014   //! Constructor
00015   MapBuilderNode(MapBuilderRequest::MapBuilderRequestType_t requestType=MapBuilderRequest::cameraMap) :
00016     StateNode(), mapreq(requestType), cancelFlag(false) {}
00017 
00018   //! Constructor
00019   MapBuilderNode(std::string const name,
00020      MapBuilderRequest::MapBuilderRequestType_t requestType=MapBuilderRequest::cameraMap) :
00021     StateNode(name), mapreq(requestType), cancelFlag(false) {}
00022 
00023   virtual void preStart() {
00024     cancelFlag = false;
00025     StateNode::preStart();
00026   }
00027   
00028   virtual void postStart() {
00029     StateNode::postStart();
00030     if ( ! cancelFlag ) {
00031       erouter->addListener(this, EventBase::mapbuilderEGID, (size_t)this, EventBase::statusETID);
00032       VRmixin::mapBuilder->executeRequest(this,mapreq);
00033     }
00034   }
00035 
00036   virtual void doEvent() {
00037     postStateCompletion();
00038   }
00039 
00040   //! If called inside doStart, prevents request from being passed to MapBuilder, and posts a failure event
00041   virtual void cancelThisRequest() {
00042     cancelFlag = true;
00043     postStateFailure();
00044   }
00045 
00046 protected:
00047   MapBuilderRequest mapreq;
00048   bool cancelFlag;  //!< If set true in doStart, request will not be submitted to the MapBuilder
00049 
00050 };
00051 
00052 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:44 2016 by Doxygen 1.6.3