wxMaxima
Loading...
Searching...
No Matches
MaximaSessionInfo.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2026 Gunter Königsmann <wxMaxima@physikbuch.de>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// SPDX-License-Identifier: GPL-2.0+
21
34#ifndef MAXIMASESSIONINFO_H
35#define MAXIMASESSIONINFO_H
36
37#include <wx/string.h>
38#include <wx/hashmap.h>
39#include <unordered_map>
40
48{
49public:
52 {
53 // The list elements are plain string literals: a `const wxString &`
54 // loop variable would bind to a temporary constructed per element,
55 // which gcc's -Wrange-loop-construct rejects under -Werror.
56 for (const wxChar *op : {
57 wxS("("), wxS("/"), wxS("{"), wxS("-"), wxS("^"), wxS("#"),
58 wxS("="), wxS(":"), wxS("["), wxS("'"), wxS("!"), wxS("+"),
59 wxS("*"), wxS("or"), wxS("and"), wxS("do_in"), wxS(">"),
60 wxS("$SUBVAR"), wxS("<"), wxS("if"), wxS("::="), wxS("::"),
61 wxS("@"), wxS("."), wxS("-->"), wxS("^^"), wxS("not"),
62 wxS("<="), wxS(":="), wxS(">="), wxS("$BFLOAT"), wxS("do")})
63 m_operators[op] = 1;
64 wxString operators(wxS("\u221A\u22C0\u22C1\u22BB\u22BC\u22BD\u00AC\u222b"
65 "\u2264\u2265\u2211\u2260+-*/^:=#'!()[]{}"));
66 for (wxString::const_iterator it = operators.begin();
67 it != operators.end(); ++it)
68 m_operators[wxString(*it)] = 1;
69 }
70
72 bool IsOperator(const wxString &name) const
73 { return m_operators.find(name) != m_operators.end(); }
75 void AddOperator(const wxString &name) { m_operators[name] = 1; }
76
78 wxString GetMaximaVersion() const { return m_maximaVersion; }
80 void SetMaximaVersion(const wxString &version) { m_maximaVersion = version; }
82 wxString GetMaximaArch() const { return m_maximaArch; }
84 void SetMaximaArch(const wxString &arch) { m_maximaArch = arch; }
86 wxString GetLispVersion() const { return m_lispVersion; }
88 void SetLispVersion(const wxString &version) { m_lispVersion = version; }
90 wxString GetLispType() const { return m_lispType; }
92 void SetLispType(const wxString &type) { m_lispType = type; }
93
95 wxString GetWorkingDirectory() const { return m_workingDirectory; }
97 void SetWorkingDirectory(wxString dir) { m_workingDirectory = std::move(dir); }
99 wxString ShareDir() const { return m_shareDir; }
101 void ShareDir(wxString dir) { m_shareDir = std::move(dir); }
103 wxString DemoDir() const { return m_demoDir; }
105 void DemoDir(wxString dir) { m_demoDir = std::move(dir); }
106
108 bool InLispMode() const { return m_inLispMode; }
110 void InLispMode(bool lisp) { m_inLispMode = lisp; }
111
112private:
114 std::unordered_map<wxString, int, wxStringHash> m_operators;
116 wxString m_maximaVersion;
118 wxString m_maximaArch;
120 wxString m_lispVersion;
122 wxString m_lispType;
124 wxString m_workingDirectory;
126 wxString m_shareDir;
128 wxString m_demoDir;
130 bool m_inLispMode = false;
131};
132
133#endif // MAXIMASESSIONINFO_H
What we know about the Maxima instance we are talking to.
Definition: MaximaSessionInfo.h:48
wxString GetWorkingDirectory() const
Maxima's working directory.
Definition: MaximaSessionInfo.h:95
bool InLispMode() const
Is maxima currently in lisp mode (where commands need no trailing ";")?
Definition: MaximaSessionInfo.h:108
void SetLispType(const wxString &type)
Sets the type of the lisp the connected Maxima runs on.
Definition: MaximaSessionInfo.h:92
void SetMaximaArch(const wxString &arch)
Sets the processor architecture the connected Maxima runs on.
Definition: MaximaSessionInfo.h:84
wxString GetMaximaArch() const
The processor architecture the connected Maxima runs on.
Definition: MaximaSessionInfo.h:82
void InLispMode(bool lisp)
Tells us whether maxima currently is in lisp mode.
Definition: MaximaSessionInfo.h:110
wxString GetLispVersion() const
The version of the lisp the connected Maxima runs on.
Definition: MaximaSessionInfo.h:86
wxString DemoDir() const
The directory maxima's demo files live in.
Definition: MaximaSessionInfo.h:103
void AddOperator(const wxString &name)
Registers name as an operator known to maxima.
Definition: MaximaSessionInfo.h:75
void SetWorkingDirectory(wxString dir)
Sets maxima's working directory.
Definition: MaximaSessionInfo.h:97
wxString ShareDir() const
The directory maxima's shared files (e.g. the manual) live in.
Definition: MaximaSessionInfo.h:99
void DemoDir(wxString dir)
Sets the directory maxima's demo files live in.
Definition: MaximaSessionInfo.h:105
wxString GetLispType() const
The type of the lisp the connected Maxima runs on.
Definition: MaximaSessionInfo.h:90
void ShareDir(wxString dir)
Sets the directory maxima's shared files live in.
Definition: MaximaSessionInfo.h:101
void SetMaximaVersion(const wxString &version)
Sets the version of the connected Maxima.
Definition: MaximaSessionInfo.h:80
void SetLispVersion(const wxString &version)
Sets the version of the lisp the connected Maxima runs on.
Definition: MaximaSessionInfo.h:88
wxString GetMaximaVersion() const
The version of the connected Maxima.
Definition: MaximaSessionInfo.h:78
MaximaSessionInfo()
Constructs the session info with the built-in operator names seeded.
Definition: MaximaSessionInfo.h:51
bool IsOperator(const wxString &name) const
Is this name an operator known to maxima?
Definition: MaximaSessionInfo.h:72