[saga-rg] C++ binding: question

Hartmut Kaiser hkaiser at cct.lsu.edu
Fri Nov 4 14:30:39 CST 2005


Andre Merzky wrote:

> here is another question about the C++ language binding we
> stukmbled upon.  The API spec says that the session is an
> optional argument to each object creation in SAGA.  If the
> session is not given, a default session (theSession) is to be
> associated with the object.
>
> Now, consider a object which has a number of optyional
> parameters already (example not spec conform):
>
>   saga::file (string url, mode=saga::file::mode::RO, saga::session s);
>
> If a programmer wants to specify a session, he NEEDS to
> specify mode, and all other optional parameters of the
> constructor.  For a programmer who always specifies a session
> that is awkward.
>
> OTOH, a constructor like
>
>   saga::file (saga::session s, string url, mode=saga::file::mode::RO);
>
> would giove that programmer the ability to use session and
> rely on parameters defaults, but for another programmer who
> does not use an explicit session it would require to ALWAYS
> specify the session anyway:
>
>   saga::file f (theSession, url);
>
>
> The solution we would like to propose is to introduce two
> versions of all constructors:
>
>   saga::file (                 string url, mode=saga::file::mode::RO);
>   saga::file (saga::session s, string url, mode=saga::file::mode::RO);
>
> which would accomodate both use cases nicely.  To be sure:
> that affects only the C++ language bindings - that might look
> totally different for other languages.
>
> Any comments?  If not, we go for the proposed solution...

What about using the Boost.Parameters library to have true named parameters
in C++:

    saga::file f("url", session=theSession, mode=saga::file::mode::RO);
or  saga::file f("url", mode=saga::file::mode::RO);

etc.
?

Regards Hartmut






More information about the saga-rg mailing list