blob: 7b036f0b7b582a842c68fbf29f5697ec5f0ce435 (
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
63
64
65
66
67
68
69
70
71
|
/*
* Structogram.h
*
* Created on: Nov 14, 2017
* Author: naopross
*/
#ifndef SRC_DIAGRAM_STRUCTOGRAM_H_
#define SRC_DIAGRAM_STRUCTOGRAM_H_
#include <iostream>
#include <list>
#include "Statement.hpp"
namespace samb {
/* A Structogram is a Nassi-Schneiderman diagram, in this implementation it is
* simply and iterable object that holds statements.
*
* The first statement inside a structogram (m_head) is a SCOPE
* statement that holds the entire program inside it.
*/
class Structogram {
public:
/* forward only iterator */
class iterator {
public:
iterator(Statement::pointer first);
~iterator();
iterator& operator++();
iterator& operator++(int);
bool operator==(const iterator& other) const;
bool operator!=(const iterator& other) const;
Statement& operator*() const;
Statement::pointer operator->() const;
private:
Statement::pointer m_current;
};
Structogram(std::string title);
virtual ~Structogram();
std::size_t size() const;
// cannot be implemented because iter is forward only
// iterator insert(iterator it, Statement::pointer statement);
// iterator erase(iterator it);
iterator insert_after(iterator it, Statement::pointer statement);
iterator erase_after(iterator it);
/* iterator */
iterator begin() const;
const iterator end() const;
const Statement& operator[](const Statement& it) = delete;
private:
std::size_t m_size;
std::string m_title;
Statement::pointer m_head;
Statement::pointer m_tail;
};
} /* namespace structograms */
#endif /* SRC_DIAGRAM_STRUCTOGRAM_H_ */
|