[Insight-users] Why does not a wrapped custom class get AddObserver method in java?

Marcus Wallin wallmarc at gmail.com
Thu Oct 27 09:17:56 EDT 2005


Hi!

I have a custom C++ class that performs operations similar to the example
DeformableModel1. I have managed to get this custom C++ class running from
within Java with the expected results. My problem, however, is that when I
wrap this class to Java, the AddObserver method doesn't get wrapped along
with the rest.

I extend the ITK Object class that contains AddObserver but it apparently is
not there in Java.

In "CustomClass.h"

     class ITK_EXPORT CustomClass : public Object


In trying to circumwent this odd behaviour, I added a method with the same
signature but with differing name.

     unsigned long AddMyObserver(const EventObject & event, Command *);

and implemented this method with

     return AddObserver(event, command);


Sure, this method gets wrapped and is accessible from Java. However, the
method signature is

     AddMyObserver(SWIGTYPE_p_itk__EventObject, SWIGTYPE_p_itk__Command);


which is not at all the same as the AddObserver method that exists in for
instance itkImageSeriesReaderF3_Pointer which is

     AddObserver(itkEventObject, itkCommand);


I suspect there is some configuration in CMakeLists.txt or one of the wrap*
I have missed, but could someone please enlighten me as to where to look?


My goal in the end is to be able to pass an observer from Java down to the
custom C++ class and have events sent back. I have found some previous posts
mentioning that one should create the Observer by extending itkJavaCommand
and implementing the method Execute(), with no parameters. Is this the way
to go?


Thanks,

--
Marcus Wallin
Software Engineer
Chalmers University of Technology, Sweden



More information about the Insight-users mailing list