I have a legacy (but still internally maintained) application written in C++ which handles some hardware, interacts with databases, receives commands via serial line or socket... in short it does a non-trivial amount of work.
This application runs under Linux (ARM/Buildroot).
Now the need is to revamp the control interface adding a RESTful API.
I am exploring the possibility to do so via a Python extension.
Note I am a C++/java programmer and I'm not really proficient in Python, but I know the basics.
General idea would be:
- Start a Python interpreter as a thread in the C++ application.
- Use Flask/jinja2 (or just plain Bottle) to handle incoming RESTful requests.
- Expose a few (perhaps just one) C++ class to Python.
- Call from Python the appropriate C++ methods to perform the required actions.
I studied the official documentation (mainly pertaining plain C) and several alternatives, including:
- Boost.Python (possibly too heavy for our limited hardware)
- pybind11 (seems concerned only in extending Python, not embedding it).
- http://www.codeproject.com/Articles/11805/Embedding-Python-in-C-C-Part-I (deals only with embedding, without giving Python access to C++ classes).
Question are:
- does this make any sense?
- what is the least intrusive way (if any) to achieve this?
- which lib/framework is advised to use?
- is there some tutorial project along these lines?
I know the question is quite broad, but I hope to narrow it as soon as the first comments will point me in the right direction.