CommandDispatch.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef EXECUTION_COMMAND_DISPATCH
00039 #define EXECUTION_COMMAND_DISPATCH
00040
00041 #include "DataSource.hpp"
00042 #include "DispatchInterface.hpp"
00043 #include "ConditionInterface.hpp"
00044
00045
00046 namespace RTT
00047 {
00048 class TryCommand;
00049 class CommandProcessor;
00050
00059 class RTT_API CommandDispatch
00060 : public DispatchInterface
00061 {
00062 bool send;
00063 bool maccepted;
00064 CommandProcessor* proc;
00065 CommandInterface* com;
00066 ConditionInterface* mcn;
00067
00072 struct Dispatcher : public CommandInterface {
00073 bool mexecuted, mvalid;
00074 CommandDispatch* cd;
00075
00076 Dispatcher(CommandDispatch* c) : mexecuted(false), mvalid(true), cd(c) {}
00077 void readArguments() {}
00078 bool execute() { mvalid=cd->com->execute(); mexecuted=true; return mvalid;}
00079 void reset() { mexecuted=false; mvalid=true; }
00080 virtual Dispatcher* clone() const { return new Dispatcher(cd); }
00081 } dispatcher;
00082
00083 public:
00087 CommandDispatch(CommandProcessor* p, CommandInterface* c, ConditionInterface* cn );
00088
00093 ~CommandDispatch();
00094
00095 void readArguments();
00096
00097 bool ready() const;
00098
00099 bool execute();
00100
00105 bool dispatch();
00106
00111 void reset();
00112
00117 bool sent() const;
00118
00124 bool accepted() const;
00125
00130 bool executed() const;
00131
00136 bool valid() const;
00137
00144 bool done() const;
00145
00146 virtual ConditionInterface* createCondition() const;
00147
00148 DispatchInterface* clone() const;
00149
00150 DispatchInterface* copy( std::map<const DataSourceBase*, DataSourceBase*>& alreadyCloned ) const;
00151 };
00152 }
00153
00154 #endif