Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. VC++, classes and DLLs

VC++, classes and DLLs

Scheduled Pinned Locked Moved C / C++ / MFC
c++hardwareperformancehelpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KingTermite
    wrote on last edited by
    #1

    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.

    B D I 3 Replies Last reply
    0
    • K KingTermite

      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.

      B Offline
      B Offline
      basementman
      wrote on last edited by
      #2

      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...

      1 Reply Last reply
      0
      • K KingTermite

        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.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        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.

        K 1 Reply Last reply
        0
        • K KingTermite

          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.

          I Offline
          I Offline
          Iain Clarke Warrior Programmer
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • D David Crow

            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.

            K Offline
            K Offline
            KingTermite
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups