sony / nmos-cpp

An NMOS (Networked Media Open Specifications) Registry and Node in C++ (IS-04, IS-05)
Apache License 2.0
136 stars 79 forks source link

Implementation of IS-13 NMOS Annotation API #331

Open garethsb opened 1 year ago

garethsb commented 1 year ago

⚠️ Ink isn't dry on the IS-13 spec, but here's an implementation.

garethsb commented 1 year ago

Current annotation_patch_merger has three arguments:

  1. const nmos::resource& resource - the IS-04 resource that is being PATCHed
  2. web::json::value& value - contains the annotation properties from that resource, modifiable by the callback
  3. const web::json::value& patch - contains the body of the PATCH request, which is guaranteed valid per the schema

The behaviour is that the callback is expected to update the value with the patch, and then the calling function updates the resource from the updated value.

Passing read-only resource and a writable value ensures that the callback cannot update other properties than label, description and tags, but that it has access to the full resource to determine semantic validity.

However, the implementation is still a bit complicated. The callback might want to proceed to...

garethsb commented 1 year ago

As @jonathan-r-thorpe suggested, nmos::details::is_read_only_tag is now an overridable predicate, and default values can also be specified declaratively. This is demonstrated by _nmos-cpp-node/nodeimplementation.cpp for the Node and Device tags specified via config.json node_tags and device_tags.

garethsb commented 3 weeks ago

@jonathan-r-thorpe, @lo-simon, I've just attempted to merge master into this rwnode branch, so let's keep an eye on the tests :-)