Expr min(Expr a, Expr b) { //assert(a.type() == b.type() && "Arguments to min must have the same type"); matchTypes(&a, &b); Expr e(makeMin(a.node(), b.node()), a.type()); e.child(a); e.child(b); return e; }
Expr operator==(Expr a, Expr b) { //assert(a.type() == b.type() && "Arguments to == must have the same type"); matchTypes(&a, &b); Expr e(makeEQ(a.node(), b.node()), Int(1)); e.child(a); e.child(b); return e; }
Expr select(Expr cond, Expr thenCase, Expr elseCase) { //assert(thenCase.type() == elseCase.type() && "then case must have same type as else case in select"); //assert(cond.type() == Int(1) && "condition must have type bool in select"); matchTypes(&thenCase, &elseCase); cond = cast(Int(1), cond); Expr e(makeSelect(cond.node(), thenCase.node(), elseCase.node()), thenCase.type()); e.child(cond); e.child(thenCase); e.child(elseCase); return e; }
bool OSCMessage::matches(const char* addressPattern, const char* typeTag) const { return valid() && !strcmp(_address.asString(), addressPattern) && matchTypes(typeTag); }
void join1(char target[800],int threshold) { Result.clear(); RoadList.clear(); AnswerList.clear(); Result.reserve(10000); RoadList.reserve(100000); AnswerList.reserve(10000); int len=0; readTypes(target,bmType,page_no_Type,page_size); if(len==Result.size()) { printf("Didn`t Find Target1!\n"); return; } len=Result.size(); while(Result.empty()==0) { Concept *c=Result.front(); Result.erase(Result.begin()); RoadList.push_back(new Road(c,c->father,1)); } for(int i=2;i<threshold;i++) { readSubClassOf(target,bmSubClassOf,page_no_SubClassOf,page_size,threshold); while(RoadListTemp.empty()==0) { Road *r=RoadListTemp.front(); RoadListTemp.erase(RoadListTemp.begin()); RoadList.push_back(new Road(r->start,r->end,r->length)); } //("%d\n",i); } sort(RoadList.begin(),RoadList.end(),ResultSort); page_no_Type=0; matchTypes(target,bmType,page_no_Type,page_size); sort(AnswerList.begin(),AnswerList.end(),AnswerSort); for(vector<Answer*>::iterator Iter=AnswerList.begin();Iter!=AnswerList.end()-1;Iter++) if(strcmp((*Iter)->name,target)==0||strcmp((*Iter)->name,(*(Iter+1))->name)==0) { Iter=AnswerList.erase(Iter); Iter--; } char filename[100]; memset(filename,0,sizeof(filename)); strcpy(filename,"Schema Integration of "); strcat(filename,target); strcat(filename," by Join Algorithm 1 at Threshold of "); char thre[5]; memset(thre,0,sizeof(thre)); _itoa(threshold,thre,10); strcat(filename,thre); strcat(filename,".txt"); FILE *IntegrationOut=fopen(filename,"w"); int SchemaCount=0; for(vector<Answer*>::iterator Iter=AnswerList.begin();Iter!=AnswerList.end();Iter++) { fprintf(IntegrationOut,"%s\t%d\n",(*Iter)->name,(*Iter)->length); SchemaCount++; } fprintf(IntegrationOut,"Integrated Schema Amount:%d\n",SchemaCount); printf("Integrated Schema Amount:%d\n",SchemaCount); fclose(IntegrationOut); }
void OscController::update(ofEventArgs &args){ // map mode if(bMapModeEnabled){ while(oscIn.hasWaitingMessages()){ address = ""; ofxOscMessage message; oscIn.getNextMessage(&message); address = message.getAddress(); // link if(selected != ""){ //cout << "message type is " << message.getArgType(0) << endl; // check if param and osc types match if( matchTypes(selected, message) ){ for(map<string,string>::iterator it=addressToName.begin(); it!=addressToName.end(); ++it){ // if the selected parameter is linked to an address if(selected == it->second){ // erase the address linked to the selected parameter addressToName.erase(it); //stop searching break; } } // create a link between the address and the parameter // this will overide the value if the address aready exists addressToName[address] = selected; } else{ cout << "[TYPE MISMATCH] " << selected; cout << " <-> " << address << endl; } } } } // play mode else{ while(oscIn.hasWaitingMessages()){ ofxOscMessage m; oscIn.getNextMessage(&m); address = m.getAddress(); // if address is linked to a param... if(addressToName.find(address) != addressToName.end()){ // test: echo the message // note that only messages mapped to a control are forwarded // for (int i = 0; i < oscOut.size(); i++) { // oscOut[i]->sendMessage(m); // } // use this to record incomming messages with vezer //senderVezer.sendMessage(m); string paramName = addressToName[address]; ofAbstractParameter& parameter = controls[paramName]->getParameter(); if(m.getNumArgs() == 3){ if(m.getArgType(0) == OFXOSC_TYPE_INT32){ parameter.cast<ofColor>() = ofColor(m.getArgAsInt32(0), m.getArgAsInt32(1), m.getArgAsInt32(2)); } else if(m.getArgType(0) == OFXOSC_TYPE_FLOAT){ parameter.cast<ofFloatColor>() = ofFloatColor(m.getArgAsFloat(0), m.getArgAsFloat(1), m.getArgAsFloat(2)); } } else if (m.getNumArgs() == 1){ if(m.getArgType(0) == OFXOSC_TYPE_INT32){ parameter.cast<int>() = m.getArgAsInt32(0); } else if(m.getArgType(0) == OFXOSC_TYPE_FLOAT){ //parameter.cast<float>() = m.getArgAsFloat(0); //////////////////////////////////////////////////////////////// // testing: float value = m.getArgAsFloat(0); if(parameter.type() == typeid(ofParameter<float>).name()){ ofParameter<float> & p = parameter.cast<float>(); p = ofMap(value, 0.0, 1.0, p.getMin(), p.getMax()); } // float to int else if(parameter.type() == typeid(ofParameter<int>).name()){ ofParameter<int> & p = parameter.cast<int>(); p = ofMap(value, 0.0, 1.0, p.getMin(), p.getMax()); } // float to bool (0.0 = false, 1.0 = true) else if(parameter.type() == typeid(ofParameter<bool>).name()){ parameter.cast<bool>() = value; } //////////////////////////////////////////////////////////////// } else if(m.getArgType(0) == OFXOSC_TYPE_STRING){ parameter.cast<string>() = m.getArgAsString(0); } } else{ cout << "unknown argument type!" << endl; } } } } }