G'day,
Doing a little input manager for a project of mine. Basically I have an input event (InputEvent), which is a simple, small class. And then a user-defined function which takes an std::queue<InputEvent>.
The user-defined function is called about 100 times a second. With say a max of 10 input events per-call. Is it wise to be storing InputEvent objects in the queue or should I be storing pointers?
Basically I don't want to make the user free the InputEvent pointers themselves.
Secondly, should I specifically make my InputEvent copyable (ie override operator=)?
In short I have,
My library
Code:
// ...
std::queue<InputEvent> events_;
// ... add the events to the queue
events_.push(InputEvent(x, y));
events_.push(InputEvent(x, y));
events_.push(InputEvent(x, y));
client->frame(&events_);
// ...
User's code
Code:
void frame(std::queue<InputEvent> * events)
{
// the InputEvents are removed from the queue
}
Thanks!
Zac