Hi Lucian,

The basic C++ should have two functions for each member attribute, named after the attribute; one with no arguments, which returns the value of the attribute, and one with one argument which sets the value of the attribute.

So, to set the name you would call
model->name(L"modelname");
And to get the name, you would call
model->name();

These specific functions are located in ./sources/cellml/CellMLImplementation.cpp

Different bindings have different conventions; in the Java binding, we use setX and getX methods for attribute X. In the XPCOM binding we have setX and getX as well, but they both take pointers to a container as arguments, and return status flags. I hope this helps.

As far as a recommended approach to loading files goes, in the test cases for the API, we assume we are given a URL. In OpenCell, we resolve file locations into URLs. Depending on the libraries you are using, converting file locations into URLs or pulling out the text from a file yourself may be trivial or annoying; we use whichever method is least annoying at the time, which is usually resolving the file location into a URL, unless we are dealing with models that only exist in ram.

Best Regards,
Justin.

Quoting Lucian Smith <lpsm...@spod-central.org>:

(Thanks for the link to the CellML2C source; that was very helpful.)

(Also, I'm more than willing to move this to some other forum if it's
better suited there.)

So, I feel like I'm missing something pretty fundamental here, because I
can't figure out how to set the name of a model.  The example Java program
sets the name with a 'setName' function, but this doesn't exist for the
basic C++.  The docs say:

attribute CellMLAttributeString         name
        The name associated with this CellML element.

but trying to do (say)

model->name = L"modelname";

tells me 'invalid use of member', which probably refers to the fact that

model->name()

is a *function* that will give me the name of the model, should it already
be set.

So I don't know whether the docs are out of date, or if the 'attribute'
bit means something I'm unfamiliar with, or what.


In other first-encounter-with-the-library news, I am sad that there is no
loadFile option, just loadFromURL and createFromText.  Is the standard
recommendation to convert a filename to a URL, or to load the file and
extract the text myself?

Thanks for bearing with me through the newbie stage!

-Lucian
_______________________________________________
cellml-discussion mailing list
cellml-discussion@cellml.org
http://www.cellml.org/mailman/listinfo/cellml-discussion




----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

_______________________________________________
cellml-discussion mailing list
cellml-discussion@cellml.org
http://www.cellml.org/mailman/listinfo/cellml-discussion

Reply via email to