amath  1.8.5
Simple command line calculator
program.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  * Project homepage:
26  * https://amath.innolan.net
27  *
28  */
29 
30 #ifndef AMATH_PROGRAM_H
31 #define AMATH_PROGRAM_H
32 
33 /**
34  * @file program.h
35  * @brief Program flow and global states.
36  *
37  */
38 
39 #include "console.h"
40 #include "language.h"
41 #include "filesystem.h"
42 #include "preferences.h"
43 #include "lib/numb.h"
44 #include "lib/ntext.h"
45 #include "main/values.h"
46 #include "main/functionlist.h"
47 
48 /**
49 * @brief Master control class.
50 * @details
51 * This control class handles all processes and data
52 * in the entire program. It usually only exist as a
53 * single instance.
54 */
55 class Program
56 {
57 public:
58  Program();
59  virtual ~Program();
60  virtual void Initialize(int argc, char** argv) = 0;
61  virtual void Start() = 0;
62  virtual void Exit();
63  void NewPositionalInput(short unsigned int base, short unsigned int digits);
64  void NewPositionalOutput(short unsigned int base, short unsigned int digits);
65  void SetLastResult(Number* number);
66  void SetPrompt(const char* text) const;
67  int GetExitStatus() const;
68  bool GetAnsiMode() const;
69  void SetAnsiMode(bool value);
70  struct Number* GetLastResult() const;
71  class Language* Language;
79  class GraphList* Graphs;
80 
81 protected:
82  void InitAnsiMode();
83  bool shellMode;
84  bool ansiMode;
85  int status;
86 
87 private:
88  struct Number* ins;
89 };
90 
91 #endif
void SetPrompt(const char *text) const
Definition: program.cpp:113
void NewPositionalInput(short unsigned int base, short unsigned int digits)
Definition: program.cpp:81
Master control class.
Definition: program.h:55
struct Number * ins
Definition: program.h:88
void NewPositionalOutput(short unsigned int base, short unsigned int digits)
Definition: program.cpp:97
virtual void Start()=0
int status
Definition: program.h:85
class FilesystemBase * Filesystem
Definition: program.h:74
Abstract base class encapsulating console logic.
Definition: console.h:43
void SetAnsiMode(bool value)
Definition: program.cpp:148
Definition: numb.h:66
A list of user defined variables.
Definition: values.h:49
virtual void Exit()
Definition: program.cpp:168
bool GetAnsiMode() const
Definition: program.cpp:143
class FunctionList * Functions
Definition: program.h:78
virtual void Initialize(int argc, char **argv)=0
Abstract base class encapsulating file system calls.
Definition: filesystem.h:45
void InitAnsiMode()
Definition: program.cpp:138
class GraphList * Graphs
Definition: program.h:79
virtual ~Program()
Definition: program.cpp:67
class VariableList * Variables
Definition: program.h:77
Program()
Definition: program.cpp:48
bool ansiMode
Definition: program.h:84
bool shellMode
Definition: program.h:83
struct Number * GetLastResult() const
Definition: program.cpp:122
Base class for all numeral systems.
Definition: ntext.h:49
int GetExitStatus() const
Definition: program.cpp:133
A list of user defined functions.
Definition: functionlist.h:42
void SetLastResult(Number *number)
Definition: program.cpp:127
class NumeralSystem * Input
Definition: program.h:75
class ConsoleBase * Console
Definition: program.h:72
class PreferencesBase * Preferences
Definition: program.h:73
class NumeralSystem * Output
Definition: program.h:76