4 #include "DefaultGuidance.h"
10 /* This class tells the analysis stuff */
12 1. Source for atoms if the set is too small - can be another set or function call (assumed to be no set)
13 2. Source for atoms if relation requires atom of this set - can be another set or function call (assumed to be no set)
14 3. Removal from set - where to insert objects from this set
15 4. Insertion into set - which subset to put objects in */
17 DefGuidance::DefGuidance(model *m) {
21 Source DefGuidance::sourceforsetsize(char *set) {
22 if (equivalentstrings(set,"TERRAINTYPES"))
23 return Source(copystr("water"));
24 if (equivalentstrings(set,"STILE"))
25 return Source(copystr("STILE"));
26 return Source(&allocatebytes);
29 Source DefGuidance::sourceforrelation(char *set) {
30 if (equivalentstrings(set,"TERRAINTYPES"))
31 return Source(copystr("water"));
32 if (equivalentstrings(set,"STILE"))
33 return Source(copystr("STILE"));
34 DomainRelation *dr=globalmodel->getdomainrelation();
35 DomainSet *ds=dr->getset(set);
36 if (equivalentstrings(ds->getelementtype(),"int"))
37 return Source(copystr("int"));
38 return Source(&allocatebytes);
41 char * DefGuidance::removefromset(char * set) {
42 DomainRelation *dr=globalmodel->getdomainrelation();
43 DomainSet *ds=dr->getset(set);
44 DomainSet *ss=dr->getsuperset(ds);
45 while(ss!=NULL&&ss->gettype()==DOMAINSET_PARTITION) {
46 for(int i=0;i<ss->getnumsubsets();i++) {
47 char *name=ss->getsubset(i);
48 if (!equivalentstrings(ds->getname(),name)&&
49 !equivalentstrings(ds->getname(),name)) {
52 while(ss->gettype()==DOMAINSET_PARTITION) {
53 char *name=ss->getsubset(0);
60 ss=dr->getsuperset(ss);
68 char * DefGuidance::insertiontoset(char *set) {
69 DomainRelation *dr=globalmodel->getdomainrelation();
70 DomainSet *ds=dr->getset(set);
71 while (ds->gettype()==DOMAINSET_PARTITION) {
72 ds=dr->getset(ds->getsubset(0));
73 /* have to look for subset; */
78 Element * allocatebytes(structure * st, model *m) {
79 int size=st->getsize(m->getbitreader(),m,m->gethashtable());
80 Element * e=new Element(new char[size],st);