patch
type: Specification
license: isc
developer: me
name: LV2 Patch
release:
  created: 2012-02-08
  revision: 0.1
shortdesc: Messages for accessing and manipulating properties.
documentation: This extension defines messages which can be used to access and manipulate property-based data. It is designed to provide a powerful dynamic control interface for LV2 plugins, but is useful for RDF-like systems in general. The main feature of this design is that requests and responses are themselves completely described in RDF. Thus, the complete protocol can be expressed wherever RDF can without imposing additional implementation burdens like a new syntax or binary formats. In particular, messages can be serialised in Turtle, or as an LV2 Object. This set of patch types is deliberately small to avoid an explosion of messages that all implementations would have to explicitly support. Instead, the idea is to achieve control via manipulating properties rather than defining custom commands. However, this is conceptual; there is no requirement that the receiver actually implement a store of resources with properties. For example, consider an object that can blink. Rather than define a specific interface to control this (e.g. obj.start_blinking(); obj.stop_blinking()), set a blinking property to true or false to achieve the desired behaviour. One benefit of this approach is that a persistent state model is available for free: simply serialise the blinking property. Because changes are described in terms of properties, important functionality like undo stacks or revision control are simple to implement generically. Accordingly, plugins are strongly encouraged to use these property-based messages rather than defining custom methods for every action they require (or worse, defining entirely new formats for messages). These methods are deliberately very similar to HTTP methods, but defined specifically for property-based resources. The properties used here are RDF properties, thus predicates from any of the countless pre-existing vocabularies may be used.

Ack
type: Class
subclass of: Response
documentation: An acknowledgement that a request has been successfully processed. This is returned as a reply when a specific reply type is not necessary or appropriate.

Delete
type: Class
subclass of: Request
documentation: Request the subject(s) be deleted.

Error
type: Class
subclass of: Response
documentation: A response indicating an error processing a request.

Get
type: Class
subclass of: Request
documentation: Request a description of the subject. The detail of the response is not specified, it may be a flat description of all the properties of the subject, or a more expressive description with several subjects. A good choice is a concise bounded description, i.e. a description which recursively includes all properties with blank node values. The response should have the same patch:subject property as the request, and a patch:body that is a description of that subject. For example: <get-request> a patch:Get ; patch:subject <something> . Could result in: [] a patch:Response ; patch:request <get-request> ; patch:subject <something> ; patch:body [ eg:name "Something" ; eg:ratio 1.6180339887 ; ] . Note the use of blank nodes is not required; the value of patch:body may be the actual resource node. Depending on the transport and syntax used this may be preferable. However, the patch:subject property is required regardless. For example, the same response could be written: <something> eg:name "Something" ; eg:ratio 1.6180339887 . [] a patch:Response ; patch:request <get-request> ; patch:subject <something> ; patch:body <something> .

Insert
type: Class
subclass of: Request
subclass of: Restriction
  max cardinality: 1
  on property: subject
documentation: Insert the patch:body at patch:subject. If the subject does not exist, it is created. If the subject does already exist, it is added to. This request only adds properties, it never removes them. The user must take care that multiple values are not set for properties which should only have one value.

Message
type: Class

Move
type: Class
subclass of: Request
subclass of: Restriction
  max cardinality: 1
  on property: subject
subclass of: Restriction
  cardinality: 1
  on property: destination
documentation: Move the patch:subject to patch:destination. After this, patch:destination has the description patch:subject had prior to this request's execution, and patch:subject does not exist any more.It is an error if the subject does not exist or the destination already exists.

Patch
type: Class
subclass of: Request
subclass of: Restriction
  min cardinality: 1
  on property: subject
subclass of: Restriction
  max cardinality: 1
  on property: add
subclass of: Restriction
  max cardinality: 1
  on property: remove
documentation: A method for modifying the properties of an object. This method always has at least one patch:subject, and exactly one patch:add and patch:remove property. The value of patch:add and patch:remove are nodes which have the properties to add or remove from the subject(s), respectively. The special value patch:wildcard may be used as the value of a remove property to remove all properties with the given predicate. For example: [] a patch:Patch ; patch:subject <something> ; patch:add [ eg:name "New name" ; eg:age 42 ; ] ; patch:remove [ eg:name "Old name" ; eg:age patch:wildcard ; # Remove all old eg:age properties ] .

Put
type: Class
subclass of: Request
subclass of: Restriction
  max cardinality: 1
  on property: subject
documentation: Put the patch:body as the patch:subject. If the subject does not already exist, it is created. If the subject does already exist, the patch:body is considered an updated version of it, and the previous version is replaced.

Request
type: Class
subclass of: Message
documentation: A request. A request may have a patch:subject property, which indicates which resource the request applies to. The subject may be omitted in contexts where it is implicit (e.g. the recipient is the subject).

Response
type: Class
subclass of: Message
documentation: A response to a method.

Set
type: Class
subclass of: Request
subclass of: Restriction
  cardinality: 1
  on property: body
documentation: A method for setting properties of an object to unique values. This is a simplified version of patch:Patch which only makes sense for properties which have at most one value. This method always has at least one patch:subject, and exactly one patch:add property. All the properties of the value of patch:add are set on the subject, with all old values for those properties removed. For example: [] a patch:Set ; patch:subject <something> ; patch:body [ eg:name "New name" ; eg:age 42 ; ] . This method is equivalent to a patch:Patch where the patch:remove value has every property of patch:add but with wildcard values. For example, the above patch is equivalent to: [] a patch:Patch ; patch:subject <something> ; patch:add [ eg:name "New name" ; eg:age 42 ; ] ; patch:remove [ eg:name patch:wildcard ; eg:age patch:wildcard ; ] ;

body
type: Property
type: ObjectProperty
type: FunctionalProperty
domain: Message
documentation: The body of a message. The details of this property's value depend on the type of message it is a part of.

request
type: Property
type: ObjectProperty
type: FunctionalProperty
domain: Response
range: Request
documentation: The request this is a response to.