473,394 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

From native to managed

I'm working on a project where all the current code is written in
standard compliant C++ with no dependencies on any external libraries
except the standard library. The application is used to perform
simulations of thermal radiation and is highly performance sensitive
and as such we have no plans to rewrite it in managed C++. However we
want to add a graphical user interface to it and we are looking at
using the .Net framework to do so, probably using managed DirectX to
visualize the 3D models used in the simulations.

We have no prior experience with managed C++ so we are wondering what
would be the best approach to this, should we start a new project and
integrate our existing code together with managed code for the GUI and
compile some parts native and other managed. Or would it perhaps be
better to create a DLL/LIB of the existing code and make calls to it
from the GUI?

We don't expect a lot of interaction between the current code and the
GUI, mostly passing some values (ints, doubles), a list of pointers to
structs describing the model (std::vector<Cell*>) and perhaps perform
some callbacks for status/progress notifications.

All advice welcome, and if you happen to know of any good articles on
the subject please tell.

--
Erik Wikström

Feb 19 '07 #1
2 1770

I'm working on a project where all the current code is written in
standard compliant C++ with no dependencies on any external libraries
except the standard library. The application is used to perform
simulations of thermal radiation and is highly performance sensitive
and as such we have no plans to rewrite it in managed C++. However we
want to add a graphical user interface to it and we are looking at
using the .Net framework to do so, probably using managed DirectX to
visualize the 3D models used in the simulations.

We have no prior experience with managed C++ so we are wondering what
would be the best approach to this, should we start a new project and
integrate our existing code together with managed code for the GUI and
compile some parts native and other managed. Or would it perhaps be
better to create a DLL/LIB of the existing code and make calls to it
from the GUI?

We don't expect a lot of interaction between the current code and the
GUI, mostly passing some values (ints, doubles), a list of pointers to
structs describing the model (std::vector<Cell*>) and perhaps perform
some callbacks for status/progress notifications.
================================================== ======

Hi,

There are several options. however, for the sake of flexibility and
maintainability, I would choose one of the following 2 approaches:
- leave the code as it is (unmanaged code) and add a set of native classes
that will be compiled with /clr. create a set of WinForms classes that
implement whatever you want for the GUI and access that through that set of
classes.
By doing this you have an abstraction layer between your GUI and your app
itself. Should you later decide to use OpenGL or something else, you will
only have to change the UI classes implementation.
- refactor the code to be a DLL native project. Then create a winforms
application that calls into your DLL. this allows you to distribute and
update the algorithms as a separate unit, should you ever want to.

The key thing here is that you mentioned that you have standards compliant
C++ code, using the STL.
Currently there is no way to make C# or VB work with STL classes. That means
that you have to use C++/CLI for your GUI part.

That is no drama, but I tell you this so that you don't turn your project
into a DLL with the intention to invoke it in a C# application.
It wouldn't work without abandoning the STL.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Feb 19 '07 #2
The key thing here is that you mentioned that you have standards compliant
C++ code, using the STL.
Currently there is no way to make C# or VB work with STL classes. That
means that you have to use C++/CLI for your GUI part.

That is no drama, but I tell you this so that you don't turn your project
into a DLL with the intention to invoke it in a C# application.
It wouldn't work without abandoning the STL.
Well, you wouldn't have to abandon the STL or rewrite existing code, but you
would need to provide conversion functions to create .NET
System.Collections.(Generic.)List objects from each vector in order for C#
to be able to access them. That isn't too hard, and creating a template
implementation of IList<that proxies all access to a stl::vector for any
type wouldn't be difficult.
>
--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"

Feb 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tim Menninger | last post by:
Just started working on this and have not found any real good resources out there. We have a lot of native C++ Dll code that we use for our app. We want to share the code so that C# ASP.net code...
5
by: Bern McCarty | last post by:
I have a DLL written in C++ (it's really C code that was adjusted to compile OK as C++) that I compile successfully into IL with the /CLR switch of Visual C 7.1. I use the resultant library...
3
by: Adam | last post by:
I can't seem to find one spot on the net that specifies exactly what I need to do. Situation: Native dll needs to hold a static reference to a managed class in .net 2.0 (whidbey) which needs to...
13
by: bonk | last post by:
Hello, I am trying to create a dll that internally uses managed types but exposes a plain unmanaged interface. All the managed stuff shall be "wrapped out of sight". So that I would be able to...
9
by: Herby | last post by:
Is possible to have a managed method within a Native(un-managed) class within a \clr project? E.g. class myClass { public: #pragma managed void myMethod(void);
3
by: Lonewolf | last post by:
Hi all, I'm having difficulties passing data back to managed class from my native class when the data is generated from within a native thread in the native class itself. I will give the following...
1
by: Scott McFadden | last post by:
What is the proper way to pass pointers by reference from managed c++ calls to native c++ calls? In managed C++, I have a pointer to an array of structures, that I pass to a native c++ method by...
14
by: John | last post by:
My friend told me that his company will migrate the VC++ win32 applications to C++ .NET windows applications. I don't understand why since currently Microsoft only supports .NET on windows...
2
by: Haroon_Saeed | last post by:
Hey, I wrote a managed c++ class library in viusal studio 2005. This managed c++ dll calls native C++ methods of an SDK. When I referenced this managed c++ library in a console applciation...
5
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I have a class that is writen in unmanaged pure native C++. This class files (h and cpp) are inserted to a managed C++ (VC++ 2005, C++/CLI) DLL compoenet. This DLL compoenet is used in a C#...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.