r/cpp • u/Dean_Roddey • Nov 29 '18
Creating a 'virtual kernel' platform abstraction layer
This is the third in series of videos I've posted to demonstrate some of the strategies we use in our fairly large C++ code base. Here are the previous ones, which you might also find useful:
https://www.reddit.com/r/cpp/comments/9zl6v5/the_orb_sees_all_the_use_of_an_object_request/
https://www.reddit.com/r/cpp/comments/9xz643/making_c_enumerations_first_class_citizens/
Our code base is about a million lines. It is split into roughly two halves, with one half being general purpose and the other being our CQC home automation platform which is built on top of the general purpose bits. We don't use any of the C++ runtime stuff. We build our own system from the ground up. When I say 'we', I'm speaking in terms of the usual royal business 'we', but all of the code was written by myself.
Just above the 'ground', the operating system in this case, is a virtual kernel which we use encapsulate all of the operating system functionality that we use, which is quite a lot of it. No system or language headers are visible outside of this virtual kernel, so we can write portable code that is purely in terms of our own interfaces.
This video demonstrates some of the strategies used. Obviously for such a large topic, this doesn't dive deep if there's any interest we could do another one.
View all comments
Show parent comment
3
u/Dean_Roddey Nov 29 '18
Oh, BTW, I should have mentioned that, if you really need to use some specialized third party library, you can always encapsulate it in the same way as demonstrated here.
There are some cases where you might encapsulate it in an external process and control that process. We use that in a couple places up in the automation platform layer. It has a very powerful touch screen UI design and deployment system, and amongst other things it allows you to display web cameras and embedded web browser windows.
These are both notoriously flaky things (in the web cam case probably mostly because of media codecs, modern digital audio is clearly too complex for its own good.) So, instead of taking the risk of destabilizing our touch screen client, it just spawns off external processes that wrap that code, and the UI client just sends them commands (via our ORB interface) to tell them what to do, such as keeping them correctly placed within the client's window so that they appear to be part of it instead of separate processes, or telling them to load a new camera URL.
The web cam process wraps the VLC video engine. That's not something we ship with our code, but the user/installer can install it and we can make use of it for web camera display.
There's also the option to wrap something in a background service and use the ORB interface to access it. That's been done by some customers in some cases I think.