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. C++: pls help me to choose or suggest me a new one

C++: pls help me to choose or suggest me a new one

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelpc++comdata-structures
8 Posts 6 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.
  • S Offline
    S Offline
    Sarath C
    wrote on last edited by
    #1

    Take a minute to read. I could not shorten my problem... be patient... I have a CBaseEvent class There are other two classes have derived from CBaseEvent named CSysEvent and CGuiEvent I have created a queue of CBaseEvent pointers. This queue is being processed by an event handler class. A thread is working for this. Whenever a new event adds on the queue, this thread will process the event by calling ProcessEventFunction. which prototyped as ProcessEventFunction(CBaseEvent* pEvent) Here comes the problem. How can I identify between System Event and GUI event? These are the possibilities I have 1. Use dynamic_cast identify the pointer using dynamic cast. Then do the further processing depends on Sys event or GUI event. 2. Do the above check inside the thread itself and call the ProcessEvent function overloaded with GUI event and SysEvent depends on the result 3. Use two queues. One for sys event and another for GUI event. Run two threads for the same and call the overloaded ProcessEvent function depends on the queue. Here definitely I’ll face some problems with the order of the events received. I need to process the sys and GUI events in first come first serve manner. So this approach will have sync issues. The above are the solutions I have!!! Could you pls suggest one from this or a new one? Again sorry for borring you with a long question :) SaRath.
    "Do Next Thing..." Understanding State Pattern in C++

    R R C H L 5 Replies Last reply
    0
    • S Sarath C

      Take a minute to read. I could not shorten my problem... be patient... I have a CBaseEvent class There are other two classes have derived from CBaseEvent named CSysEvent and CGuiEvent I have created a queue of CBaseEvent pointers. This queue is being processed by an event handler class. A thread is working for this. Whenever a new event adds on the queue, this thread will process the event by calling ProcessEventFunction. which prototyped as ProcessEventFunction(CBaseEvent* pEvent) Here comes the problem. How can I identify between System Event and GUI event? These are the possibilities I have 1. Use dynamic_cast identify the pointer using dynamic cast. Then do the further processing depends on Sys event or GUI event. 2. Do the above check inside the thread itself and call the ProcessEvent function overloaded with GUI event and SysEvent depends on the result 3. Use two queues. One for sys event and another for GUI event. Run two threads for the same and call the overloaded ProcessEvent function depends on the queue. Here definitely I’ll face some problems with the order of the events received. I need to process the sys and GUI events in first come first serve manner. So this approach will have sync issues. The above are the solutions I have!!! Could you pls suggest one from this or a new one? Again sorry for borring you with a long question :) SaRath.
      "Do Next Thing..." Understanding State Pattern in C++

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      I've relied on poor man's RTTI by adding a protected member of the enum type CBaseEvent::Type to the base class. The enum is set in each base class constructor. CBaseEvent has a getType() method that returns the type of subclass. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      1 Reply Last reply
      0
      • S Sarath C

        Take a minute to read. I could not shorten my problem... be patient... I have a CBaseEvent class There are other two classes have derived from CBaseEvent named CSysEvent and CGuiEvent I have created a queue of CBaseEvent pointers. This queue is being processed by an event handler class. A thread is working for this. Whenever a new event adds on the queue, this thread will process the event by calling ProcessEventFunction. which prototyped as ProcessEventFunction(CBaseEvent* pEvent) Here comes the problem. How can I identify between System Event and GUI event? These are the possibilities I have 1. Use dynamic_cast identify the pointer using dynamic cast. Then do the further processing depends on Sys event or GUI event. 2. Do the above check inside the thread itself and call the ProcessEvent function overloaded with GUI event and SysEvent depends on the result 3. Use two queues. One for sys event and another for GUI event. Run two threads for the same and call the overloaded ProcessEvent function depends on the queue. Here definitely I’ll face some problems with the order of the events received. I need to process the sys and GUI events in first come first serve manner. So this approach will have sync issues. The above are the solutions I have!!! Could you pls suggest one from this or a new one? Again sorry for borring you with a long question :) SaRath.
        "Do Next Thing..." Understanding State Pattern in C++

        R Offline
        R Offline
        Rutger Ellen
        wrote on last edited by
        #3

        Create a ProcessEventFunction on the base class CBaseEvent that is overloaded for proper processing and invoke that function.

        1 Reply Last reply
        0
        • S Sarath C

          Take a minute to read. I could not shorten my problem... be patient... I have a CBaseEvent class There are other two classes have derived from CBaseEvent named CSysEvent and CGuiEvent I have created a queue of CBaseEvent pointers. This queue is being processed by an event handler class. A thread is working for this. Whenever a new event adds on the queue, this thread will process the event by calling ProcessEventFunction. which prototyped as ProcessEventFunction(CBaseEvent* pEvent) Here comes the problem. How can I identify between System Event and GUI event? These are the possibilities I have 1. Use dynamic_cast identify the pointer using dynamic cast. Then do the further processing depends on Sys event or GUI event. 2. Do the above check inside the thread itself and call the ProcessEvent function overloaded with GUI event and SysEvent depends on the result 3. Use two queues. One for sys event and another for GUI event. Run two threads for the same and call the overloaded ProcessEvent function depends on the queue. Here definitely I’ll face some problems with the order of the events received. I need to process the sys and GUI events in first come first serve manner. So this approach will have sync issues. The above are the solutions I have!!! Could you pls suggest one from this or a new one? Again sorry for borring you with a long question :) SaRath.
          "Do Next Thing..." Understanding State Pattern in C++

          C Offline
          C Offline
          Chris Meech
          wrote on last edited by
          #4

          I've used virtual functions for this, so that you don't have to identify the type. Chris Meech I am Canadian. [heard in a local bar] When no one was looking, every single American woman between the ages of 18 and 32 went out and got a tatoo just above their rumpus. [link[^]]

          1 Reply Last reply
          0
          • S Sarath C

            Take a minute to read. I could not shorten my problem... be patient... I have a CBaseEvent class There are other two classes have derived from CBaseEvent named CSysEvent and CGuiEvent I have created a queue of CBaseEvent pointers. This queue is being processed by an event handler class. A thread is working for this. Whenever a new event adds on the queue, this thread will process the event by calling ProcessEventFunction. which prototyped as ProcessEventFunction(CBaseEvent* pEvent) Here comes the problem. How can I identify between System Event and GUI event? These are the possibilities I have 1. Use dynamic_cast identify the pointer using dynamic cast. Then do the further processing depends on Sys event or GUI event. 2. Do the above check inside the thread itself and call the ProcessEvent function overloaded with GUI event and SysEvent depends on the result 3. Use two queues. One for sys event and another for GUI event. Run two threads for the same and call the overloaded ProcessEvent function depends on the queue. Here definitely I’ll face some problems with the order of the events received. I need to process the sys and GUI events in first come first serve manner. So this approach will have sync issues. The above are the solutions I have!!! Could you pls suggest one from this or a new one? Again sorry for borring you with a long question :) SaRath.
            "Do Next Thing..." Understanding State Pattern in C++

            H Offline
            H Offline
            HakunaMatada
            wrote on last edited by
            #5

            Virtual Functions ? :rolleyes: --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!

            S 1 Reply Last reply
            0
            • H HakunaMatada

              Virtual Functions ? :rolleyes: --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!

              S Offline
              S Offline
              Sarath C
              wrote on last edited by
              #6

              how ??? SaRath.
              "Do Next Thing..." Understanding State Pattern in C++

              H 1 Reply Last reply
              0
              • S Sarath C

                Take a minute to read. I could not shorten my problem... be patient... I have a CBaseEvent class There are other two classes have derived from CBaseEvent named CSysEvent and CGuiEvent I have created a queue of CBaseEvent pointers. This queue is being processed by an event handler class. A thread is working for this. Whenever a new event adds on the queue, this thread will process the event by calling ProcessEventFunction. which prototyped as ProcessEventFunction(CBaseEvent* pEvent) Here comes the problem. How can I identify between System Event and GUI event? These are the possibilities I have 1. Use dynamic_cast identify the pointer using dynamic cast. Then do the further processing depends on Sys event or GUI event. 2. Do the above check inside the thread itself and call the ProcessEvent function overloaded with GUI event and SysEvent depends on the result 3. Use two queues. One for sys event and another for GUI event. Run two threads for the same and call the overloaded ProcessEvent function depends on the queue. Here definitely I’ll face some problems with the order of the events received. I need to process the sys and GUI events in first come first serve manner. So this approach will have sync issues. The above are the solutions I have!!! Could you pls suggest one from this or a new one? Again sorry for borring you with a long question :) SaRath.
                "Do Next Thing..." Understanding State Pattern in C++

                L Offline
                L Offline
                led mike
                wrote on last edited by
                #7

                SaRath C wrote:

                How can I identify between System Event and GUI event?

                :doh: Why? The whole design is based on not needing to identify them. :confused:

                1 Reply Last reply
                0
                • S Sarath C

                  how ??? SaRath.
                  "Do Next Thing..." Understanding State Pattern in C++

                  H Offline
                  H Offline
                  HakunaMatada
                  wrote on last edited by
                  #8

                  Well not sure if this is exactly what you need, but here goes. :) Define the funtion that you want to call as a pure virtual function in CBaseEvent. Code their implementations in CSysEvent and CGuiEvent. Now whenever you want to call the function, just upcast the CBaseEvent's pointer with either CSysEvent or CGuiEvent's address. CBaseEvent* Base ; CSysEvent Sys ; Base = &Sys ; Base->Function() ; //Calls CSysEvent's Function. Hope this was helpful. --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!

                  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