Implementing the IEventData interface

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Implementing the IEventData interface

      Can someone explain to me what this C++ code is doing? Specifically, the timeStamp portions of it. I don't see any classes that implement this use the timeStamp anywhere. There is a method to get the timeStamp, but that isn't used anywhere. I don't see any place the timeStamp is being set either, except it looks like it's defaulting to 0.0f.


      Source Code

      1. class BaseEventData : public IEventData
      2. {
      3. const float m_timeStamp;
      4. public:
      5. explicit BaseEventData(const float timeStamp = 0.0f) : m_timeStamp(timeStamp) { }
      6. // Returns the type of the event
      7. virtual const EventType& VGetEventType(void) const = 0;
      8. float GetTimeStamp(void) const { return m_timeStamp; }
      9. // Serializing for network input / output
      10. virtual void VSerialize(std::ostrstream &out) const { }
      11. virtual void VDeserialize(std::istrstream& in) { }
      12. };
      Display All
    • I'm pretty sure this is dead code from a previous edition of the book. It's easy enough to resurrect it or remove it if you like. The original idea is that it's sometimes useful to know when an event was triggered so that you you can ignore older events of the same type. I don't remember if that was actually happening in the old system.

      In the current system, every event is handled in the order it was pushed.

      -Rez