diff options
author | Nao Pross <naopross@thearcway.org> | 2017-11-28 15:05:02 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2017-11-28 15:05:02 +0100 |
commit | 12e86e71ca36a58d7e2ed64f0454b65ed6f7eb56 (patch) | |
tree | 466f7d2756b0619921e2d9d061862c8443649ed3 /src/diagram/Scope.hpp | |
parent | Update header ifdefs to match and clean up comments (diff) | |
download | OrbitingYeti-12e86e71ca36a58d7e2ed64f0454b65ed6f7eb56.tar.gz OrbitingYeti-12e86e71ca36a58d7e2ed64f0454b65ed6f7eb56.zip |
New data structure for Structogram and Statements
Diffstat (limited to 'src/diagram/Scope.hpp')
-rw-r--r-- | src/diagram/Scope.hpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/diagram/Scope.hpp b/src/diagram/Scope.hpp new file mode 100644 index 0000000..b1fe2f0 --- /dev/null +++ b/src/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: + iterator(pointer statement); + ~iterator(); + + iterator& operator++(); + iterator& operator++(int); + + Statement& operator*() const; + Statement::pointer operator->() const; + + private: + Statement::pointer m_current; + }; + + 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_ */ |