aboutsummaryrefslogtreecommitdiffstats
path: root/src/diagram/statement.cpp
blob: 7f1109b42d78ebe8fbed1e2202ee82275664ffe3 (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
#include "diagram/statement.h"

#include "diagram/branch.h"
#include "diagram/iterator.h"
#include "diagram/scope.h"

#include "debugtools.h"

using namespace samb;

/* Statement */

template<class... Args>
static Statement::pointer make(Statement::Type t, Args&& ...args)
{
    Statement::pointer stat;

    switch (t) {
    case Statement::Type::PROCESS:
        stat = new Statement(t, args...);
        break;

    case Statement::Type::DECISION:
    case Statement::Type::PARALLEL:
    case Statement::Type::SWITCH:
        stat = new Branch(t, args...);
        break;

    case Statement::Type::WHILE:
    case Statement::Type::UNTIL:
        stat = new Iterator(t, args...);
        break;

    case Statement::Type::SCOPE:
        stat = new Scope(t, args...);
        break;

    default:
        debug_err("invalid type");
        break;
    }

    return stat;
}

Statement::Statement(Type t, const QString &text) :
    type(t), _text(text), _next(nullptr)
{

}

Statement::Statement(Type t, const QString &text, Statement::pointer p) :
    type(t), _text(text), _next(p)
{

}

Statement::~Statement()
{

}

bool Statement::operator==(const Statement &other) const {
    // comparison by pointers
    return (this == &other);
}