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

« back to all changes in this revision

Viewing changes to src/sd/bv/adshyperedge.c

  • 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
// This file is part of Toolkit for Conceptual Modeling (TCM).
 
3
// (c) copyright 2001, Universiteit Twente.
 
4
// Author: Rik Eshuis (eshuis@cs.utwente.nl).
 
5
//
 
6
// TCM 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 2 of the License, or
 
9
// (at your option) any later version.
 
10
//
 
11
// TCM 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 TCM; if not, write to the Free Software
 
18
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
19
// 02111-1307, USA.
 
20
////////////////////////////////////////////////////////////////////////////////
 
21
#include "adshyperedge.h"
 
22
#include "adshypergraph.h"
 
23
#include "adsproperty.h"
 
24
#include "adsvariable.h"
 
25
#include "outputfile.h"
 
26
#include "adsclockconstraint.h"
 
27
//#include <stdlib.h> // for NULL only
 
28
 
 
29
 
 
30
 
 
31
     
 
32
ADSHyperEdge::ADSHyperEdge(ADSHyperGraph *a, Edge *e): HyperEdge(a,e){
 
33
  cc=NULL;
 
34
  edgelist.add(e);
 
35
  sendevent=NULL;
 
36
};
 
37
 
 
38
bool ADSHyperEdge::AddProp(Prop *p){
 
39
  for (propl.first();!propl.done();propl.next()){
 
40
    if (*propl.cur()==*p) return False;
 
41
  }
 
42
  propl.add(p);
 
43
  return True;
 
44
}
 
45
 
 
46
bool ADSHyperEdge::AddVar(ADSVar *v){
 
47
  for (varl.first();!varl.done();varl.next()){
 
48
    if (*varl.cur()==*v) return False;
 
49
  }
 
50
  varl.add(v);
 
51
  return True;
 
52
}
 
53
 
 
54
void ADSHyperEdge::GetPropList(List <Prop *> &p){
 
55
  p=propl;
 
56
}
 
57
 
 
58
void ADSHyperEdge::GetVarList(List <ADSVar *> &v){
 
59
  v=varl;
 
60
}
 
61
 
 
62
 
 
63
void ADSHyperEdge::SetClockConstraint(ClockConstraint *c){
 
64
  cc=c;
 
65
}
 
66
 
 
67
 
 
68
ClockConstraint *ADSHyperEdge::GetClockConstraint(){
 
69
  return cc;
 
70
}
 
71
 
 
72
 
 
73
bool ADSHyperEdge::hasClockConstraint(){
 
74
  return (cc!=NULL);
 
75
}
 
76
 
 
77
 
 
78
bool ADSHyperEdge::conflicts(ADSHyperEdge *he){
 
79
  return conflict.contains(he);
 
80
}
 
81
 
 
82
bool ADSHyperEdge::isconflicting(){
 
83
  return (conflict.count()>0);
 
84
}
 
85
 
 
86
void ADSHyperEdge::AddEdges(List <Subject *> l){
 
87
  for (l.first();!l.done();l.next()){
 
88
    edgelist.add(l.cur());
 
89
  }
 
90
}
 
91
 
 
92
void ADSHyperEdge::GetEdges(List <Subject *> *l){
 
93
  for (edgelist.first();!edgelist.done();edgelist.next()){
 
94
    l->add(edgelist.cur());
 
95
  }
 
96
}
 
97
 
 
98
 
 
99
string ADSHyperEdge::GetUniqueName(){
 
100
  string str="HE_"; 
 
101
  string hid=(unsigned int)GetId();
 
102
  return str+hid;
 
103
}
 
104
 
 
105
void ADSHyperEdge::WriteMembers(OutputFile *f){
 
106
  (*f) << "HYPEREDGE ID " << GetId() <<"\n";
 
107
  HyperEdge::WriteMembers(f);
 
108
  for (propl.first();!propl.done();propl.next()){ 
 
109
    (*f) << "\tPRoperty\n";
 
110
    propl.cur()->Write(f);
 
111
    (*f) << "\n";
 
112
  }
 
113
  (*f) << "Clock constraint\n";
 
114
  if (cc!=NULL) cc->Write(f);
 
115
  if (sendevent!=NULL){
 
116
    (*f) << "\tSEND EVENT:\t"; 
 
117
    sendevent->Write(f);
 
118
    (*f) << "\n";
 
119
  }
 
120
  for (inlist.first();!inlist.done();inlist.next()){ 
 
121
    (*f) << "INLIST\n\t\t";
 
122
    inlist.cur()->Write(f);
 
123
    (*f) << "\n";
 
124
  }
 
125
  for (notinlist.first();!notinlist.done();notinlist.next()){ 
 
126
    (*f) << "NOT INLIST\n\t\t";
 
127
    notinlist.cur()->Write(f);
 
128
    (*f) << "\n";
 
129
  }
 
130
  for (edgelist.first();!edgelist.done();edgelist.next()){
 
131
    (*f) << "\tedge ID:\t" << edgelist.cur()->GetId() << "\n";
 
132
  }
 
133
  (*f) << "\n";
 
134
}
 
135
 
 
136
void ADSHyperEdge::WriteScreen(){
 
137
  std::cout << "HYPEREDGE ID " << GetId() <<"\n";
 
138
 
 
139
  for (propl.first();!propl.done();propl.next()){ 
 
140
    std::cout << "\tPRoperty\n";
 
141
    propl.cur()->Write();
 
142
    std::cout << "\n";
 
143
  }
 
144
 
 
145
}
 
146
 
 
147