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

Factory to create StackOperators and help from StackOperatorCreators. More...

#include <StackOperatorFactory.h>

Public Member Functions

 StackOperatorFactory ()
 Create. More...
 
 StackOperatorFactory (const StackOperatorFactory &rhs)
 
 StackOperatorFactory (StackOperatorFactory &&rhs)
 
StackOperatorFactoryoperator= (const StackOperatorFactory &rhs)
 
StackOperatorFactoryoperator= (StackOperatorFactory &&rhs)
 
void addCreator (std::shared_ptr< StackOperatorCreator > creator)
 Add creator as available after all previous creators. More...
 
std::string getHelp () const
 
std::shared_ptr< StackOperatorcreate (const std::string &str) const
 Try to create a StackOperator for the given str. More...
 

Detailed Description

Factory to create StackOperators and help from StackOperatorCreators.

This class is simple for a reason: if you want to change available commands, create a factory for each situation and provide it when relevant.

Note
When creating StackOperators, the first added creator that can make a StackOperator wins and terminates. There is no ambiguity or resolution done.

Definition at line 31 of file StackOperatorFactory.h.

Constructor & Destructor Documentation

◆ StackOperatorFactory() [1/3]

Calculator::StackOperatorFactory::StackOperatorFactory ( )

Create.

Definition at line 32 of file StackOperatorFactory.cpp.

◆ StackOperatorFactory() [2/3]

Calculator::StackOperatorFactory::StackOperatorFactory ( const StackOperatorFactory rhs)

Definition at line 37 of file StackOperatorFactory.cpp.

◆ StackOperatorFactory() [3/3]

Calculator::StackOperatorFactory::StackOperatorFactory ( StackOperatorFactory &&  rhs)

Definition at line 42 of file StackOperatorFactory.cpp.

Member Function Documentation

◆ addCreator()

void Calculator::StackOperatorFactory::addCreator ( std::shared_ptr< StackOperatorCreator creator)

Add creator as available after all previous creators.

Parameters
creatorto add

Definition at line 59 of file StackOperatorFactory.cpp.

◆ create()

StackOperator::Ptr Calculator::StackOperatorFactory::create ( const std::string &  str) const

Try to create a StackOperator for the given str.

Parameters
strto use in attempting to create a StackOperator
Returns
StackOperator created, or none if there is no match to str

Definition at line 73 of file StackOperatorFactory.cpp.

◆ getHelp()

std::string Calculator::StackOperatorFactory::getHelp ( ) const
Returns
help string for all available creators

Definition at line 63 of file StackOperatorFactory.cpp.

◆ operator=() [1/2]

StackOperatorFactory & Calculator::StackOperatorFactory::operator= ( const StackOperatorFactory rhs)

Definition at line 48 of file StackOperatorFactory.cpp.

◆ operator=() [2/2]

StackOperatorFactory & Calculator::StackOperatorFactory::operator= ( StackOperatorFactory &&  rhs)

Definition at line 53 of file StackOperatorFactory.cpp.


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