CoreLinux++  0.4.32
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
corelinux::CommandFrame Class Reference

CommandFrame builds a unit of work around one or more Commands. More...

#include <CommandFrame.hpp>

Public Member Functions

 CommandFrame (bool autoReverse=false)
 Default Constructor.
 
 throw (CommandFrameException)
 Copy constructor. More...
 
virtual ~CommandFrame (void)
 Virtual destructor. More...
 
CommandFrameRef operator= (CommandFrameCref) throw ( CommandFrameException )
 Operator assignment. More...
 
bool operator== (CommandFrameCref) const
 Equality operator.
 
WorkState getState (void) const
 Retrieves the state of the frame. More...
 
bool getReverseFlag (void) const
 Retrieves the auto reverse flag. More...
 
virtual void getCommands (CommandsRef) const
 Retrieves the commands into a Command collection. More...
 
CommandFrameRef operator+= (AbstractCommandPtr) throw ( CommandFrameException )
 Operator overload for adding a command. More...
 
CommandFrameRef operator+= (CommandFrameCref) throw ( CommandFrameException )
 Operator overload for appending commands from another CommandFrame to the current frame. More...
 
virtual void addCommand (AbstractCommandPtr) throw ( CommandFrameException )
 Explicit call to add command. More...
 
void setAutoReverse (bool) throw ( CommandFrameException )
 Sets the auto reverse flag. More...
 
void execute (void) throw ( CommandFrameException )
 Run the frame which will iterate through the commands, calling execute for each on. More...
 
void executeReverse (void) throw ( CommandFrameException )
 Run the reverse commands. More...
 
- Public Member Functions inherited from corelinux::Synchronized
 Synchronized (void)
 Default constructor.
 
 Synchronized (SynchronizedCref)
 Copy constructor.
 
virtual ~Synchronized (void)
 Virtual Destructor.
 
SynchronizedRef operator= (SynchronizedCref)
 Assignment operator.
 
bool operator== (SynchronizedCref) const
 Equality operator.
 

Protected Member Functions

virtual WorkState executeCommands (void)
 Called from execute AFTER the state is set to EXECUTING and a synchronized monitor is created. More...
 
virtual WorkState executeReverseCommands (void)
 Called from executeReverse AFTER the state is set to REVERSING and a synchronized monitor is created. More...
 
- Protected Member Functions inherited from corelinux::Synchronized
Guard access (void) const throw (SemaphoreException)
 Access returns a instance of Guard which is block scoped to the caller. More...
 

Protected Attributes

bool theAutoReverseFlag
 The recovery flag.
 
WorkState theWorkState
 The state of execution.
 
Commands theCommands
 The Commands that make up the frame.
 

Additional Inherited Members

- Protected Types inherited from corelinux::Synchronized
typedef GuardGuardPtr
 
typedef const GuardGuardCptr
 
typedef GuardGuardRef
 
typedef const GuardGuardCref
 

Detailed Description

CommandFrame builds a unit of work around one or more Commands.

It maintains state and can be flagged to auto recover (reverse) the command effects.

Constructor & Destructor Documentation

corelinux::CommandFrame::~CommandFrame ( void  )
virtual

Virtual destructor.

Clears the colleciton of commands from the list. DOES NOT DESTROY THEM!!!

References theAutoReverseFlag, theCommands, and theWorkState.

Member Function Documentation

void corelinux::CommandFrame::addCommand ( AbstractCommandPtr  aCommand)
throw (CommandFrameException
)
virtual

Explicit call to add command.

Parameters
AbstractCommandpointer
Exceptions
CommandFrameExceptionif not building or pointer is NULLPTR
void corelinux::CommandFrame::execute ( void  )
throw (CommandFrameException
)

Run the frame which will iterate through the commands, calling execute for each on.

The state must be BUILDING, which will change to COMPLETED if all goes well, REVERSED if auto reverse is true and there was a need to roll-back the commands, or NEVERCOMPLETED if auto reverse if false.

Exceptions
CommandFrameExceptionif state not BUILDING

References corelinux::Exception::addUnwindInfo(), corelinux::BUILDING, executeCommands(), theWorkState, and throw().

WorkState corelinux::CommandFrame::executeCommands ( void  )
protectedvirtual

Called from execute AFTER the state is set to EXECUTING and a synchronized monitor is created.

Returns
WorkState indicating the last state of execution.

References corelinux::AbstractCommand::execute(), getReverseFlag(), and theCommands.

Referenced by execute().

void corelinux::CommandFrame::executeReverse ( void  )
throw (CommandFrameException
)

Run the reverse commands.

The state must be COMPLETED for this to work. You can reverse a CommandFrame even if the auto reverse command is off. The state, upon valid completion will be REVERSED or NEVERCOMPLETED in case of error

Exceptions
CommandFrameExceptionif state not COMPLETED

References corelinux::Exception::addUnwindInfo(), executeReverseCommands(), theWorkState, and throw().

WorkState corelinux::CommandFrame::executeReverseCommands ( void  )
protectedvirtual

Called from executeReverse AFTER the state is set to REVERSING and a synchronized monitor is created.

Returns
WorkState indicating the last state of execution.

References theCommands.

Referenced by executeReverse().

void corelinux::CommandFrame::getCommands ( CommandsRef  aCommandList) const
virtual

Retrieves the commands into a Command collection.

Parameters
Commandsreference

References theCommands.

bool corelinux::CommandFrame::getReverseFlag ( void  ) const

Retrieves the auto reverse flag.

Returns
bool true if autoreverse enabled

References theAutoReverseFlag.

Referenced by executeCommands().

WorkState corelinux::CommandFrame::getState ( void  ) const

Retrieves the state of the frame.

Returns
WorkState

References theWorkState.

CommandFrameRef corelinux::CommandFrame::operator+= ( AbstractCommandPtr  aCommand)
throw (CommandFrameException
)

Operator overload for adding a command.

Parameters
AbstractCommandpointer
Returns
CommandFrame reference
Exceptions
CommandFrameExceptionif not building or pointer is NULLPTR
CommandFrameRef corelinux::CommandFrame::operator+= ( CommandFrameCref  aCommandFrame)
throw (CommandFrameException
)

Operator overload for appending commands from another CommandFrame to the current frame.

Parameters
CommandFrameconst reference
Returns
CommandFrame reference to self
Exceptions
CommandFrameExceptionif not building
CommandFrameRef corelinux::CommandFrame::operator= ( CommandFrameCref  aCommandFrame)
throw (CommandFrameException
)

Operator assignment.

The commands from the argument replace the commands in the current CommandFrame.

Parameters
CommandFrameconst reference
Returns
CommandFrame reference to self
Exceptions
CommandFrameExceptionif not building

References corelinux::BUILDING.

void corelinux::CommandFrame::setAutoReverse ( bool  autoReverse)
throw (CommandFrameException
)

Sets the auto reverse flag.

Parameters
booltrue to auto recover from exceptions
Exceptions
CommandFrameExceptionif not building

References corelinux::BUILDING.

corelinux::CommandFrame::throw ( CommandFrameException  )

Copy constructor.

Parameters
CommandFrameanother CommandFrame reference
Exceptions
CommandFrameExceptionif the state of the argument is not BUILDING, COMPLETED, or REVERSED. The state of this CommandFrame is set to BUILDING

Referenced by execute(), and executeReverse().


The documentation for this class was generated from the following files:

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