When OMneT++ Goes Python
When OMneT++ Goes Python
András Varga
[email protected]
OMNeT++ Core Team
# sink.py
from omnetpp.runtime import *
class Sink(omnetpp.cSimpleModule):
def handleMessage(self, msg):
...
import cppyy
cppyy.include("iostream")
cppyy.cppdef("""class A { public: void sayHello() { std::cout << "Hello" << std::endl; } };""")
A = cppyy.gbl.A
a = A()
a.sayHello() # prints “Hello”
• Foundations:
– Cling, the interactive C++ interpreter from CERN
– Cling itself builds on Clang and LLVM
– (at least this is what they want you to believe, but actually it relies on magic)
17
OMNeT++ Community Virtual Summit – November 2-3, 2022