Getter/Setters

Get/set routines operate on a pointer or handle to an object. Typically they have a set type they operate on. There is also an enum which names each property which can be accessed through this generic interface.

void set_str(thing_t* self, int property, const char* neu);
const char* get_str(thing_t* self, int property);

Accessors are able to perform validation against the current version of an object. If a field is changed it can be upgraded if possible and otherwise silently or loudly failed.

Faceplate mechanism can be used to make these less obnoxious. For example:

static inline void thingbuilder_set_port(thingbuilder_t* self, int port) {
    thingbuilder_set_int(self, tbPort, port);
}