cortoproject / corto

A hierarchical object store for connecting realtime machine data with web applications, historians & more
https://www.corto.io
MIT License
86 stars 14 forks source link

Add support for objective state, observable/optional members to corto_rw API #687

Closed SanderMertens closed 6 years ago

SanderMertens commented 6 years ago

Currently the corto_rw API does not correctly handle observable/optional fields and fields of a target type (objective state). The corto_rw API should:

For target members, the API should automatically pick the target or actual members when not explicitly specified. For example, given the following type description:

struct Foo {
    m: target[int32]
}

and the following code:

corto_object o = corto_create(data_o, "my_obj", Foo_o);
corto_rw rw = corto_rw_init(Foo_o, o);
corto_rw_field(&rw, "m");
corto_rw_set_int(&rw, 10);
corto_rw_deinit(&rw);

if my_obj is owned by the current thread, the m.actual member should be set. If the object is not owned, the m.target member should be set. The target, actual and objective members may also be explicitly set. When attempting to explicitly assign a member that is not owned by the thread, the set operation will fail.

The API should also take into account complex types. Take for example this type definition:

struct Point {
    x, y: int32
}
struct Foo {
    m: target[Point]
}

It should be possible to select field expression m.x, and depending on whether the object is owned or not, the API will set m.target.x or m.actual.x.