| 382 | | def writeGetPort(self,output,c): |
| 383 | | """ This function writes the getPort functionality to the component cpp file""" |
| 384 | | inCount = 0; outCount=0; |
| 385 | | flag = True |
| 386 | | for x in c.ports: |
| 387 | | if x.type == "Provides": |
| 388 | | if flag: |
| 389 | | ts = " "*4 + 'if (strcmp(_id,"' + x.name + '") == 0) {\n' |
| 390 | | else: |
| 391 | | ts = " "*4 + 'else if (strcmp(_id,"' + x.name + '") == 0) {\n' |
| 392 | | output.write(ts) |
| 393 | | # ts = " "*8 + "return inPort" + str(inCount) + "_var;\n" |
| 394 | | ts = " "*8 + "return " + x.interface.nameSpace + "::" + x.interface.name |
| 395 | | ts += "::_duplicate(inPort" + str(inCount) + "_var);\n" |
| 396 | | ts += " "*4 + "}\n" |
| 397 | | output.write(ts) |
| 398 | | inCount += 1 |
| 399 | | ts = "\n"; output.write(ts) |
| 400 | | for x in c.ports: |
| 401 | | if x.type == "Uses": |
| 402 | | if flag: |
| 403 | | ts = " "*4 + 'if (strcmp(_id,"' + x.name + '") == 0) {\n' |
| 404 | | else: |
| 405 | | ts = " "*4 + 'else if (strcmp(_id,"' + x.name + '") == 0) {\n' |
| 406 | | output.write(ts) |
| 407 | | ts = " "*8 + "outPort" + str(outCount) + "_active = true;\n" |
| 408 | | ts += " "*8 + "return CF::Port::_duplicate(outPort" + str(outCount) + "_var);\n" |
| 409 | | ts += " "*4 + "}\n" |
| 410 | | output.write(ts) |
| 411 | | outCount += 1 |
| 412 | | ts = "\n"; output.write(ts) |
| 413 | | ts = " "*4 + 'return NULL;\n'; output.write(ts) |