General API questoin

2 posts / 0 new
Last post
Offline
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()

and

error = getSomethingElse(referenceToType)

e.g.

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

 

 

Mighhtily confusing.

asorbini's picture
Offline
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.