00001 #if !defined(__COMMANDFRAME_HPP)
00002 #define __COMMANDFRAME_HPP
00003
00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022
00023
00024 #if !defined(__COMMON_HPP)
00025 #include <Common.hpp>
00026 #endif
00027
00028 #if !defined(__ABSTRACTCOMMAND_HPP)
00029 #include <AbstractCommand.hpp>
00030 #endif
00031
00032 #if !defined(__VECTOR_HPP)
00033 #include <Vector.hpp>
00034 #endif
00035
00036 #if !defined(__COMMANDFRAMEEXCEPTION_HPP)
00037 #include <CommandFrameException.hpp>
00038 #endif
00039
00040 namespace corelinux
00041 {
00042 CORELINUX_VECTOR( AbstractCommandPtr , Commands );
00043
00044 DECLARE_CLASS( CommandFrame );
00045
00050 enum WorkState
00051 {
00053
00054 BUILDING = 0,
00055 EXECUTING,
00056 COMPLETED,
00057 REVERSING,
00058 REVERSED,
00059 NEVERCOMPLETED
00060 };
00061
00069 class CommandFrame : public Synchronized
00070 {
00071
00072 public:
00073
00074
00075
00076 00078
00079 CommandFrame( bool autoReverse = false );
00080
00090 CommandFrame( CommandFrameCref )
00091 throw( CommandFrameException );
00092
00099 virtual ~CommandFrame( void );
00100
00101
00102
00103
00104
00114 CommandFrameRef operator=( CommandFrameCref )
00115 throw( CommandFrameException );
00116
00118
00119 bool operator==( CommandFrameCref ) const;
00120
00121
00122
00123
00124
00130 WorkState getState( void ) const;
00131
00137 bool getReverseFlag( void ) const;
00138
00145 virtual void getCommands( CommandsRef ) const;
00146
00147
00148
00149
00150
00159 CommandFrameRef operator+=( AbstractCommandPtr )
00160 throw( CommandFrameException );
00161
00170 CommandFrameRef operator+=( CommandFrameCref )
00171 throw( CommandFrameException );
00172
00180 virtual void addCommand( AbstractCommandPtr )
00181 throw( CommandFrameException );
00182
00183
00190 void setAutoReverse( bool ) throw( CommandFrameException );
00191
00202 void execute( void ) throw( CommandFrameException );
00203
00212 void executeReverse( void ) throw( CommandFrameException );
00213
00214 protected:
00215
00223 virtual WorkState executeCommands( void );
00224
00232 virtual WorkState executeReverseCommands( void );
00233
00234 protected:
00235
00237
00238 bool theAutoReverseFlag;
00239
00241
00242 WorkState theWorkState;
00243
00245
00246 Commands theCommands;
00247 };
00248 }
00249
00250 #endif // if !defined(__COMMANDFRAME_HPP)
00251
00252 00253 00254 00255 00256 00257 00258
00259
00260
00261