Help me with a solution for what could be solutioned by virtual static fields... in FPC

Posted by Gregory Smith on Stack Overflow See other posts from Stack Overflow or by Gregory Smith
Published on 2010-02-28T02:53:52Z Indexed on 2010/04/10 22:33 UTC
Read the original article Hit count: 432

Filed under:
|
|
|
|

Hi
I'm doing an event manager in Freepascal
Each event is an object type TEvent (=object), each kind of event must derive from this class.
Events are differentiated by an integer identificator, assigned dynamically.
The problem is that i want to retrieve the event id of an instance, and i can't do it well.

  • All instances of a class(object) have a unique id => so it should be static field.
  • All classes have a diferent id => so it should be virtual.
  • Event ids are assignated in run time, and can change => so it can't be a simple method

In sum, I can't put all this together.
I'm looking for an elegant solution, i don't want to write a hardcoded table, actualizing it in every constructor... etc, i'd prefer something taking advantage of the polymorphism
Can anyone help me with another technical or design solution?
I remark I don't want to use class instead of object construct.(property doesn't work on objects? :(

© Stack Overflow or respective owner

Related posts about freepascal

Related posts about fpc