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 /include/diagram/scope.hpp | |
parent | Add mainwindow.ui (diff) | |
download | OrbitingYeti-62bd9aa4da85ef87c4d9a9bb7911f8a4e0ac9986.tar.gz OrbitingYeti-62bd9aa4da85ef87c4d9a9bb7911f8a4e0ac9986.zip |
Moved to QtCreator project with QMake
Diffstat (limited to 'include/diagram/scope.hpp')
-rw-r--r-- | include/diagram/scope.hpp | 59 |
1 files changed, 59 insertions, 0 deletions
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_ */ |