Appearance
class flake::Service
#include <flake/Service.h>
Inherits from flake::ObjectDelegate
Public Functions
| Name | |
|---|---|
| virtual [int] | set(Property & ) =0 |
| virtual Property | get([uint32_t] ) =0 |
| virtual | ~Service() =default |
| virtual ServiceImpl * | asServiceImpl() |
| virtual [void] | onInitialized() =0 This function is called when the service is initialized. |
| virtual [bool] | isInitialized() =0 Checks if the service is initialized. |
| virtual [int] | broadcast([const][string] command, PropArray & params) =0 Broadcasts a command with parameters. |
| virtual [int] | get(PropArray & pa) =0 Retrieve multiple properties from the object. |
| virtual [int] | set(PropArray & pa) =0 Set multiple properties on the object. |
| template <uint32_t PropTag,typenameT > [int] | set([T] value) Set the value of a property. |
| template <uint32_t PropTag> [PropType]< [PropTag] > | get([PropType]< [PropTag] > defval =PropTypeFromTag< TAG_TYPE([PropTag])>::default_value) Retrieve the value of a specific property. |
| template <uint32_t PropTag> [int] | on([PropCallback]< [PropTag] &~TAG_ACTIONABLE > cb, [PropType]< [PropTag] > min, [PropType]< [PropTag] > max) Registers a callback function for a specific tag. |
| template <uint32_t PropTag> [int] | on([PropCallback]< [PropTag] > cb) |
| template <uint32_t PropTag> [int] | onRead([PropCallBackStreamRead] cb) |
| template <uint32_t PropTag> [int] | onOpenClose([PropCallBackStreamOpenClose] cb) |
| template <uint32_t PropTag> [int] | onWrite([PropCallBackStreamWrite] cb) |
| virtual [int] | on([string] message, std::function< [int](PropArray &, PropArray &)> cb) =0 |
| virtual [void] | setMessageHook(std::function< [int]([const][string] &, PropArray &, PropArray &, [void] *)> cb, [void] * ctx) =0 |
| virtual [void] | setPropertyHook(std::function< [int]([uint32_t] tag, Property &value, [const]PropArray &[transaction], [bool], [void] *)> cb, [void] * ctx) =0 |
| virtual [int] | openProperty([const][uint32_t] propTag, Stream ** stream) =0 |
| virtual [int] | sync([int] timeout_ms =FLAKE_DEFAULT_TIMEOUT_MS) =0 |
| virtual [void] | defer() =0 |
| virtual [int] | syncDeferred([unsigned] timeout_ms, [bool] block) =0 |
| virtual [bool] | hasDeferred() =0 |
| virtual [unsigned] | pendingBytes() =0 |
| virtual [void] | reset() =0 |
Additional inherited members
Public Functions inherited from flake::ObjectDelegate
| Name | |
|---|---|
| virtual | ~ObjectDelegate() =default |
| virtual Object * | handle() =0 |
| virtual [int8_t] | handleCustomMessage(std::string name, [const]PropArray & data, PropArray & outProps) =0 |
| virtual [int8_t] | handleStreamOpen(Stream * s) =0 |
| virtual [int8_t] | handleStreamClose(Stream * s) =0 |
| virtual [int8_t] | handleStreamWrite(Stream * s, [uint8_t] * cb, [uint16_t] len) =0 |
| virtual [int8_t] | handleStreamRead(Stream * s, [uint8_t] * cb, [uint16_t] * len, [uint16_t] max_len) =0 |
| virtual [int] | setPropertyRequested([uint32_t] tag, Property & value, [const]PropArray & transaction, [bool] internal) =0 |
| virtual [int] | getPropertyRequested([uint32_t] tag, Property & value) =0 |
| virtual [void] | propertyChanged([const]Property & ) =0 |
Detailed Description
cpp
class flake::Service;This class provides a base implementation for a service. A service is responsible for interacting with properties and handling messages and events.
Public Functions Documentation
function set
cpp
virtual int set(
Property &
) =0function get
cpp
virtual Property get(
uint32_t
) =0function ~Service
cpp
virtual ~Service() =defaultfunction asServiceImpl
cpp
inline virtual ServiceImpl * asServiceImpl()function onInitialized
cpp
virtual void onInitialized() =0This function is called when the service is initialized.
Reimplements: flake::ObjectDelegate::onInitialized
This function should be overridden in derived classes to perform any necessary initialization tasks when the service is initialized.
function isInitialized
cpp
virtual bool isInitialized() =0Checks if the service is initialized.
Return: bool True if the service is initialized, otherwise false.
This function returns a boolean value indicating whether the service is initialized or not.
function broadcast
cpp
virtual int broadcast(
conststring command,
PropArray & params
) =0Broadcasts a command with parameters.
Parameters:
- command The command to be broadcasted.
- params The parameters associated with the command.
Return: int The result of the broadcast. Returns 0 if the broadcast is successful. Returns an error code if the broadcast fails.
This function sends a command with parameters to all interested listeners. It should be called when you want to notify other entities about an event or action.
function get
cpp
virtual int get(
PropArray & pa
) =0Retrieve multiple properties from the object.
Parameters:
- pa A reference to an empty PropArray object to be populated.
Return: An integer representing the result of the operation.
- E_FAILED: If none of the properties could be retrieved
- E_PARTIAL_SUCCESS: if some of the properties could be retrieved
- E_OK: if all of the properties could be retrieved.
function set
cpp
virtual int set(
PropArray & pa
) =0Set multiple properties on the object.
Parameters:
- pa The PropArray object containing the properties to be set
Return: An integer representing the result of the operation.
- E_FAILED: If none of the properties could be set
- E_PARTIAL_SUCCESS: if some of the properties could be set
- E_OK: if all of the properties could be set.
- E_REFUSED: if called from within a property-callback, registered with on
Note: : mind, that you cannot call set from within a property-callback you registered with on
function set
cpp
template <uint32_t PropTag,
typenameT >
inline int set(
T value
)Set the value of a property.
Parameters:
- value The value to be set.
Template Parameters:
- PropTag The tag of the property.
- T The type of the value to be set.
Return: An integer representing the result of the operation.
- E_REFUSED: If the passed value cannot be safely cast to the property's type. or if called from within a property-callback, registered with on
- E_OK: if the operation succeeded
Note: : mind, that you cannot call set from within a property-callback you registered with on!
This function is used to set the value of a property identified by its tag. The value to be set can be of any type supported by the property, as long as it is convertible to the property's type.
function get
cpp
template <uint32_t PropTag>
inline PropType< PropTag > get(
PropType< PropTag > defval =PropTypeFromTag< TAG_TYPE(PropTag)>::default_value
)Retrieve the value of a specific property.
Parameters:
- defval The default value to be returned if the property value is not found.
Template Parameters:
- PropTag The tag of the property.
Return: PropType The value of the property or the default value.
This function is used to retrieve the value of a property identified by its tag. If the property value is not found, the default value provided will be returned.
function on
cpp
template <uint32_t PropTag>
inline int on(
PropCallback< PropTag &~TAG_ACTIONABLE > cb,
PropType< PropTag > min,
PropType< PropTag > max
)Registers a callback function for a specific tag.
Parameters:
- tag The unique identifier for the property.
- cb The callback function to handle the property.
Return: int Returns 0 if the registration is successful, or an error code if the registration fails.
This function is used to register a callback function for a specific tag. When the specified tag is encountered during property handling, the registered callback function will be called to handle the property.
function on
cpp
template <uint32_t PropTag>
inline int on(
PropCallback< PropTag > cb
)function onRead
cpp
template <uint32_t PropTag>
inline int onRead(
PropCallBackStreamRead cb
)function onOpenClose
cpp
template <uint32_t PropTag>
inline int onOpenClose(
PropCallBackStreamOpenClose cb
)function onWrite
cpp
template <uint32_t PropTag>
inline int onWrite(
PropCallBackStreamWrite cb
)function on
cpp
virtual int on(
string message,
std::function< int(PropArray &, PropArray &)> cb
) =0function setMessageHook
cpp
virtual void setMessageHook(
std::function< int(conststring &, PropArray &, PropArray &, void *)> cb,
void * ctx
) =0function setPropertyHook
cpp
virtual void setPropertyHook(
std::function< int(uint32_t tag, Property &value, constPropArray &transaction, bool, void *)> cb,
void * ctx
) =0function openProperty
cpp
virtual int openProperty(
constuint32_t propTag,
Stream ** stream
) =0function sync
cpp
virtual int sync(
int timeout_ms =FLAKE_DEFAULT_TIMEOUT_MS
) =0function defer
cpp
virtual void defer() =0function syncDeferred
cpp
virtual int syncDeferred(
unsigned timeout_ms,
bool block
) =0function hasDeferred
cpp
virtual bool hasDeferred() =0function pendingBytes
cpp
virtual unsigned pendingBytes() =0function reset
cpp
virtual void reset() =0