Calculator
Extensible stack-based calculator primarily in library form
Calculator::StackManipulator Class Reference

Stack Modifier for Stack Operations. More...

#include <StackManipulator.h>

Inheritance diagram for Calculator::StackManipulator:
Collaboration diagram for Calculator::StackManipulator:

Public Types

enum class  Operation {
  POP , DUP , SWAP , RESET ,
  POP_ALL
}
 Operations supported. More...
 
- Public Types inherited from Calculator::StackOperator
typedef std::shared_ptr< StackOperatorPtr
 

Public Member Functions

 ~StackManipulator ()
 
virtual Result operator() (Stack &stack, StackOperator::Ptr ofThis)
 Execute this operator on stack. More...
 
- Public Member Functions inherited from Calculator::StackOperator
virtual ~StackOperator ()
 

Static Public Member Functions

static StackManipulator::Ptr create (Operation operation)
 Create to perform operation. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Calculator::StackOperator
 StackOperator ()=default
 
 StackOperator (const StackOperator &)=delete
 
 StackOperator (StackOperator &&)=delete
 
StackOperatoroperator= (const StackOperator &)=delete
 
StackOperatoroperator= (StackOperator &&)=delete
 

Detailed Description

Stack Modifier for Stack Operations.

Support multiple operations distinguished by the Operation parameter.

Operations support separate stack-element manipulations

Definition at line 29 of file StackManipulator.h.

Member Enumeration Documentation

◆ Operation

Operations supported.

Enumerator
POP 

Pop the top value off and forget it.

DUP 

Duplicate the top value.

SWAP 

Swap the top two elements.

RESET 

Clear the entire stack and set of variables.

POP_ALL 

Clear the entire stack.

Definition at line 32 of file StackManipulator.h.

Constructor & Destructor Documentation

◆ ~StackManipulator()

Calculator::StackManipulator::~StackManipulator ( )

Definition at line 29 of file StackManipulator.cpp.

Member Function Documentation

◆ create()

StackManipulator::Ptr Calculator::StackManipulator::create ( Operation  operation)
static

Create to perform operation.

Parameters
operationto perform
Returns
StackManipulator created

Definition at line 25 of file StackManipulator.cpp.

◆ operator()()

Result Calculator::StackManipulator::operator() ( Stack stack,
StackOperator::Ptr  ofThis 
)
virtual

Execute this operator on stack.

Parameters
stackto operate on
ofThisis this in a copied StackOperator::Ptr to maintain integrity of the shared_ptrs.
Returns
Result of execution

Implements Calculator::StackOperator.

Definition at line 37 of file StackManipulator.cpp.


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