BusBricks: Service< content_class, stackSize > Class Template Reference
BusBricks  0.1
Customize bus-communication
Loading...
Searching...
No Matches
Service< content_class, stackSize > Class Template Reference

Service-Template to derive a Service class by defining the Content (derived Class of "Content") to handle and the size of the stacks (send and receive). A Service has to be instantiated with a unique service-ID and an instance-ID, the service-instance should use for it's communication. E.g.: Messenger-service with service-id "m" (specified in derived class, same on every host) is instantiated with a host-specific ID to identify the instances. The derived classes have to define the stack-processing to handle the payload at the rec-stack and add payload to the send-stack. Each derived class has a unique serviceID to identify the Service-type and each instance in the communication-network has a unique instanceID. More...

#include <Service.h>

Inheritance diagram for Service< content_class, stackSize >:
[legend]
Collaboration diagram for Service< content_class, stackSize >:
[legend]

Public Member Functions

 Service (uint8_t serviceID, uint8_t instanceID)
 
uint8_t * get_ServiceID () override
 Get pointer to the 1-byte ServiceID of the Service (unique for each Service-template derived Class)
 
uint8_t * get_InstanceID () override
 Get pointer to the 1-byte InstanceID of the Service-instance (unique for each Instance of Service within the whole communication-network)
 
virtual bool impart_pdu (String *pdu) override
 Add a new Content-Object created from a received payload to the services receive-Stack. The payload is the representation of the Content-Object, during the construction, the Content-object creates it's content from the representation. The Content-object is added to the rec_stack.
 
virtual String get_response () override
 Get the get the response-payload, stored at the response_pdu of the service instance

 
virtual bool responseAvailable () override
 Check, if a response of the service is available (services sendStack not empty)
 
virtual void clearResponse () override
 Clear the response-buffer (delete item, that was returned by get_response from the service-sendStack)
 
virtual void stackProcessing () override
 Execute the service's functions for each item on the receive-stack and add all response-payloads to be send to the send-stack.
 
- Public Member Functions inherited from ServiceBase
virtual ~ServiceBase ()
 Destroy the Service Base object.
 

Protected Member Functions

void write_response_pdu (content_class response_object)
 

Protected Attributes

uint8_t serviceID
 
uint8_t instanceID
 
Content_stack< content_class, stackSize > rec_stack
 
Content_stack< content_class, stackSize > send_stack
 
String response_pdu
 

Detailed Description

template<typename content_class, int stackSize>
class Service< content_class, stackSize >

Service-Template to derive a Service class by defining the Content (derived Class of "Content") to handle and the size of the stacks (send and receive). A Service has to be instantiated with a unique service-ID and an instance-ID, the service-instance should use for it's communication. E.g.: Messenger-service with service-id "m" (specified in derived class, same on every host) is instantiated with a host-specific ID to identify the instances. The derived classes have to define the stack-processing to handle the payload at the rec-stack and add payload to the send-stack. Each derived class has a unique serviceID to identify the Service-type and each instance in the communication-network has a unique instanceID.

Author
Felix Schuelke (flxsc.nosp@m.ode@.nosp@m.gmail.nosp@m..com)
Template Parameters
content_classtype of the items stored in the stack
stackSizetype of the items stored in the stack

Member Function Documentation

◆ clearResponse()

template<typename content_class , int stackSize>
virtual void Service< content_class, stackSize >::clearResponse ( )
inlineoverridevirtual

Clear the response-buffer (delete item, that was returned by get_response from the service-sendStack)

Implements ServiceBase.

Here is the call graph for this function:

◆ get_InstanceID()

template<typename content_class , int stackSize>
uint8_t * Service< content_class, stackSize >::get_InstanceID ( )
inlineoverridevirtual

Get pointer to the 1-byte InstanceID of the Service-instance (unique for each Instance of Service within the whole communication-network)

Returns
uint8_t* InstanceID of the Service-instance

Implements ServiceBase.

◆ get_response()

template<typename content_class , int stackSize>
virtual String Service< content_class, stackSize >::get_response ( )
inlineoverridevirtual

Get the get the response-payload, stored at the response_pdu of the service instance

Returns
String response-pdu as String

Implements ServiceBase.

Here is the call graph for this function:

◆ get_ServiceID()

template<typename content_class , int stackSize>
uint8_t * Service< content_class, stackSize >::get_ServiceID ( )
inlineoverridevirtual

Get pointer to the 1-byte ServiceID of the Service (unique for each Service-template derived Class)

Returns
uint8_t* ServiceID of the service

Implements ServiceBase.

◆ impart_pdu()

template<typename content_class , int stackSize>
virtual bool Service< content_class, stackSize >::impart_pdu ( String * pdu)
inlineoverridevirtual

Add a new Content-Object created from a received payload to the services receive-Stack. The payload is the representation of the Content-Object, during the construction, the Content-object creates it's content from the representation. The Content-object is added to the rec_stack.

Parameters
pdupayload from received Frame-object as pointer to string
Returns
true content-object added to service-rec_stack
false rec_stack is full, content-object not added

Implements ServiceBase.

Here is the call graph for this function:

◆ responseAvailable()

template<typename content_class , int stackSize>
virtual bool Service< content_class, stackSize >::responseAvailable ( )
inlineoverridevirtual

Check, if a response of the service is available (services sendStack not empty)

Returns
true a response-payload is available
false no response-payload is available

Implements ServiceBase.

Here is the call graph for this function:

◆ stackProcessing()

template<typename content_class , int stackSize>
virtual void Service< content_class, stackSize >::stackProcessing ( )
inlineoverridevirtual

Execute the service's functions for each item on the receive-stack and add all response-payloads to be send to the send-stack.

Implements ServiceBase.

Reimplemented in ErrorService, and MessageService.

Here is the call graph for this function:

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