00001 /* 00002 * TAOStdProtocols.h 00003 * 00004 * Created on: Dec 29, 2013 00005 * Author: dan 00006 */ 00007 00008 #ifndef TAOSTDPROTOCOLS_H_ 00009 #define TAOSTDPROTOCOLS_H_ 00010 00011 #include "TAO.h" 00012 00013 namespace decision_making{ 00014 00015 00016 class NextFirstReady:public decision_making::ProtocolNext{ 00017 public: 00018 NextFirstReady(int& res, decision_making::CallContext* call_context, decision_making::EventQueue* events):ProtocolNext(res, call_context, events){} 00019 bool decide(){ 00020 //cout<<"[decide for next of "<<call_context->str()<<" ]"; 00021 for(size_t i=0;i<options.size();i++){ 00022 if(options[i].isReady){ 00023 //cout<<"[ set next state = "<<options[i].id <<": "<<options[i].name<<"]"<<endl; 00024 result = options[i].id; 00025 return true; 00026 } 00027 } 00028 return false; 00029 } 00030 }; 00031 00032 class AllocFirstReady:public decision_making::ProtocolAllocation{ 00033 public: 00034 AllocFirstReady(int& res, decision_making::CallContext* call_context, decision_making::EventQueue* events):ProtocolAllocation(res, call_context, events){} 00035 bool decide(){ 00036 //cout<<"[decide for next of "<<call_context->str()<<" ]"; 00037 for(size_t i=0;i<options.size();i++){ 00038 if(options[i].isReady){ 00039 //cout<<"[ set allocation state = "<<options[i].id <<": "<<options[i].name<<"]"<<endl; 00040 result = options[i].id; 00041 return true; 00042 } 00043 } 00044 return false; 00045 } 00046 }; 00047 00048 00049 } 00050 00051 00052 #endif /* TAOSTDPROTOCOLS_H_ */