From a7e74749a1c4edb2f8bc34c79e9bd1562de86ee9 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Tue, 19 Dec 2017 01:54:28 +0100 Subject: 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 --- include/diagram/scope.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 include/diagram/scope.h (limited to 'include/diagram/scope.h') diff --git a/include/diagram/scope.h b/include/diagram/scope.h new file mode 100644 index 0000000..63698dd --- /dev/null +++ b/include/diagram/scope.h @@ -0,0 +1,57 @@ +#ifndef DIAGRAM_SCOPE_H +#define DIAGRAM_SCOPE_H + +#include "diagram/statement.h" + +#include + +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 _current; + }; + + explicit Scope(const QString &label); + Scope(const QString &label, Statement::pointer first); + virtual ~Scope(); + + iterator insert_after(iterator it, Statement::pointer statement); + iterator erase_after(iterator it); + + /* accessors */ + std::size_t size() const { return _size; } + + /* iterator */ + iterator begin() { return iterator(_head); } + iterator end() { return iterator(_tail); } + +private: + Statement::pointer _head; + Statement::pointer _tail; + std::size_t _size = 0; +}; + +} /* namespace samb */ + +#endif /* SRC_DIAGRAM_SCOPE_HPP_ */ -- cgit v1.2.1