31 imageFilterProtocol->
addOutputPort(
"outputImage",
"VuoImage");
32 protocols.push_back(imageFilterProtocol);
36 imageGeneratorProtocol->
addInputPort(
"width",
"VuoInteger");
37 imageGeneratorProtocol->
addInputPort(
"height",
"VuoInteger");
38 imageGeneratorProtocol->
addOutputPort(
"outputImage",
"VuoImage");
39 protocols.push_back(imageGeneratorProtocol);
42 imageTransitionProtocol->
addInputPort(
"time",
"VuoReal");
43 imageTransitionProtocol->
addInputPort(
"progress",
"VuoReal");
44 imageTransitionProtocol->
addInputPort(
"startImage",
"VuoImage");
45 imageTransitionProtocol->
addInputPort(
"endImage",
"VuoImage");
46 imageTransitionProtocol->
addOutputPort(
"outputImage",
"VuoImage");
47 protocols.push_back(imageTransitionProtocol);
150 for (vector<pair<string, string> >::iterator i = inputPortNamesAndTypes.begin(); i != inputPortNamesAndTypes.end(); ++i)
152 string currentPortName = i->first;
153 string currentPortType = i->second;
154 if (currentPortName == portName)
155 return currentPortType;
158 VUserLog(
"Error: Protocol '%s' has no input port with name '%s'.", this->name.c_str(), portName.c_str());
167 for (vector<pair<string, string> >::iterator i = outputPortNamesAndTypes.begin(); i != outputPortNamesAndTypes.end(); ++i)
169 string currentPortName = i->first;
170 string currentPortType = i->second;
171 if (currentPortName == portName)
172 return currentPortType;
175 VUserLog(
"Error: Protocol '%s' has no output port with name '%s'.", this->name.c_str(), portName.c_str());
189 __block
int charNum = 0;
190 bool (^getNextLine)(
string &linenumber) = ^(
string &linenumber){
194 char c = compositionAsString[charNum++];
205 string (^getLabel)(
string linenumber) = ^(
string linenumber){
206 string labelToken =
"label=\"";
207 string::size_type labelLocation = linenumber.find(labelToken);
208 if (labelLocation == string::npos)
211 labelLocation += labelToken.length();
213 while (labelLocation < linenumber.length() && linenumber[labelLocation] !=
'"')
214 label += linenumber[labelLocation++];
220 bool (^getNextPort)(
string &label,
string &portID) = ^(
string &label,
string &portID){
222 string portToken =
"|<";
223 string::size_type portLocation = label.find(portToken);
224 if (portLocation == string::npos)
227 portLocation += portToken.length();
228 while (portLocation < label.length() && label[portLocation] !=
'>')
229 portID += label[portLocation++];
231 label = label.substr(portLocation);
237 string (^getType)(
string linenumber,
string portID) = ^(
string linenumber,
string portID){
238 string typeToken =
"_" + portID +
"_type=\"";
239 string::size_type typeLocation = linenumber.find(typeToken);
240 if (typeLocation == string::npos)
243 typeLocation += typeToken.length();
245 while (typeLocation < linenumber.length() && linenumber[typeLocation] !=
'"')
246 type += linenumber[typeLocation++];
253 vector<pair<string,string>> publishedInputs;
254 vector<pair<string,string>> publishedOutputs;
256 while (getNextLine(linenumber))
260 bool isPublishedInputs =
false;
261 bool isPublishedOutputs =
false;
263 isPublishedInputs =
true;
265 isPublishedOutputs =
true;
267 if (!isPublishedInputs && !isPublishedOutputs)
270 string label = getLabel(linenumber);
275 while (getNextPort(label, portID))
277 if (isPublishedInputs)
278 publishedInputs.push_back({portID, getType(linenumber, portID)});
280 publishedOutputs.push_back({portID, getType(linenumber, portID)});
284 return arePublishedPortsCompliant(publishedInputs, publishedOutputs);
290bool VuoProtocol::arePublishedPortsCompliant(
const vector<pair<string, string>> &publishedInputNamesAndTypes,
295 if (std::find(publishedInputNamesAndTypes.begin(), publishedInputNamesAndTypes.end(), protocolInput) == publishedInputNamesAndTypes.end())
300 if (std::find(publishedOutputNamesAndTypes.begin(), publishedOutputNamesAndTypes.end(), protocolOutput) == publishedOutputNamesAndTypes.end())
323 const vector<pair<string, string>> &publishedOutputNamesAndTypes)
326 vector<VuoProtocol *> adheresToProtocols;
328 if (protocol->arePublishedPortsCompliant(publishedInputNamesAndTypes, publishedOutputNamesAndTypes))
329 adheresToProtocols.push_back(protocol);
330 return adheresToProtocols;
341 pair<string, string> portNameAndType = make_pair(portName, portType);
343 for (vector<pair<string, string> >::iterator i = inputPortNamesAndTypes.begin(); i != inputPortNamesAndTypes.end(); ++i)
345 string currentPortName = i->first;
346 if (currentPortName == portName)
348 VUserLog(
"Error: Protocol '%s' already had an input port with name '%s'.", this->name.c_str(), portName.c_str());
353 inputPortNamesAndTypes.push_back(portNameAndType);
364 pair<string, string> portNameAndType = make_pair(portName, portType);
366 for (vector<pair<string, string> >::iterator i = outputPortNamesAndTypes.begin(); i != outputPortNamesAndTypes.end(); ++i)
368 string currentPortName = i->first;
369 if (currentPortName == portName)
371 VUserLog(
"Error: Protocol '%s' already had an output port with name '%s'.", this->name.c_str(), portName.c_str());
376 outputPortNamesAndTypes.push_back(portNameAndType);