[Insight-developers] itkEventObject and type_info::before
Lydia Ng
lng@insightful.com
Thu, 13 Dec 2001 16:28:16 -0800
Hi All,
In SubjectImplementation::InvokeEvent an observer
is executed if it event "the same as" (*observer)->m_Event or=20
if event is "before" (*observer)->m_Event
(see code below).
What does the "before" ordering mean?=20
Who determines this "before" ordering?
Is it consistent across platforms?=20
The only description I can on this find is:
---------------------------
You can also ask a typeinfo object if it precedes another typeinfo
object in the implementation-defined "collation sequence," using
before(typeinfo&), which returns true or false. When you say,=20
if(typeid(me).before(typeid(you))) // ...=20
you're asking if me occurs before you in the collation sequence.=20
---------------------------
(from http://www.codeguru.com/cpp/tic/tic0270.shtml)
It's not clear to me what the ordering mean? What=20
is a "collation sequence"?
In my LevelSetShapeDetectionTest I attached an
observer that response to the ProgressEvent only.
In Win32/VC++ the observer also get activated by
StartEvent. While in Cygwin/gcc the observer
was *not* activated by StartEvent.
Which behavior is correct?
Lydia
----------------------------------------------------------
void=20
SubjectImplementation::
InvokeEvent( const EventObject & event,
Object* self)
{
for(std::list<Observer* >::iterator i =3D m_Observers.begin();
i !=3D m_Observers.end(); ++i)
{
const EventObject * e =3D (*i)->m_Event;
if( typeid( *e ) =3D=3D ( typeid( event ) ) ||
typeid( *e ).before( typeid( event ) ) )
{
(*i)->m_Command->Execute(self, event);
}
}
}