Calculator
Extensible stack-based calculator primarily in library form
|
Stack Modifier for Binary Math Operations. More...
#include <BinaryMathOperator.h>
Public Types | |
enum class | Operation { ADD , SUBTRACT , MULTIPLY , DIVIDE , EXPONENT } |
Operations supported. More... | |
typedef std::shared_ptr< BinaryMathOperator > | Ptr |
Public Types inherited from Calculator::StackOperator | |
typedef std::shared_ptr< StackOperator > | Ptr |
Public Member Functions | |
~BinaryMathOperator () | |
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 BinaryMathOperator::Ptr | create (Operation op) |
Create to perform operation. More... | |
Protected Member Functions | |
BinaryMathOperator (Operation op) | |
Create to perform operation. More... | |
BinaryMathOperator (const BinaryMathOperator &)=delete | |
BinaryMathOperator (BinaryMathOperator &&)=delete | |
BinaryMathOperator & | operator= (const BinaryMathOperator &)=delete |
BinaryMathOperator & | operator= (BinaryMathOperator &&)=delete |
Protected Member Functions inherited from Calculator::StackOperator | |
StackOperator ()=default | |
StackOperator (const StackOperator &)=delete | |
StackOperator (StackOperator &&)=delete | |
StackOperator & | operator= (const StackOperator &)=delete |
StackOperator & | operator= (StackOperator &&)=delete |
Stack Modifier for Binary Math Operations.
Support multiple operations distinguished by the Operation parameter.
All Operations pop 2 items, caclulate formerTop (operator) formerSecond and push the result back onto the stack.
Definition at line 30 of file BinaryMathOperator.h.
typedef std::shared_ptr<BinaryMathOperator> Calculator::BinaryMathOperator::Ptr |
Definition at line 32 of file BinaryMathOperator.h.
|
strong |
Operations supported.
Enumerator | |
---|---|
ADD | Add the two values. |
SUBTRACT | Subtract the two values. |
MULTIPLY | Multiply the two values. |
DIVIDE | Divide the two values. |
EXPONENT | Raise top to the exponent second. |
Definition at line 35 of file BinaryMathOperator.h.
Calculator::BinaryMathOperator::~BinaryMathOperator | ( | ) |
Definition at line 117 of file BinaryMathOperator.cpp.
|
protected |
Create to perform operation.
op | to perform |
Definition at line 120 of file BinaryMathOperator.cpp.
|
protecteddelete |
|
protecteddelete |
|
static |
Create to perform operation.
op | to perform |
Definition at line 113 of file BinaryMathOperator.cpp.
|
virtual |
Execute this operator on stack.
stack | to operate on |
ofThis | is this in a copied StackOperator::Ptr to maintain integrity of the shared_ptrs. |
Implements Calculator::StackOperator.
Definition at line 125 of file BinaryMathOperator.cpp.
|
protecteddelete |
|
protecteddelete |