1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 2001, Universiteit Twente.
5
// Author: Rik Eshuis (eshuis@cs.utwente.nl).
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.
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.
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
21
////////////////////////////////////////////////////////////////////////////////
22
#include "inputfile.h"
23
#include "outputfile.h"
25
#include "assoclist.h"
26
#include "hypergraph.h"
27
#include "hyperedge.h"
31
HyperEdge::HyperEdge(HyperGraph *g, List<Subject *> *n1, List<Subject *> *n2): Subject(g) {
37
HyperEdge::HyperEdge(HyperGraph *g,Edge *e): Subject(g) {
38
subject1= new List<Subject *>();
39
subject1->add(e->GetSubject1());
40
subject2= new List<Subject *>();
41
subject2->add(e->GetSubject2());
45
HyperEdge::HyperEdge(HyperGraph *g): Subject(g){
46
subject1= new List <Subject *>;
47
subject2= new List <Subject *>;
51
bool HyperEdge::operator==(HyperEdge &comp){
52
// compare the configurations
53
// compare the property valuations
54
int sourcelen=subject1->count();
55
int compsourcelen=comp.subject1->count();
57
for (i=0;i<sourcelen;i++){
58
if (!comp.subject1->contains((*subject1)[i])) return False;
60
for (j=0;j<compsourcelen;j++){
61
if (!subject1->contains((*(comp.subject1))[j])) return False;
64
int targetlen=subject2->count();
65
int comptargetlen=comp.subject2->count();
67
for (i=0;i<targetlen;i++){
68
if (!comp.subject2->contains((*subject2)[i])) return False;
70
for (j=0;j<comptargetlen;j++){
71
if (!subject2->contains((*(comp.subject2))[j])) return False;
74
return (label==comp.label);
80
HyperEdge::~HyperEdge() {
86
bool HyperEdge::InGraph() const {
87
return GetHyperGraph()->HasHyperEdge((HyperEdge *)this);
91
void HyperEdge::WriteMembers(OutputFile *ofile) {
92
Subject::WriteMembers(ofile);
93
for (subject1->first();!subject1->done();subject1->next()){
94
(*ofile) << "\t{ Subject1 " << (check(subject1->cur())?
95
subject1->cur()->GetId():0) << " }\n";
97
for (subject2->first();!subject2->done();subject2->next()){
98
(*ofile) << "\t{ Subject2 " << (check(subject2->cur())?
99
subject2->cur()->GetId():0) << " }\n";
101
(*ofile) << "\t{ Label: " << label <<"\n";
106
void HyperEdge::AddSubject1(Subject *s){
110
void HyperEdge::AddSubject2(Subject *s){
116
string HyperEdge::GetLabel(){
120
void HyperEdge::SetLabel(string s){
125
string HyperEdge::GetEvent(){
128
while (i<label.length()){
129
if (label[i]=='[') return txt;
138
string HyperEdge::GetGuard(){
141
while ((i<label.length()) && (label[i]!='[')) i++;
142
if (i==label.length()) return txt;
144
while (i<label.length()){
145
txt = txt + label[i];
154
bool HyperEdge::HasEmptyEvent(){
155
return (GetEvent()=="");
161
bool HyperEdge::HasEmptyGuard(){
162
return (GetGuard()=="");