StaticCommand.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // A wrapper for a Command function
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef StaticCommand_h
00020 #define StaticCommand_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include "Command.h"
00033 
00034 
00035 // ===========================================================================
00036 // class definition
00037 // ===========================================================================
00046 template< class T  >
00047 class StaticCommand : public Command {
00048 public:
00050     typedef SUMOTime(*Operation)(SUMOTime);
00051     //T::*
00052 
00053 
00054 public:
00061     StaticCommand(Operation operation) throw()
00062             : myOperation(operation), myAmDescheduledByParent(false) {}
00063 
00064 
00066     ~StaticCommand() throw() {}
00067 
00068 
00074     void deschedule() {
00075         myAmDescheduledByParent = true;
00076     }
00077 
00078 
00079 
00082 
00092     SUMOTime execute(SUMOTime currentTime) throw(ProcessError) {
00093         // do not execute if the command was descheduled
00094         if (myAmDescheduledByParent) {
00095             return 0;
00096         }
00097         // execute if stil valid
00098         return (*myOperation)(currentTime);
00099     }
00101 
00102 
00103 private:
00105     Operation myOperation;
00106 
00108     bool myAmDescheduledByParent;
00109 
00110 
00111 };
00112 
00113 
00114 #endif
00115 
00116 /****************************************************************************/
00117 

Generated on Wed May 5 00:06:36 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6