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

Stack Modifier for Binary Math Operations. More...

#include <BinaryMathOperator.h>

Inheritance diagram for Calculator::BinaryMathOperator:
Collaboration diagram for Calculator::BinaryMathOperator:

Public Types

enum class  Operation {
  ADD , SUBTRACT , MULTIPLY , DIVIDE ,
  EXPONENT
}
 Operations supported. More...
 
typedef std::shared_ptr< BinaryMathOperatorPtr
 
- Public Types inherited from Calculator::StackOperator
typedef std::shared_ptr< StackOperatorPtr
 

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
 
BinaryMathOperatoroperator= (const BinaryMathOperator &)=delete
 
BinaryMathOperatoroperator= (BinaryMathOperator &&)=delete
 
- 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 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.

Member Typedef Documentation

◆ Ptr

Definition at line 32 of file BinaryMathOperator.h.

Member Enumeration Documentation

◆ Operation

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.

Constructor & Destructor Documentation

◆ ~BinaryMathOperator()

Calculator::BinaryMathOperator::~BinaryMathOperator ( )

Definition at line 117 of file BinaryMathOperator.cpp.

◆ BinaryMathOperator() [1/3]

Calculator::BinaryMathOperator::BinaryMathOperator ( Operation  op)
protected

Create to perform operation.

Parameters
opto perform

Definition at line 120 of file BinaryMathOperator.cpp.

◆ BinaryMathOperator() [2/3]

Calculator::BinaryMathOperator::BinaryMathOperator ( const BinaryMathOperator )
protecteddelete

◆ BinaryMathOperator() [3/3]

Calculator::BinaryMathOperator::BinaryMathOperator ( BinaryMathOperator &&  )
protecteddelete

Member Function Documentation

◆ create()

BinaryMathOperator::Ptr Calculator::BinaryMathOperator::create ( Operation  op)
static

Create to perform operation.

Parameters
opto perform
Returns
BinaryMathOperator created

Definition at line 113 of file BinaryMathOperator.cpp.

◆ operator()()

Result Calculator::BinaryMathOperator::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 125 of file BinaryMathOperator.cpp.

◆ operator=() [1/2]

BinaryMathOperator& Calculator::BinaryMathOperator::operator= ( BinaryMathOperator &&  )
protecteddelete

◆ operator=() [2/2]

BinaryMathOperator& Calculator::BinaryMathOperator::operator= ( const BinaryMathOperator )
protecteddelete

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