I am writing a cross-platform (OS X and Windows) desktop application in C++11. I
ID: 655482 • Letter: I
Question
I am writing a cross-platform (OS X and Windows) desktop application in C++11. I intend to use the same C++11 core on both platforms, utilizing native frameworks for the UI (Cocoa and Objective-C on OS X and WPF and C# on Windows) as I believe the best UX experience is a native one.
Currently the application runs as a console app on both platforms. The application performs some CPU-intensive work and provides callbacks for progress reporting and, when complete, instantiates a collection of Items (std::vector<std::unique_ptr<Item>>) representing the results of the processing.
My goal is for the C++11 library to act as a model for the UI in a manner compatible with the MVC and MVVM patterns.
The UI must:
Allow the user to choose a file to process (open a file dialog and send the file path to the C++ library)
Display progress (handle callbacks from the C++ library to update a progress bar)
Display the results in a WPF form (access the Item class and display information it provides)
I've looked at WinRT and it seems there isn't a lot of information out there for use in desktop applications. I'm also not fond of the idea of creating the UI itself in C++. My goal is to get data in and out of the C++ app and use C# to handle the UI as I believe that's a more efficient way of working with WPF.
I'm aware of P/Invoke but my understanding is that it only works with a C interface. Creating such an interface around the C++11 seems cumbersome.
I'm also aware of C++/CLI but I'm not sure if that will meet my needs or if it is compatible with C++11.
I took a look at CppSharp but it seems to be a work-in-progress and I doubt I'd know how to work around any issues that may arise.
I have a lot of experience with C++ and a little with C# but I'm not sure if I'm missing better options or which of the above is a sound approach.
Explanation / Answer
SWIG can generate C# wrappers for C++ code. I have no experience using it for this, so I don't know how well it works.
I believe the current release of SWIG (version 2.x) has at least some C++11 support, but you may need to use the development version for full support.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.