~ubuntu-branches/ubuntu/intrepid/tcm/intrepid

« back to all changes in this revision

Viewing changes to src/dg/diagramchecks.h

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//------------------------------------------------------------------------------
 
2
// 
 
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
 
4
// (c) copyright 1997, Vrije Universiteit Amsterdam.
 
5
// Author: Frank Dehne (frank@cs.vu.nl).
 
6
//
 
7
// TCM is free software; you can redistribute it and/or modify
 
8
// it under the terms of the GNU General Public License as published by
 
9
// the Free Software Foundation; either version 2 of the License, or
 
10
// (at your option) any later version.
 
11
//
 
12
// TCM is distributed in the hope that it will be useful,
 
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
// GNU General Public License for more details.
 
16
//
 
17
// You should have received a copy of the GNU General Public License
 
18
// along with TCM; if not, write to the Free Software
 
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
20
// 02111-1307, USA.
 
21
//-----------------------------------------------------------------------------
 
22
#ifndef _DIAGRAMCHECKS_H
 
23
#define _DIAGRAMCHECKS_H
 
24
 
 
25
#include "bool.h"
 
26
#include <limits.h>
 
27
class Graph;
 
28
class Diagram;
 
29
class string;
 
30
 
 
31
/// implements generic checks for soft constraints on diagrams.
 
32
class DiagramChecks {
 
33
/*@Doc: {\large {\bf scope:} diagram} */
 
34
public:
 
35
        ///
 
36
        DiagramChecks(Diagram *d, Graph *g);
 
37
 
 
38
        // Error messages are appended to chkbuf. The functions return the
 
39
        // number of errors found.
 
40
 
 
41
        /// diagram should have count nodes of nodeType.
 
42
        unsigned CheckNodeCount(unsigned count, int nodeType, string &chkbuf);
 
43
 
 
44
        /// diagram should have min <= count <= max nodes of nodeType.
 
45
        unsigned CheckNodeCount(unsigned min, unsigned max, 
 
46
                int nodeType, string &chkbuf);
 
47
 
 
48
        /// diagram should have count edges of edgeType
 
49
        unsigned CheckEdgeCount(unsigned count, int edgeType, string &chkbuf);
 
50
 
 
51
        /// diagram should have min <= count <= max edges of edgeType.
 
52
        unsigned CheckEdgeCount(unsigned min, unsigned max, 
 
53
                int edgeType, string &chkbuf);
 
54
 
 
55
        /// check that nodes unique indexes.
 
56
        unsigned CheckDoubleIndexes(string &chkbuf);
 
57
 
 
58
        /// diagram should have no nameless nodes of nodeType
 
59
        unsigned CheckNamelessNodes(int nodeType, string &chkbuf); 
 
60
 
 
61
        /// diagram should have no nameless edges of edgeType
 
62
        unsigned CheckNamelessEdges(int edgeType, string &chkbuf); 
 
63
 
 
64
        /// diagram should have no nodes of nodeType named 'name'. 
 
65
        unsigned CheckIllegalNodeNames(int nodeType, const string *name, 
 
66
                        string &chkbuf); 
 
67
 
 
68
        /// diagram should have no edges of edgeType named 'name'.
 
69
        unsigned CheckIllegalEdgeNames(int edgeType, const string *name, 
 
70
                        string &chkbuf); 
 
71
 
 
72
        /// diagram should have no nameless edges of edgeType between types. 
 
73
        unsigned CheckNamelessEdges(
 
74
                int edgeType, int type1, int type2, string &chkbuf);
 
75
 
 
76
        /// diagram shouldn't have double nameless edges between these types. 
 
77
        unsigned CheckDoubleNamelessEdges(int edgeType, int type1, 
 
78
                int type2, string &chkbuf);
 
79
 
 
80
        /// diagram should not have multiple nodes of nodeType with same name.
 
81
        unsigned CheckDoubleNodes(int nodeType, string &chkbuf);
 
82
 
 
83
        /// nodeType nodes should be connected (index: name or index in msg)
 
84
        unsigned CheckConnected(int nodeType, bool index, string &chkbuf);
 
85
 
 
86
        /// nodeType nodes should be connected (index: name or index in msg)
 
87
        unsigned CheckConnected(int nodeType, int toNode, int min, int max, 
 
88
                bool index, string &chkbuf);
 
89
 
 
90
        /// nodes of nodeType connected by 1 parent edge and minChildren edges.
 
91
        unsigned CheckJunctionCoherence(int nodeType, int parenttype, 
 
92
                        int childtype, unsigned minChildren, string &chkbuf);
 
93
 
 
94
        /// nodes of nodeType should have min/max departing edges of edgeType.
 
95
        unsigned CheckCountEdgesFrom(int nodeType, int edgeType, unsigned min, 
 
96
                        unsigned max, bool zeroAllowed, bool index, 
 
97
                        string &chkbuf);
 
98
 
 
99
        /// nodes of nodeType are reachable from >= 1 nodes of rootType.
 
100
        unsigned CheckReachability(int rootType, int nodeType, 
 
101
                        bool index, string &chkbuf);
 
102
 
 
103
protected:
 
104
        ///
 
105
        Graph *GetGraph() const {return graph;}
 
106
        ///
 
107
        Diagram *GetDiagram() const {return diagram;}
 
108
        ///
 
109
        unsigned CheckCount(unsigned min, unsigned max, int type, 
 
110
                string &chkbuf, bool node);
 
111
        ///
 
112
        unsigned CheckIllegalNames(int type, const string *name,
 
113
                string &chkbuf, bool node);
 
114
private:
 
115
        ///
 
116
        Graph *graph;
 
117
        ///
 
118
        Diagram *diagram;
 
119
};
 
120
#endif