blob: 8ae7e7920aa4bb6d5d138c1425535245c96dda0c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#ifndef DIAGRAM_SCOPE_H
#define DIAGRAM_SCOPE_H
#include "diagram/statement.h"
#include <QString>
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();
bool operator==(const iterator &other) const;
bool operator!=(const iterator &other) const;
iterator& operator++();
iterator& operator++(int);
Statement& operator*() const;
Statement::pointer operator->() const;
private:
Statement::pointer _current;
};
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();
const iterator begin() const;
iterator end();
const iterator end() const;
private:
Statement::pointer _head;
Statement::pointer _tail;
std::size_t _size = 0;
};
} /* namespace samb */
#endif /* SRC_DIAGRAM_SCOPE_HPP_ */
|