General API questoin

2 posts / 0 new
Last post
Last seen: 8 months 1 week ago
Joined: 02/08/2021
Posts: 6
General API questoin

Why is there such a mixture of

type = getSomething()


error = getSomethingElse(referenceToType)


DDSTopic *topic = writer->get_topic();
DDS_ReturnCode_tretval = publisher->get_default_datawriter_qos(qos);



Mighhtily confusing.

asorbini's picture
Last seen: 1 month 3 weeks ago
Joined: 02/06/2013
Posts: 7

In general, the DDS API (and RTI Connext DDS' implementation of it), tends to favor the idiom where an error code is returned by function calls which may fail, with other output values returned via formal parameters.

There are few exception to this pattern, namely the various create_XXX() functions, for which the only "error code" returned is a nil return value, and some "accessor" methods (like DDS_DataWriter_get_topic), which are never expected to fail in a sound implementation.