Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 831975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:17:24+00:00 2026-05-15T04:17:24+00:00

Here is my situation: I have an event driven system, where all my handlers

  • 0

Here is my situation:

I have an event driven system, where all my handlers are derived from IHandler class, and implement an onEvent(const Event &event) method. Now, Event is a base class for all events and contains only the enumerated event type. All actual events are derived from it, including the EventKey event, which has 2 fields: (uchar) keyCode and (bool) isDown.

Here’s the interesting part: I generate an EventKey event using the following syntax:

Event evt = EventKey(15, true);

and I ship it to the handlers:

EventDispatch::sendEvent(evt); // void EventDispatch::sendEvent(const Event &event);

(EventDispatch contains a linked list of IHandlers and calls their onEvent(const Event &event) method with the parameter containing the sent event.

Now the actual question:

Say I want my handlers to poll the events in a queue of type Event, how do I do that?

  • Dynamic pointers with reference counting sound like too big of a solution.

  • Making copies is more difficult than it sounds, since I’m only receiving a reference to a base type, therefore each time I would need to check the type of event, upcast to EventKey and then make a copy to store in a queue. Sounds like the only solution – but is unpleasant since I would need to know every single type of event and would have to check that for every event received – sounds like a bad plan.

  • I could allocate the events dynamically and then send around pointers to those events, enqueue them in the array if wanted – but other than having reference counting – how would I be able to keep track of that memory? Do you know any way to implement a very light reference counter that wouldn’t interfere with the user?

What do you think would be a good solution to this design?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:17:25+00:00Added an answer on May 15, 2026 at 4:17 am

    Opinion: choose the reference counting option. Use boost::shareed_ptr, and boost::dynamic_pointer_cast to determine actual type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is my situation: I have class 1 that calls a method from class
here's the situation: I have a where in every cell all the area has
I have an situation here that looks very like a SELECT N+1 from the
So here is the situation: I have a class. For examples sake: class Author
If I have a class with a couple of event handlers inside of it
Here is the situation: I have created a custom view class with UITextView as
Not even sure I'm stating the question correctly. Here's the situation. I have a
Here is the situation : we have to offer a customer with a web-based
Here is my situation: I have one table that contains a list of drugs
Here is my situation: I have a C project linking with many libraries (I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.