Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
swarmio::services::keyvalue::Service Class Referencefinal

The Key-Value Service is responsible for getting and setting named values. More...

#include <Service.h>

Inheritance diagram for swarmio::services::keyvalue::Service:
Inheritance graph
[legend]

Public Member Functions

virtual void DescribeService (data::discovery::Response &descriptor) override
 Add descriptors for the service to the discovery descriptor. More...
 
virtual bool ReceiveMessage (const Node *sender, const data::Message *message) override
 Delivery point of all messages. More...
 
void RegisterTarget (const std::string &path, Target *target)
 Register a new Target with the specified path. More...
 
 Service (Endpoint *endpoint)
 Construct a new Service object. More...
 
void UnregisterTarget (const std::string &path)
 Unregister a Target. More...
 
- Public Member Functions inherited from swarmio::Mailbox
virtual void Disconnect ()
 Disconnect this Mailbox from the Endpoint. More...
 
EndpointGetEndpoint ()
 Get the associated Endpoint. More...
 
 Mailbox (const Mailbox &)=delete
 Remove copy constructor. More...
 
virtual void MailboxWasConnected () noexcept
 Called when the mailbox is attached to an already running endpoint or if the attached endpoint has just started. More...
 
virtual void MailboxWillBeDisconnected () noexcept
 Called right before the mailbox is disconnected from its endpoint or if the attached endpoint is about to stop. More...
 
virtual void NodeDidJoin (const Node *node) noexcept
 Called when a new Node has joined the group. More...
 
virtual void NodeWasDiscovered (const Node *node) noexcept
 Called when a new Node has been discovered. More...
 
virtual void NodeWillLeave (const Node *node) noexcept
 Called when a Node signals that it will leave. More...
 
Mailboxoperator= (const Mailbox &)=delete
 Remove assignment operator. More...
 
virtual ~Mailbox ()
 Destroy the Mailbox object. More...
 

Static Public Member Functions

static ValueAwaiter Get (Endpoint *endpoint, const Node *node, const std::string &path)
 Get a remote value. More...
 
static ErrorAwaiter Set (Endpoint *endpoint, const Node *node, const std::string &path, const data::Variant &value)
 Set a remote value. More...
 

Private Member Functions

bool HandleGetRequest (const Node *sender, const data::Message *message)
 Handle remote Get requests. More...
 
bool HandleSetRequest (const Node *sender, const data::Message *message)
 Handle remote Set requests. More...
 

Private Attributes

std::mutex _mutex
 Mutex to protect target list. More...
 
std::map< std::string, Target * > _targets
 Key-target map. More...
 

Additional Inherited Members

- Protected Member Functions inherited from swarmio::Mailbox
void FinishConstruction ()
 Called when the last constructor has finished its job. More...
 
void FinishMovingTo (Mailbox *other)
 Called when message handling should be passed onto the new instance. More...
 
 Mailbox ()
 Construct a disconnected Mailbox. More...
 
 Mailbox (Endpoint *endpoint)
 Construct a new Mailbox object. More...
 
 Mailbox (Mailbox &&other)
 Move a Mailbox object. More...
 

Detailed Description

The Key-Value Service is responsible for getting and setting named values.

Definition at line 20 of file keyvalue/Service.h.

Constructor & Destructor Documentation

swarmio::services::keyvalue::Service::Service ( Endpoint endpoint)
inline

Construct a new Service object.

Parameters
endpointEndpoint

Definition at line 84 of file keyvalue/Service.h.

Member Function Documentation

void Service::DescribeService ( data::discovery::Response &  descriptor)
overridevirtual

Add descriptors for the service to the discovery descriptor.

Parameters
descriptorThe proposed response to load the description into

Implements swarmio::services::discovery::Discoverable.

Definition at line 149 of file keyvalue/Service.cpp.

ValueAwaiter Service::Get ( Endpoint endpoint,
const Node node,
const std::string &  path 
)
static

Get a remote value.

Thread-safe.

Parameters
endpointEndpoint to use
nodeNode to get the value from
pathResource path
Returns
ValueAwaiter Async value

Definition at line 9 of file keyvalue/Service.cpp.

bool Service::HandleGetRequest ( const Node sender,
const data::Message *  message 
)
private

Handle remote Get requests.

Parameters
requestRequest message
reply_toReply address
Returns
True if the request was handled

Definition at line 72 of file keyvalue/Service.cpp.

bool Service::HandleSetRequest ( const Node sender,
const data::Message *  message 
)
private

Handle remote Set requests.

Parameters
requestRequest message
Returns
True if the request was handled

Definition at line 102 of file keyvalue/Service.cpp.

bool Service::ReceiveMessage ( const Node sender,
const data::Message *  message 
)
overridevirtual

Delivery point of all messages.

Parameters
senderThe node that has sent the message
messageThe message itself
Returns
True if the message had been processed and should not be forwarded to other mailboxes

Reimplemented from swarmio::Mailbox.

Definition at line 52 of file keyvalue/Service.cpp.

void Service::RegisterTarget ( const std::string &  path,
Target target 
)

Register a new Target with the specified path.

Thread-safe.

Parameters
pathResource path
targetTarget

Definition at line 125 of file keyvalue/Service.cpp.

ErrorAwaiter Service::Set ( Endpoint endpoint,
const Node node,
const std::string &  path,
const data::Variant &  value 
)
static

Set a remote value.

Thread-safe.

Parameters
endpointEndpoint to use
nodeNode to set the value at
pathResource path
Returns
ErrorAwaiter Async result

Definition at line 30 of file keyvalue/Service.cpp.

void Service::UnregisterTarget ( const std::string &  path)

Unregister a Target.

Thread-safe.

Parameters
pathResource path

Definition at line 141 of file keyvalue/Service.cpp.

Member Data Documentation

std::mutex swarmio::services::keyvalue::Service::_mutex
private

Mutex to protect target list.

Definition at line 34 of file keyvalue/Service.h.

std::map<std::string, Target*> swarmio::services::keyvalue::Service::_targets
private

Key-target map.

Definition at line 28 of file keyvalue/Service.h.


The documentation for this class was generated from the following files:


swarmros
Author(s):
autogenerated on Fri Apr 3 2020 03:42:48