[Saga-devel] Adding a new (overloaded) method to an adaptor

Hartmut Kaiser hkaiser at cct.lsu.edu
Fri Jan 16 13:34:37 CST 2009


Paul,

> I had sort of got this far having had a good search through the code
> this afternoon.

Cool...

> Can you confirm then that there is no way to have overloading of
> function names in the adaptor and that you have to use different
> function names there

As I said, 'experience shows it's the best to choose different names'.
Although it's possible to use similar names in the adaptor this makes the
automatic function registration much more complex and less powerful. 

Currently, the existing (implemented) adaptor functions are discovered
automatically at _compile_ time allowing the engine to adjust to the
functionality exposed by a certain adaptor (i.e. automatically supplying
asynchronous wrappers if the adaptor implements only synchronous
functionality, etc.). This auto-detection is implemented using C++ meta
template programming tricks. Essentially we figure out, whether a certain
virtual function (i.e. the exposed adaptor functions) is overloaded by the
adaptor or not. If there are two functions with similar names the compiler
is not able to disambiguate those anymore, requiring more complex
registration constructs. You can see examples for those all around, in
almost all packages. Just look for the SAGA_REGISTER_MEMBER_EX() macros in
the existing code.

So, go ahead and use similar names if you like. I just strongly urge you not
to do so. There are more hidden things lurking around behind the scenes than
you might imagine. :-P

As a sidenote: I'm planning to remove the currently existing, duplicate
function names on the adaptor level for all packages. We recently found a
gotcha in the template magic mentioned above which might be easiest to
overcome simply by disambiguating things by design.

> I know that this is fairly well hidden from the end user, it just feels
> wrong to effectively have a C++ interface to the adaptors and yet not
> be able to use function overloading.  It looks like it's not far from a
> plain C interface which would then make wrapping the adaptors with
> other languages a whole lot easier, unless I'm missing some subtlety.

Come on. Now you're exaggerating. 

> I hasten to add that I've only been playing with saga for a few weeks
> and I'm playing Devil's Advocate a little here to see how it all works.
> :)

Thanks for your comments!
Regards Hartmut





More information about the saga-devel mailing list