diff options
author | Nao Pross <naopross@thearcway.org> | 2017-12-18 23:01:33 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2017-12-18 23:01:33 +0100 |
commit | 62bd9aa4da85ef87c4d9a9bb7911f8a4e0ac9986 (patch) | |
tree | b7187831bb1908ad2d34eadf831bf63bfd3343b1 /src/diagram | |
parent | Add mainwindow.ui (diff) | |
download | OrbitingYeti-62bd9aa4da85ef87c4d9a9bb7911f8a4e0ac9986.tar.gz OrbitingYeti-62bd9aa4da85ef87c4d9a9bb7911f8a4e0ac9986.zip |
Moved to QtCreator project with QMake
Diffstat (limited to 'src/diagram')
-rw-r--r-- | src/diagram/BranchStatement.hpp | 35 | ||||
-rw-r--r-- | src/diagram/IteratorStatement.hpp | 32 | ||||
-rw-r--r-- | src/diagram/Scope.hpp | 59 | ||||
-rw-r--r-- | src/diagram/Statement.hpp | 67 | ||||
-rw-r--r-- | src/diagram/Structogram.hpp | 17 | ||||
-rw-r--r-- | src/diagram/branchstatement.cpp (renamed from src/diagram/BranchStatement.cpp) | 9 | ||||
-rw-r--r-- | src/diagram/iteratorstatement.cpp (renamed from src/diagram/IteratorStatement.cpp) | 9 | ||||
-rw-r--r-- | src/diagram/scope.cpp (renamed from src/diagram/Scope.cpp) | 7 | ||||
-rw-r--r-- | src/diagram/statement.cpp (renamed from src/diagram/Statement.cpp) | 9 |
9 files changed, 4 insertions, 240 deletions
diff --git a/src/diagram/BranchStatement.hpp b/src/diagram/BranchStatement.hpp deleted file mode 100644 index b7cc495..0000000 --- a/src/diagram/BranchStatement.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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/src/diagram/IteratorStatement.hpp b/src/diagram/IteratorStatement.hpp deleted file mode 100644 index a14d78d..0000000 --- a/src/diagram/IteratorStatement.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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/src/diagram/Scope.hpp b/src/diagram/Scope.hpp deleted file mode 100644 index bf85759..0000000 --- a/src/diagram/Scope.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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/src/diagram/Statement.hpp b/src/diagram/Statement.hpp deleted file mode 100644 index ab8c5b7..0000000 --- a/src/diagram/Statement.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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/src/diagram/Structogram.hpp b/src/diagram/Structogram.hpp deleted file mode 100644 index 84a4b84..0000000 --- a/src/diagram/Structogram.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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/src/diagram/BranchStatement.cpp b/src/diagram/branchstatement.cpp index 6345c1b..2835f35 100644 --- a/src/diagram/BranchStatement.cpp +++ b/src/diagram/branchstatement.cpp @@ -1,11 +1,4 @@ -/* - * BranchStatement.cpp - * - * Created on: Nov 28, 2017 - * Author: naopross - */ - -#include "BranchStatement.hpp" +#include "diagram/BranchStatement.hpp" using namespace samb; diff --git a/src/diagram/IteratorStatement.cpp b/src/diagram/iteratorstatement.cpp index 02a7318..675d8eb 100644 --- a/src/diagram/IteratorStatement.cpp +++ b/src/diagram/iteratorstatement.cpp @@ -1,11 +1,4 @@ -/* - * IteratorStatement.cpp - * - * Created on: Nov 28, 2017 - * Author: naopross - */ - -#include "IteratorStatement.hpp" +#include "diagram/IteratorStatement.hpp" using namespace samb; diff --git a/src/diagram/Scope.cpp b/src/diagram/scope.cpp index 721ee4b..a1074a3 100644 --- a/src/diagram/Scope.cpp +++ b/src/diagram/scope.cpp @@ -1,9 +1,4 @@ -/* - * Created on: Nov 28, 2017 - * Author: naopross - */ - -#include "Scope.hpp" +#include "diagram/Scope.hpp" using namespace samb; diff --git a/src/diagram/Statement.cpp b/src/diagram/statement.cpp index 711bcf4..9cbcdb4 100644 --- a/src/diagram/Statement.cpp +++ b/src/diagram/statement.cpp @@ -1,11 +1,4 @@ -/* - * Statement.cpp - * - * Created on: Nov 23, 2017 - * Author: naopross - */ - -#include "Statement.hpp" +#include "diagram/Statement.hpp" using namespace samb; |