A list for the developers of CellML tools

Text archives Help


[cellml-dev] CellML API: cleaner C++ interface


Chronological Thread 
  • From: ak.miller at auckland.ac.nz (Andrew Miller)
  • Subject: [cellml-dev] CellML API: cleaner C++ interface
  • Date: Wed, 09 Nov 2011 12:00:52 +1300

Hi all,

A number of people have commented that the C++ interface to the CellML
API is difficult to use, and so I have been working on ways to improve
it, while minimising the need for users of the CellML API to change
their code.

A number of changes have now been pushed to the Mercurial repository on
Sourceforge, and now would be a good opportunity for people to comment
on them:
1. Instead of returning wchar_t*, methods returning strings now return
std::wstring. If your code is written using RETURN_INTO_WSTRING, this
code should continue to work, as the macro has been changed to expect a
std::wstring return. Calls into the API now expect a const std::wstring&
wherever a string is needed; calling it with a wchar_t* will continue to
work because the compiler will construct a std::wstring temporary
automatically so your code won't need to be changed (although if you are
using someWString.c_str() as an argument, it will now be more efficient
to get rid of the .c_str() part).
2. Instead of returning a bare pointer to a type T (i.e. T*), functions
return objects now have return type already_AddRefd<T>. ObjRef
recognises this and doesn't call add_ref. This means that instead of
writing:
ObjRef<T> myT = already_AddRefd<T>(o->functionThatReturnsT());
you can instead simply write:
ObjRef<T> myT = o->functionThatReturnsT();
Code that was written as:
RETURN_INTO_OBJREF(myT, T, functionThatReturnsT());
will continue to work as before.
The last form was the way we previously encouraged people to write code,
and so if this form is used, no code changes will be required in
applications that call the API. However, code that defines callbacks may
need to be changed.
3. Instead of passing sequences as arrays, they are now passed as
std::vectors. This only affects the CIS and SRuS (which return sequences
of numbers when giving results).

Please let me know what you think (on tracker item 3108:
https://tracker.physiomeproject.org/show_bug.cgi?id=3108).

Best wishes,
Andrew



  • [cellml-dev] CellML API: cleaner C++ interface, Andrew Miller, 11/09/2011

Archive powered by MHonArc 2.6.18.

Top of page