CoreLinux++  0.4.32
CommandFrame.hpp
1 #if !defined(__COMMANDFRAME_HPP)
2 #define __COMMANDFRAME_HPP
3 
4 /*
5  CoreLinux++
6  Copyright (C) 1999,2000 CoreLinux Consortium
7 
8  The CoreLinux++ Library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12 
13  The CoreLinux++ Library Library is distributed in the hope that it will
14  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public
19  License along with the GNU C Library; see the file COPYING.LIB. If not,
20  write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA 02111-1307, USA.
22 */
23 
24 #if !defined(__COMMON_HPP)
25 #include <Common.hpp>
26 #endif
27 
28 #if !defined(__ABSTRACTCOMMAND_HPP)
29 #include <AbstractCommand.hpp>
30 #endif
31 
32 #if !defined(__VECTOR_HPP)
33 #include <Vector.hpp>
34 #endif
35 
36 #if !defined(__COMMANDFRAMEEXCEPTION_HPP)
37 #include <CommandFrameException.hpp>
38 #endif
39 
40 namespace corelinux
41 {
42  CORELINUX_VECTOR( AbstractCommandPtr , Commands );
43 
44  DECLARE_CLASS( CommandFrame );
45 
50  enum WorkState
51  {
53 
54  BUILDING = 0,
55  EXECUTING,
56  COMPLETED,
57  REVERSING,
58  REVERSED,
59  NEVERCOMPLETED
60  };
61 
69  class CommandFrame : public Synchronized
70  {
71 
72  public:
73 
74  //
75  // Constructors and destructor
76  //
78 
79  CommandFrame( bool autoReverse = false );
80 
91  throw( CommandFrameException );
92 
99  virtual ~CommandFrame( void );
100 
101  //
102  // Operator overloads
103  //
104 
115  throw( CommandFrameException );
116 
118 
119  bool operator==( CommandFrameCref ) const;
120 
121  //
122  // Accessors
123  //
124 
130  WorkState getState( void ) const;
131 
137  bool getReverseFlag( void ) const;
138 
145  virtual void getCommands( CommandsRef ) const;
146 
147  //
148  // Mutators
149  //
150 
160  throw( CommandFrameException );
161 
171  throw( CommandFrameException );
172 
180  virtual void addCommand( AbstractCommandPtr )
181  throw( CommandFrameException );
182 
183 
190  void setAutoReverse( bool ) throw( CommandFrameException );
191 
202  void execute( void ) throw( CommandFrameException );
203 
212  void executeReverse( void ) throw( CommandFrameException );
213 
214  protected:
215 
223  virtual WorkState executeCommands( void );
224 
232  virtual WorkState executeReverseCommands( void );
233 
234  protected:
235 
237 
239 
241 
243 
245 
246  Commands theCommands;
247  };
248 }
249 
250 #endif // if !defined(__COMMANDFRAME_HPP)
251 
252 /*
253  Common rcs information do not modify
254  $Author: prudhomm $
255  $Revision: 1.2 $
256  $Date: 2000/08/31 22:52:20 $
257  $Locker: $
258 */
259 
260 
261 
CommandFrameException is the base exception type for CommandFrame.
Definition: CommandFrameException.hpp:39
void setAutoReverse(bool)
Sets the auto reverse flag.
Definition: CommandFrame.cpp:201
void execute(void)
Run the frame which will iterate through the commands, calling execute for each on.
Definition: CommandFrame.cpp:217
bool theAutoReverseFlag
The recovery flag.
Definition: CommandFrame.hpp:238
WorkState theWorkState
The state of execution.
Definition: CommandFrame.hpp:242
Commands theCommands
The Commands that make up the frame.
Definition: CommandFrame.hpp:246
CommandFrame(bool autoReverse=false)
Default Constructor.
Definition: CommandFrame.cpp:33
bool operator==(CommandFrameCref) const
Equality operator.
Definition: CommandFrame.cpp:110
virtual void addCommand(AbstractCommandPtr)
Explicit call to add command.
Definition: CommandFrame.cpp:185
CommandFrameRef operator=(CommandFrameCref)
Operator assignment.
Definition: CommandFrame.cpp:78
virtual void getCommands(CommandsRef) const
Retrieves the commands into a Command collection.
Definition: CommandFrame.cpp:130
virtual WorkState executeCommands(void)
Called from execute AFTER the state is set to EXECUTING and a synchronized monitor is created...
Definition: CommandFrame.cpp:291
WorkState getState(void) const
Retrieves the state of the frame.
Definition: CommandFrame.cpp:117
AbstractCommand captures the semantics of the capabilities of commands, which is basically to provide...
Definition: AbstractCommand.hpp:38
CommandFrame builds a unit of work around one or more Commands.
Definition: CommandFrame.hpp:69
virtual WorkState executeReverseCommands(void)
Called from executeReverse AFTER the state is set to REVERSING and a synchronized monitor is created...
Definition: CommandFrame.cpp:358
void executeReverse(void)
Run the reverse commands.
Definition: CommandFrame.cpp:254
CommandFrameRef operator+=(AbstractCommandPtr)
Operator overload for adding a command.
Definition: CommandFrame.cpp:145
virtual ~CommandFrame(void)
Virtual destructor.
Definition: CommandFrame.cpp:69
WorkState
State of execution.
Definition: CommandFrame.hpp:50
Synchronized is a mixin which allows class objects to enable monitor functionality.
Definition: Synchronized.hpp:41
bool getReverseFlag(void) const
Retrieves the auto reverse flag.
Definition: CommandFrame.cpp:123
The state is in building, no work has been performed.
Definition: CommandFrame.hpp:54

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium