openigtlink / OpenIGTLink

Free, open-source network communication library for image-guided therapy
http://openigtlink.org
BSD 3-Clause "New" or "Revised" License
103 stars 184 forks source link

igtlTypeMacro not working outside igtl namespace #195

Open djromberg opened 6 years ago

djromberg commented 6 years ago

When defining own messages derived from igtl::MessageBase or other bases, the igtlTypeMacro can only be used when the defining class is inside the igtl namespace. The reason is the reference to the SmartPointer template which is not fully qualified in the macro. A workaround is to use a template<typename T> using SmartPointer = igtl::SmartPointer<T>; before using the macro, but in my opinion the macro should be changed to use igtl::SmartPointer directly instead.

leochan2009 commented 6 years ago

Hi, This is the same as what I mentioned in #192 .Yes, we could change to use igtl::SmartPointer directly

leochan2009 commented 6 years ago

@Sunderlandkyl , what do you think about changing IgtlMacro to

define igtlTypeMacro(thisClass,superclass)

virtual const char *GetNameOfClass() const {return #thisClass;} typedef thisClass Self; typedef superclass Superclass; typedef igtl::SmartPointer Pointer; typedef igtl::SmartPointer ConstPointer;

Sunderlandkyl commented 6 years ago

Sounds good to me.