[Insight-developers] itkEventObject and type_info::before

Luis Ibanez ibanez@choroid.cs.unc.edu
Thu, 13 Dec 2001 23:32:59 -0500 (EST)


Lydia Ng wrote:
> 
> In "The C++ Programming Language" Stroustrup (3rd ed)
> section 15.4.4
> 
> "There is no relation between the relationships defined
> by before and inheritance relationships"
> 

-----------------

Oops    :-\


It looks like I was making up 
a Hammer that fitted my nails...


That let us with the binary decision:

1) go back to the enums for events (I guess is what Bill proposed)
2) implement an IP-like encoding for events (something to explore)


Applications involving complex GUI's can take advantage
of the hierarchical approach because event are in some
way factorized.


the idea of the IP encoding will be to 
define unique codes for every eventclass. 

Each level of inheritance will add a 
byte to the lenght of the code.

Starting with "AnyEvent", with code null (0 bytes),
its descendants will have codes of 1-byte, and we
can have only 255 of them. The descendants of this
first generation will have codes of 2 bytes, and again
in each one only 255 grand children will be allowed.

That will be easily implemented by using a std::string
for holding the code. The length of the string will 
indicate how many derivations have been done since 
"AnyEvent". A std::vector<char> will also do the job.

If event B derives (directly or after several generations)
from event A. their codes should be such that the code
of A is the prefix of the code in B.

e.g.

   A code = 2.2.3
   B code = 2.2.3.5.6

==> B derives from A

Just like looking if an IP number is in a particular domain,
with the difference that we are not limiting the levels to
four bytes.

(That's where OOP looks pretty much like genetics...)
    

However, it is not quite clear how that will behave in a 
multithreading environment



   Luis