amath  1.8.5
Simple command line calculator
Program Class Referenceabstract

Master control class. More...

#include <program.h>

Inheritance diagram for Program:
Collaboration diagram for Program:

Public Member Functions

 Program ()
 
virtual ~Program ()
 
virtual void Initialize (int argc, char **argv)=0
 
virtual void Start ()=0
 
virtual void Exit ()
 
void NewPositionalInput (short unsigned int base, short unsigned int digits)
 
void NewPositionalOutput (short unsigned int base, short unsigned int digits)
 
void SetLastResult (Number *number)
 
void SetPrompt (const char *text) const
 
int GetExitStatus () const
 
bool GetAnsiMode () const
 
void SetAnsiMode (bool value)
 
struct NumberGetLastResult () const
 

Public Attributes

class LanguageLanguage
 
class ConsoleBaseConsole
 
class PreferencesBasePreferences
 
class FilesystemBaseFilesystem
 
class NumeralSystemInput
 
class NumeralSystemOutput
 
class VariableListVariables
 
class FunctionListFunctions
 
class GraphList * Graphs
 

Protected Member Functions

void InitAnsiMode ()
 

Protected Attributes

bool shellMode
 
bool ansiMode
 
int status
 

Private Attributes

struct Numberins
 

Detailed Description

Master control class.

This control class handles all processes and data in the entire program. It usually only exist as a single instance.

Definition at line 55 of file program.h.

Constructor & Destructor Documentation

◆ Program()

Program::Program ( )

Definition at line 48 of file program.cpp.

References ansiMode, Console, DecimalSystem::DecimalSystem(), Filesystem, FunctionList::FunctionList(), Functions, PreferencesBase::GetDigits(), Language::GetFractionPoint(), Input, ins, Output, Preferences, RealNumber::RealNumber(), shellMode, StandardLanguage::StandardLanguage(), status, VariableList::VariableList(), and Variables.

Referenced by StandardProgram::StandardProgram().

48  :
49  Console(nullptr), shellMode(false), ansiMode(false), status(0)
50 {
51  Variables = new VariableList();
52  Functions = new FunctionList();
53  ins = new RealNumber();
54 #if defined(AMIGA)
55  Language = new AmigaLanguage();
56  Filesystem = new AmigaFilesystem();
57  Preferences = new AmigaPreferences();
58 #else
59  Language = new StandardLanguage();
62 #endif
65 }
struct Number * ins
Definition: program.h:88
virtual char GetFractionPoint()=0
int status
Definition: program.h:85
class FilesystemBase * Filesystem
Definition: program.h:74
A list of user defined variables.
Definition: values.h:49
class FunctionList * Functions
Definition: program.h:78
Represent a real number with 15 significant digits.
Definition: real.h:45
class VariableList * Variables
Definition: program.h:77
bool ansiMode
Definition: program.h:84
bool shellMode
Definition: program.h:83
A list of user defined functions.
Definition: functionlist.h:42
class NumeralSystem * Input
Definition: program.h:75
int GetDigits() const
class ConsoleBase * Console
Definition: program.h:72
class PreferencesBase * Preferences
Definition: program.h:73
class NumeralSystem * Output
Definition: program.h:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Program()

Program::~Program ( )
virtual

Definition at line 67 of file program.cpp.

References Filesystem, Functions, Input, ins, PreferencesBase::Keep(), Output, Preferences, and Variables.

68 {
69  delete Variables;
70  delete Functions;
71  delete Filesystem;
72  delete Output;
73  delete Input;
74  delete Language;
75  delete ins;
76 
77  Preferences->Keep();
78  delete Preferences;
79 }
struct Number * ins
Definition: program.h:88
virtual bool Keep()=0
class FilesystemBase * Filesystem
Definition: program.h:74
class FunctionList * Functions
Definition: program.h:78
class Language * Language
Definition: program.h:71
class VariableList * Variables
Definition: program.h:77
class NumeralSystem * Input
Definition: program.h:75
class PreferencesBase * Preferences
Definition: program.h:73
class NumeralSystem * Output
Definition: program.h:76
Here is the call graph for this function:

Member Function Documentation

◆ Exit()

void Program::Exit ( )
virtual

Reimplemented in TestProgram.

Definition at line 168 of file program.cpp.

References Console, and ConsoleBase::Exit().

Referenced by ExitStatement::Execute().

169 {
170  Console->Exit();
171 }
virtual void Exit()=0
class ConsoleBase * Console
Definition: program.h:72
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAnsiMode()

bool Program::GetAnsiMode ( ) const

Definition at line 143 of file program.cpp.

References ansiMode.

144 {
145  return ansiMode;
146 }
bool ansiMode
Definition: program.h:84

◆ GetExitStatus()

int Program::GetExitStatus ( ) const

Definition at line 133 of file program.cpp.

References status.

Referenced by main().

134 {
135  return status;
136 }
int status
Definition: program.h:85
Here is the caller graph for this function:

◆ GetLastResult()

Number * Program::GetLastResult ( ) const

Definition at line 122 of file program.cpp.

References ins.

Referenced by InsVariableNode::Evaluate().

123 {
124  return ins;
125 }
struct Number * ins
Definition: program.h:88
Here is the caller graph for this function:

◆ InitAnsiMode()

void Program::InitAnsiMode ( )
protected

Definition at line 138 of file program.cpp.

References ansiMode, and SetAnsiMode().

139 {
141 }
void SetAnsiMode(bool value)
Definition: program.cpp:148
bool ansiMode
Definition: program.h:84
Here is the call graph for this function:

◆ Initialize()

virtual void Program::Initialize ( int  argc,
char **  argv 
)
pure virtual

Implemented in TestProgram, and StandardProgram.

Referenced by main().

Here is the caller graph for this function:

◆ NewPositionalInput()

void Program::NewPositionalInput ( short unsigned int  base,
short unsigned int  digits 
)

Definition at line 81 of file program.cpp.

References DecimalSystem::DecimalSystem(), Language::GetFractionPoint(), Input, and PositionalNumeralSystem::PositionalNumeralSystem().

Referenced by InputStatement::Execute().

82 {
83  delete Input;
84 
85  char fractionPoint = Language->GetFractionPoint();
86 
87  if (base == 10)
88  {
89  Input = new DecimalSystem(digits, fractionPoint);
90  }
91  else
92  {
93  Input = new PositionalNumeralSystem(base, digits, fractionPoint);
94  }
95 }
virtual char GetFractionPoint()=0
Base class for all numeral systems with a positional notation.
Definition: ntextp.h:41
class NumeralSystem * Input
Definition: program.h:75
Here is the call graph for this function:
Here is the caller graph for this function:

◆ NewPositionalOutput()

void Program::NewPositionalOutput ( short unsigned int  base,
short unsigned int  digits 
)

Definition at line 97 of file program.cpp.

References DecimalSystem::DecimalSystem(), Language::GetFractionPoint(), Output, and PositionalNumeralSystem::PositionalNumeralSystem().

Referenced by OutputStatement::Execute().

98 {
99  delete Output;
100 
101  char fractionPoint = Language->GetFractionPoint();
102 
103  if (base == 10)
104  {
105  Output = new DecimalSystem(digits, fractionPoint);
106  }
107  else
108  {
109  Output = new PositionalNumeralSystem(base, digits, fractionPoint);
110  }
111 }
virtual char GetFractionPoint()=0
Base class for all numeral systems with a positional notation.
Definition: ntextp.h:41
class NumeralSystem * Output
Definition: program.h:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetAnsiMode()

void Program::SetAnsiMode ( bool  value)

Definition at line 148 of file program.cpp.

References ansiMode, Console, ConsoleBase::SetAnsiMode(), and Language::SetAnsiMode().

Referenced by InitAnsiMode(), StandardProgram::Initialize(), and StandardProgram::Start().

149 {
150  if (Console != nullptr)
151  {
152  bool success = Console->SetAnsiMode(value);
153  if (!success)
154  {
156  return;
157  }
158  }
159 
160  if (Language != nullptr)
161  {
162  Language->SetAnsiMode(value);
163  }
164 
165  ansiMode = value;
166 }
virtual bool SetAnsiMode(bool value)
Definition: console.cpp:109
void SetAnsiMode(bool value)
Definition: language.cpp:100
bool ansiMode
Definition: program.h:84
class ConsoleBase * Console
Definition: program.h:72
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetLastResult()

void Program::SetLastResult ( Number number)

Definition at line 127 of file program.cpp.

References Number::Clone(), and ins.

Referenced by EvalStatement::Execute().

128 {
129  delete ins;
130  ins = number->Clone();
131 }
struct Number * ins
Definition: program.h:88
virtual Number * Clone()=0
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPrompt()

void Program::SetPrompt ( const char *  text) const

Definition at line 113 of file program.cpp.

References Console, Preferences, PreferencesBase::SetPrompt(), and ConsoleBase::SetPrompt().

Referenced by PromptStatement::Execute().

114 {
115  if (Console != nullptr)
116  {
117  Console->SetPrompt(text);
118  }
119  Preferences->SetPrompt(text);
120 }
void SetPrompt(const char *prompt)
virtual void SetPrompt(const char *string)
Definition: console.cpp:214
class ConsoleBase * Console
Definition: program.h:72
class PreferencesBase * Preferences
Definition: program.h:73
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Start()

virtual void Program::Start ( )
pure virtual

Implemented in TestProgram, and StandardProgram.

Referenced by main().

Here is the caller graph for this function:

Member Data Documentation

◆ ansiMode

bool Program::ansiMode
protected

Definition at line 84 of file program.h.

Referenced by GetAnsiMode(), InitAnsiMode(), Program(), and SetAnsiMode().

◆ Console

◆ Filesystem

◆ Functions

◆ Graphs

class GraphList* Program::Graphs

Definition at line 79 of file program.h.

◆ Input

◆ ins

struct Number* Program::ins
private

Definition at line 88 of file program.h.

Referenced by GetLastResult(), Program(), SetLastResult(), and ~Program().

◆ Language

class Language* Program::Language

Definition at line 71 of file program.h.

◆ Output

◆ Preferences

◆ shellMode

bool Program::shellMode
protected

◆ status

int Program::status
protected

Definition at line 85 of file program.h.

Referenced by GetExitStatus(), and Program().

◆ Variables


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