Skip to content

class flake::ObjectDelegate

Interface to be implemented by the application to expose a custom Flake object. More...

#include <platform/flake/Object.h>

Public Functions

Name
virtual~ObjectDelegate() =default
virtual Object *handle() =0
Return the underlying Object handle for this delegate.
virtual int8_thandleCustomMessage(std::string name, constPropArray & data, PropArray & outProps) =0
Handle an incoming custom (named) message.
virtual int8_thandleStreamOpen(Stream * s) =0
Called when a remote client opens a stream on this object.
virtual int8_thandleStreamClose(Stream * s) =0
Called when a previously opened stream is closed.
virtual int8_thandleStreamWrite(Stream * s, uint8_t * cb, uint16_t len) =0
Called when a remote client writes data into a stream.
virtual int8_thandleStreamRead(Stream * s, uint8_t * cb, uint16_t * len, uint16_t max_len) =0
Called when a remote client reads data from a stream.
virtual intsetPropertyRequested(uint32_t tag, Property & value, constPropArray & transaction, bool internal) =0
Called when a remote client requests to change a property.
virtual intgetPropertyRequested(uint32_t tag, Property & value) =0
Called when a remote client reads a property.
virtual voidpropertyChanged(constProperty & ) =0
Notification that a property has been changed (after commit).
virtual voidonInitialized() =0
Called once after the object has been fully initialized and registered with the router.

Protected Functions

Name
ObjectDelegate() =default

Detailed Description

cpp
class flake::ObjectDelegate;

Interface to be implemented by the application to expose a custom Flake object.

Note: Non-copyable, non-movable.

Register an ObjectDelegate with Connection::registerObject() to make it discoverable by remote clients. The framework calls the virtual methods below in response to client requests.

Public Functions Documentation

function ~ObjectDelegate

cpp
virtual ~ObjectDelegate() =default

function handle

cpp
virtual Object * handle() =0

Return the underlying Object handle for this delegate.

Return: Pointer to the associated Object.

function handleCustomMessage

cpp
virtual int8_t handleCustomMessage(
    std::string name,
    constPropArray & data,
    PropArray & outProps
) =0

Handle an incoming custom (named) message.

Parameters:

  • name Name of the message.
  • data Input properties.
  • outProps Output properties to return to the caller.

Return: Application-defined result code (0 = success).

function handleStreamOpen

cpp
virtual int8_t handleStreamOpen(
    Stream * s
) =0

Called when a remote client opens a stream on this object.

Parameters:

Return: 0 to accept, non-zero to reject the stream.

function handleStreamClose

cpp
virtual int8_t handleStreamClose(
    Stream * s
) =0

Called when a previously opened stream is closed.

Parameters:

  • s The stream being closed.

Return: 0 on success.

function handleStreamWrite

cpp
virtual int8_t handleStreamWrite(
    Stream * s,
    uint8_t * cb,
    uint16_t len
) =0

Called when a remote client writes data into a stream.

Parameters:

  • s The stream.
  • cb Buffer containing the incoming bytes.
  • len Number of bytes in cb.

Return: 0 on success, non-zero on error.

function handleStreamRead

cpp
virtual int8_t handleStreamRead(
    Stream * s,
    uint8_t * cb,
    uint16_t * len,
    uint16_t max_len
) =0

Called when a remote client reads data from a stream.

Parameters:

  • s The stream.
  • cb Destination buffer.
  • len Number of bytes written into cb.
  • max_len Capacity of cb.

Return: 0 on success, non-zero on error.

The implementation fills cb with up to max_len bytes and sets len to the number of bytes actually provided.

function setPropertyRequested

cpp
virtual int setPropertyRequested(
    uint32_t tag,
    Property & value,
    constPropArray & transaction,
    bool internal
) =0

Called when a remote client requests to change a property.

Parameters:

  • tag The property tag being modified.
  • value Proposed new value; may be modified by the implementation.
  • transaction All properties submitted in the same setProperties() call.
  • internal true if the change originates from the object itself (local).

Return: E_OK to accept, or a negative error code to reject.

function getPropertyRequested

cpp
virtual int getPropertyRequested(
    uint32_t tag,
    Property & value
) =0

Called when a remote client reads a property.

Parameters:

  • tag The property tag being queried.
  • value The property to populate.

Return: E_OK on success, or a negative error code.

The implementation may fill value with a freshly computed result.

function propertyChanged

cpp
virtual void propertyChanged(
    constProperty & 
) =0

Notification that a property has been changed (after commit).

Parameters:

  • property The property that was changed.

function onInitialized

cpp
virtual void onInitialized() =0

Called once after the object has been fully initialized and registered with the router.

Protected Functions Documentation

function ObjectDelegate

cpp
ObjectDelegate() =default