~tapaal-ltl/verifypn/rule-D-fix

« back to all changes in this revision

Viewing changes to PetriEngine/Reachability/CoverabilityTreeNode.h

  • Committer: Jonas Finnemann Jensen
  • Date: 2011-09-15 13:30:00 UTC
  • Revision ID: jopsen@gmail.com-20110915133000-wnywm1odf82emiuw
Import of sources from github

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* PeTe - Petri Engine exTremE
 
2
 * Copyright (C) 2011  Jonas Finnemann Jensen <jopsen@gmail.com>,
 
3
 *                     Thomas Søndersø Nielsen <primogens@gmail.com>,
 
4
 *                     Lars Kærlund Østergaard <larsko@gmail.com>,
 
5
 * 
 
6
 * This program is free software: you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation, either version 3 of the License, or
 
9
 * (at your option) any later version.
 
10
 * 
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 * 
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
#ifndef COVERABILITYTREENODE_H
 
20
#define COVERABILITYTREENODE_H
 
21
 
 
22
#include <vector>
 
23
 
 
24
#include "../PetriNet.h"
 
25
namespace PetriEngine { namespace Reachability {
 
26
 
 
27
/** Represents a node in the coverability tree of a Petri-net */
 
28
class CoverabilityTreeNode
 
29
{
 
30
public:
 
31
        /** Constructs a new node with its parent and a heap-allocated marking and variable assignment.
 
32
          * This class takes ownership of marking and variable assignment*/
 
33
        CoverabilityTreeNode(CoverabilityTreeNode* parent, int transition, MarkVal* marking, VarVal* assignments);
 
34
        /** Constructs a root node, and a heap-allocated marking and variable assignment.
 
35
          * This class takes ownership of the marking and variable assignment. */
 
36
        CoverabilityTreeNode(MarkVal* marking, VarVal* assignments);
 
37
 
 
38
        /** Destroy the CoverabilityTreeNode */
 
39
        ~CoverabilityTreeNode(){
 
40
                _parent = NULL;
 
41
                if(_marking)
 
42
                        delete _marking;
 
43
                _marking = NULL;
 
44
                if(_assignments)
 
45
                        delete _assignments;
 
46
                _assignments = NULL;
 
47
        }
 
48
 
 
49
        /** Checks if the node is new in the coverability tree */
 
50
        bool findDuplicate(const PetriNet& net);
 
51
 
 
52
        /** Getter for marking */
 
53
        MarkVal* marking() const{
 
54
                return _marking;
 
55
        }
 
56
        /** Getter for the transition */
 
57
         int transition() const{
 
58
                return _transition;
 
59
        }
 
60
 
 
61
private:
 
62
        /** The parent node, which is null for the root node */
 
63
        CoverabilityTreeNode* _parent;
 
64
        /** The transition being fired */
 
65
        int _transition;
 
66
        /** The current marking */
 
67
        MarkVal* _marking;
 
68
        /** The current variable assignments */
 
69
        VarVal* _assignments;
 
70
};
 
71
} // "Reachability"
 
72
} // "PetriEngine"
 
73
#endif // COVERABILITYTREENODE_H