VC++, classes and DLLs
-
Relative C++ and especially VC++ and working with Windows newbie (most previous experience is embedded). Here's the scenario: Here's what I want: one class called MonitorClass, and this class should instantiate a bunch of specific montitors underneat underneath it.... monitor1, monitor2, monitor3, etc..... The "system" will start up the Monitor class which runs in a loop all the time monitoring each specific monitor underneath. We also have seperate tests that will come into existence that may need to monitor some of the same things....so these tests should go through the MonitorClass to get a Sample() from any specific monitor. Since we want all to go through the same guy...I'm thinking we want MonitorClass in a DLL (I've never played with DLLs much) so that it is in memory only one time and all go through him. Can I make a DLL that is essentially a class ? Or must it be nothing more than a collection of functions? Or...can you understand the problem enough to give a better solution?
There are only 10 types of people in this world....those that understand binary, and those that do not.
-
Relative C++ and especially VC++ and working with Windows newbie (most previous experience is embedded). Here's the scenario: Here's what I want: one class called MonitorClass, and this class should instantiate a bunch of specific montitors underneat underneath it.... monitor1, monitor2, monitor3, etc..... The "system" will start up the Monitor class which runs in a loop all the time monitoring each specific monitor underneath. We also have seperate tests that will come into existence that may need to monitor some of the same things....so these tests should go through the MonitorClass to get a Sample() from any specific monitor. Since we want all to go through the same guy...I'm thinking we want MonitorClass in a DLL (I've never played with DLLs much) so that it is in memory only one time and all go through him. Can I make a DLL that is essentially a class ? Or must it be nothing more than a collection of functions? Or...can you understand the problem enough to give a better solution?
There are only 10 types of people in this world....those that understand binary, and those that do not.
What are you going to do with the results of the sampling/monitoring? If it is just going to be logged somewhere (file/db), and you always need this running, you may want to consider developing this as a service. onwards and upwards...
-
Relative C++ and especially VC++ and working with Windows newbie (most previous experience is embedded). Here's the scenario: Here's what I want: one class called MonitorClass, and this class should instantiate a bunch of specific montitors underneat underneath it.... monitor1, monitor2, monitor3, etc..... The "system" will start up the Monitor class which runs in a loop all the time monitoring each specific monitor underneath. We also have seperate tests that will come into existence that may need to monitor some of the same things....so these tests should go through the MonitorClass to get a Sample() from any specific monitor. Since we want all to go through the same guy...I'm thinking we want MonitorClass in a DLL (I've never played with DLLs much) so that it is in memory only one time and all go through him. Can I make a DLL that is essentially a class ? Or must it be nothing more than a collection of functions? Or...can you understand the problem enough to give a better solution?
There are only 10 types of people in this world....those that understand binary, and those that do not.
KingTermite wrote: Can I make a DLL that is essentially a class ? Or must it be nothing more than a collection of functions? The DLL can be a collection of exported functions, or it can be a collection of exported classes. From what you describe, however, I see no reason why you need a DLL. Unless the code needs to be shared between two or more applications, you'd be fine putting it all in one EXE.
-
Relative C++ and especially VC++ and working with Windows newbie (most previous experience is embedded). Here's the scenario: Here's what I want: one class called MonitorClass, and this class should instantiate a bunch of specific montitors underneat underneath it.... monitor1, monitor2, monitor3, etc..... The "system" will start up the Monitor class which runs in a loop all the time monitoring each specific monitor underneath. We also have seperate tests that will come into existence that may need to monitor some of the same things....so these tests should go through the MonitorClass to get a Sample() from any specific monitor. Since we want all to go through the same guy...I'm thinking we want MonitorClass in a DLL (I've never played with DLLs much) so that it is in memory only one time and all go through him. Can I make a DLL that is essentially a class ? Or must it be nothing more than a collection of functions? Or...can you understand the problem enough to give a better solution?
There are only 10 types of people in this world....those that understand binary, and those that do not.
Simple answer is "Yes, you can make a DLL export a class". It will tie you into only using one compiler with that DLL, but this isn't a big restriction most of the time. You'll want to look up __declspec(export) / __declspec(import) in the MSDN library. But each instance (EXE / DLL) using your DLL would have a fresh "copy" of the DLL, so you would get lots of monitors. You can do tricks to make them each refer to a single one, but that gets a bit too deep. This sounds like a good project for a COM object. This makes a singleton easier to implement (look on this site for examples), and means you could use the Monitor from VC++, VB etc. I would also think about Event Sinks to inform interested programs of changes in the real world stuff you are monitoring. If you have to poll the real world to check on a change, try creating a separate thread which wakes up at regular intervals briefly. Good luck, as this is a non-trivial learning curve... Your experience is the opposite of mine. I've been playing with windows for years, and only recently had to attack an Arm board... Iain.
-
KingTermite wrote: Can I make a DLL that is essentially a class ? Or must it be nothing more than a collection of functions? The DLL can be a collection of exported functions, or it can be a collection of exported classes. From what you describe, however, I see no reason why you need a DLL. Unless the code needs to be shared between two or more applications, you'd be fine putting it all in one EXE.
Yes, it was going to be shared by more than one exe. We talked at more length with the designer of some other code (drivers) being used which was part of the reason we thought we needed it in a seperate DLL anyway. It turns out the restrictions were not as deep as we thought and we can stick with the static libraries we already have for the monitors. Thanks for the input all, regardless.
There are only 10 types of people in this world....those that understand binary, and those that do not.