---
name: "corelinux_CommandFrame"
section: "3"
platform: "linux"
package: "libcorelinux-dev"
version: "0.4.32-5"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/corelinux_CommandFrame"
---

# corelinux\_CommandFrame(3)

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

## NAME

corelinux::CommandFrame - **CommandFrame** builds a unit of work around one or more Commands.

## SYNOPSIS

`#include <CommandFrame.hpp>`

Inherits **corelinux::Synchronized**.

### Public Member Functions

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

### Protected Member Functions

virtual **WorkState** **executeCommands** (void)\
 *Called from execute AFTER the state is set to EXECUTING and a synchronized monitor is created.*  virtual **WorkState** **executeReverseCommands** (void)\
 *Called from executeReverse AFTER the state is set to REVERSING and a synchronized monitor is created.*

### Protected Attributes

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

## 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 (CommandFrameCref) throw ( CommandFrameException )

Copy constructor. **Parameters:**

*CommandFrame* another **CommandFrame** reference

**Exceptions:**

*CommandFrameException* if the state of the argument is not BUILDING, COMPLETED, or REVERSED. The state of this **CommandFrame** is set to BUILDING

### corelinux::CommandFrame::~CommandFrame (void)` [virtual]`

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

## Member Function Documentation

### void corelinux::CommandFrame::addCommand (AbstractCommandPtr) throw ( CommandFrameException )` [virtual]`

Explicit call to add command. **Parameters:**

*AbstractCommand* pointer

**Exceptions:**

*CommandFrameException* if 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:**

*CommandFrameException* if state not BUILDING

### WorkState corelinux::CommandFrame::executeCommands (void)` [protected, virtual]`

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

WorkState indicating the last state of execution.

### 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:**

*CommandFrameException* if state not COMPLETED

### WorkState corelinux::CommandFrame::executeReverseCommands (void)` [protected, virtual]`

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

WorkState indicating the last state of execution.

### void corelinux::CommandFrame::getCommands (CommandsRef) const` [virtual]`

Retrieves the commands into a **Command** collection. **Parameters:**

*Commands* reference

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

Retrieves the auto reverse flag. **Returns:**

bool true if autoreverse enabled

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

Retrieves the state of the frame. **Returns:**

WorkState

### CommandFrameRef corelinux::CommandFrame::operator+= (CommandFrameCref) throw ( CommandFrameException )

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

*CommandFrame* const reference

**Returns:**

**CommandFrame** reference to self

**Exceptions:**

*CommandFrameException* if not building

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

Operator overload for adding a command. **Parameters:**

*AbstractCommand* pointer

**Returns:**

**CommandFrame** reference

**Exceptions:**

*CommandFrameException* if not building or pointer is NULLPTR

### CommandFrameRef corelinux::CommandFrame::operator= (CommandFrameCref) throw ( CommandFrameException )

Operator assignment. The commands from the argument replace the commands in the current **CommandFrame**.

**Parameters:**

*CommandFrame* const reference

**Returns:**

**CommandFrame** reference to self

**Exceptions:**

*CommandFrameException* if not building

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

Sets the auto reverse flag. **Parameters:**

*bool* true to auto recover from exceptions

**Exceptions:**

*CommandFrameException* if not building

## Author

Generated automatically by Doxygen for CoreLinux++ from the source code.
