diff options
author | Nao Pross <naopross@thearcway.org> | 2017-12-19 01:54:28 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2017-12-19 01:54:28 +0100 |
commit | a7e74749a1c4edb2f8bc34c79e9bd1562de86ee9 (patch) | |
tree | 4282a5dfa9ef7d77823e3e8ef02a193c91e719d6 /include/diagram/statement.h | |
parent | Moved to QtCreator project with QMake (diff) | |
download | OrbitingYeti-a7e74749a1c4edb2f8bc34c79e9bd1562de86ee9.tar.gz OrbitingYeti-a7e74749a1c4edb2f8bc34c79e9bd1562de86ee9.zip |
Change to Qt5 conding conventions
Data structure changes:
- Structogram is no longer just a scope, because it needs to store
metadata
- All structures now use QString instead of std::string, to
integrate better in the Qt framework
New code:
- MainWindow ui code, building layout
- MetadataDialog to change the metadata stored in the Structogram
- Painter is a widget (still unimplemented) to show the structogram
on the GUI
Diffstat (limited to 'include/diagram/statement.h')
-rw-r--r-- | include/diagram/statement.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/include/diagram/statement.h b/include/diagram/statement.h new file mode 100644 index 0000000..5cce908 --- /dev/null +++ b/include/diagram/statement.h @@ -0,0 +1,63 @@ +#ifndef DIAGRAM_STATEMENT_H +#define DIAGRAM_STATEMENT_H + +#include <string> +#include <memory> + +#include <QString> + +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 QString &text); + Statement(Type t, const QString &text, pointer next); + virtual ~Statement(); + + bool operator==(const Statement& other) const; + + /* accessors */ + void next(pointer next) { _next = next; } + pointer next() const { return _next; } + + void text(const QString &text) { _text = text; } + const QString& text() const { return _text; } + +private: + QString _text; + pointer _next; +}; + +} /* namespace samb */ + +#endif /* DIAGRAM_STATEMENT_H */ |