aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-12-18 23:01:33 +0100
committerNao Pross <naopross@thearcway.org>2017-12-18 23:01:33 +0100
commit62bd9aa4da85ef87c4d9a9bb7911f8a4e0ac9986 (patch)
treeb7187831bb1908ad2d34eadf831bf63bfd3343b1 /include
parentAdd mainwindow.ui (diff)
downloadOrbitingYeti-62bd9aa4da85ef87c4d9a9bb7911f8a4e0ac9986.tar.gz
OrbitingYeti-62bd9aa4da85ef87c4d9a9bb7911f8a4e0ac9986.zip
Moved to QtCreator project with QMake
Diffstat (limited to 'include')
-rw-r--r--include/diagram/branchstatement.hpp35
-rw-r--r--include/diagram/iteratorstatement.hpp32
-rw-r--r--include/diagram/scope.hpp59
-rw-r--r--include/diagram/statement.hpp67
-rw-r--r--include/diagram/structogram.hpp17
-rw-r--r--include/ui/mainwindow.h22
6 files changed, 232 insertions, 0 deletions
diff --git a/include/diagram/branchstatement.hpp b/include/diagram/branchstatement.hpp
new file mode 100644
index 0000000..b7cc495
--- /dev/null
+++ b/include/diagram/branchstatement.hpp
@@ -0,0 +1,35 @@
+/*
+ * BranchStatement.hpp
+ *
+ * Created on: Nov 28, 2017
+ * Author: naopross
+ */
+
+#ifndef SRC_DIAGRAM_BRANCHSTATEMENT_HPP_
+#define SRC_DIAGRAM_BRANCHSTATEMENT_HPP_
+
+#include "Statement.hpp"
+
+#include <map>
+
+namespace samb {
+
+class BranchStatement: public Statement {
+public:
+ BranchStatement(Type t, const std::string& condition, pointer next);
+
+ /* accessors */
+ const std::map<std::string, pointer>& branches() const { return m_branches; }
+ std::size_t branchesCount() const { return m_branchesCount; }
+
+ inline const std::string& condition() const { return text(); }
+ inline void condition(const std::string& condition) { return text(condition); }
+
+private:
+ std::map<std::string, pointer> m_branches;
+ std::size_t m_branchesCount = 0;
+};
+
+} /* namespace samb */
+
+#endif /* SRC_DIAGRAM_BRANCHSTATEMENT_HPP_ */
diff --git a/include/diagram/iteratorstatement.hpp b/include/diagram/iteratorstatement.hpp
new file mode 100644
index 0000000..a14d78d
--- /dev/null
+++ b/include/diagram/iteratorstatement.hpp
@@ -0,0 +1,32 @@
+/*
+ * IteratorStatement.hpp
+ *
+ * Created on: Nov 28, 2017
+ * Author: naopross
+ */
+
+#ifndef SRC_DIAGRAM_ITERATORSTATEMENT_HPP_
+#define SRC_DIAGRAM_ITERATORSTATEMENT_HPP_
+
+#include "Statement.hpp"
+#include "Scope.hpp"
+
+namespace samb {
+
+class IteratorStatement: public Statement {
+public:
+ IteratorStatement(Type t, const std::string& condition, pointer next);
+
+ /* accessors */
+ const Scope& inner() const { return m_inner; }
+
+ inline const std::string& condition() const { return text(); }
+ inline void condition(const std::string& condition) { return text(condition); }
+
+private:
+ Scope m_inner;
+};
+
+} /* namespace samb */
+
+#endif /* SRC_DIAGRAM_ITERATORSTATEMENT_HPP_ */
diff --git a/include/diagram/scope.hpp b/include/diagram/scope.hpp
new file mode 100644
index 0000000..bf85759
--- /dev/null
+++ b/include/diagram/scope.hpp
@@ -0,0 +1,59 @@
+/*
+ * Created on: Nov 28, 2017
+ * Author: naopross
+ */
+
+#ifndef SRC_DIAGRAM_SCOPE_HPP_
+#define SRC_DIAGRAM_SCOPE_HPP_
+
+#include "Statement.hpp"
+
+namespace samb {
+
+/* The Scope is a forward-iterable object that contains statements.
+ * A scope is also a valid type of statement.
+ *
+ * The Scope object is used inside other complex types of statements such as
+ * BranchStatement or a IteratorStatement, to hold the statements within their
+ * scope.
+ */
+class Scope : public Statement {
+public:
+ class iterator {
+ public:
+ explicit iterator(pointer statement);
+ ~iterator();
+
+ iterator& operator++();
+ iterator& operator++(int);
+
+ Statement& operator*() const;
+ Statement::pointer operator->() const;
+
+ private:
+ Statement::pointer m_current;
+ };
+
+ explicit Scope(std::string label);
+ Scope(std::string label, Statement::pointer first);
+ ~Scope();
+
+ iterator insert_after(iterator it, Statement::pointer statement);
+ iterator erase_after(iterator it);
+
+ /* accessors */
+ std::size_t size() const { return m_size; }
+
+ /* iterator */
+ iterator begin() { return iterator(m_head); }
+ iterator end() { return iterator(m_tail); }
+
+private:
+ Statement::pointer m_head;
+ Statement::pointer m_tail;
+ std::size_t m_size = 0;
+};
+
+} /* namespace samb */
+
+#endif /* SRC_DIAGRAM_SCOPE_HPP_ */
diff --git a/include/diagram/statement.hpp b/include/diagram/statement.hpp
new file mode 100644
index 0000000..ab8c5b7
--- /dev/null
+++ b/include/diagram/statement.hpp
@@ -0,0 +1,67 @@
+/*
+ * Statement.h
+ *
+ * Created on: Nov 23, 2017
+ * Author: naopross
+ */
+
+#ifndef SRC_DIAGRAM_STATEMENT_H_
+#define SRC_DIAGRAM_STATEMENT_H_
+
+#include <string>
+#include <memory>
+
+namespace samb {
+
+/* Possible types of statement, according to the NS diagram paper
+ *
+ * PROCESS : a statement that does something
+ * SCOPE : simple scope to isolate variables
+ * DECISION : splits the program in 2 branches based on a condition
+ * SWITCH : splits the program in n branches depending on a value
+ * WHILE : check first loop
+ * UNTIL : check last loop
+ * PARALLEL : parallel operations
+ */
+
+/* This struct is a statement (link) of the iterable object Scope
+ * (linked list), that is also a common interface for the various types of
+ * statements.
+ */
+class Statement {
+public:
+ using pointer = std::shared_ptr<Statement>;
+
+ enum Type {
+ PROCESS,
+ SCOPE,
+ DECISION,
+ SWITCH,
+ WHILE,
+ UNTIL,
+ PARALLEL,
+ };
+
+ const Type type;
+
+ Statement(Type t, const std::string& text);
+ Statement(Type t, const std::string& text, pointer next);
+ virtual ~Statement();
+
+ bool operator==(const Statement& other) const;
+
+ /* accessors */
+ void next(pointer next) { m_next = next; }
+ pointer next() const { return m_next; }
+
+ void text(const std::string& text) { m_text = text; }
+ const std::string& text() const { return m_text; }
+
+private:
+ std::string m_text;
+ pointer m_next;
+};
+
+} /* namespace samb */
+
+#endif /* SRC_DIAGRAM_STATEMENT_H_ */
diff --git a/include/diagram/structogram.hpp b/include/diagram/structogram.hpp
new file mode 100644
index 0000000..84a4b84
--- /dev/null
+++ b/include/diagram/structogram.hpp
@@ -0,0 +1,17 @@
+/*
+ * Structogram.hpp
+ *
+ * Created on: Nov 28, 2017
+ * Author: naopross
+ */
+
+#ifndef SRC_DIAGRAM_STRUCTOGRAM_HPP_
+#define SRC_DIAGRAM_STRUCTOGRAM_HPP_
+
+#include "Scope.hpp"
+
+namespace samb {
+ typedef Scope Structogram;
+}
+
+#endif /* SRC_DIAGRAM_STRUCTOGRAM_HPP_ */
diff --git a/include/ui/mainwindow.h b/include/ui/mainwindow.h
new file mode 100644
index 0000000..a3948a9
--- /dev/null
+++ b/include/ui/mainwindow.h
@@ -0,0 +1,22 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+private:
+ Ui::MainWindow *ui;
+};
+
+#endif // MAINWINDOW_H