pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
Football::ServiceBase Class Referenceabstract

C++ Service wrapper Manages the service's connections. More...

#include <football.h>

Inheritance diagram for Football::ServiceBase:
Inheritance graph
[legend]
Collaboration diagram for Football::ServiceBase:
Collaboration graph
[legend]

Public Member Functions

void close (void)
 Initiate shutdown of a service. More...
 
ConnectionnewConnectionFromFile (const std::string &filename)
 Create a new "connection" that reads from a file. More...
 
ConnectionnewLoopbackConnection (int *loopback)
 Create a new connection that loops back to the service. More...
 
virtual ssize_t conditional_print (bool(*callback)(FB_CONNECTION *), const std::string &message) override
 
virtual void serviceShutdown (void)
 Invoked when a service is shutting down. More...
 
- Public Member Functions inherited from Football::Thingie
virtual ~Thingie ()
 
ssize_t print (const std::string &message)
 Add a string to the output queues. More...
 
ssize_t conditional_broadcast (bool(*callback)(FB_CONNECTION *), const std::string &message)
 Send a message to some output queues depending on the callback function return value. More...
 
ssize_t printf (const char *format,...)
 Add messages to output queues. More...
 
ssize_t vprintf (const char *format, va_list parameters)
 
ssize_t bprintf (const char *format,...)
 
ssize_t bvprintf (const char *format, va_list parameters)
 
ssize_t cbprintf (bool(*callback)(FB_CONNECTION *), const char *format,...)
 
ssize_t cbvprintf (bool(*callback)(FB_CONNECTION *), const char *format, va_list parameters)
 
virtual std::streamsize xsputn (const char_type *data, std::streamsize count) override
 
virtual int_type overflow (int_type c) override
 

Protected Member Functions

virtual void * myThingie (void) const final
 
 ServiceBase (FB_SERVICE_OPTIONS options, ServiceBase *parent=nullptr)
 Create a new service with requested options. More...
 
virtual ~ServiceBase () override
 
virtual ConnectionallocNewConnection ()=0
 

Static Protected Member Functions

static ServiceBasegetFromOld (FB_SERVICE *service)
 

Protected Attributes

FB_SERVICEservice
 Pointer to underlying Football service structure. More...
 

Friends

class Iterator
 
class Connection
 
class Arena
 

Detailed Description

C++ Service wrapper Manages the service's connections.

Constructor & Destructor Documentation

◆ ServiceBase()

Football::ServiceBase::ServiceBase ( FB_SERVICE_OPTIONS  options,
ServiceBase parent = nullptr 
)
protected

Create a new service with requested options.

Creates the underlying standard C stuff, and a C++ object that wraps it.

Parameters
optionsThe service options such as ports, behavior settings, etc.
parentA parent service whose service port(s) the child will share.
See also
fb_create_service ()
Here is the call graph for this function:

◆ ~ServiceBase()

Football::ServiceBase::~ServiceBase ( )
overrideprotectedvirtual

Member Function Documentation

◆ allocNewConnection()

virtual Connection* Football::ServiceBase::allocNewConnection ( )
protectedpure virtual

Implemented in Football::Service< Connection >, and Football::Service< PianodConnection >.

Here is the caller graph for this function:

◆ close()

void Football::ServiceBase::close ( void  )

Initiate shutdown of a service.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ conditional_print()

ssize_t Football::ServiceBase::conditional_print ( bool(*)(FB_CONNECTION *)  callback,
const std::string &  message 
)
overridevirtual

Implements Football::Thingie.

Here is the call graph for this function:

◆ getFromOld()

ServiceBase * Football::ServiceBase::getFromOld ( FB_SERVICE service)
staticprotected

Retrieve a C++ service object from the old C-style service structure.

Parameters
serviceThe old standard C service structure.
Returns
The C++ service object.
Here is the caller graph for this function:

◆ myThingie()

virtual void* Football::ServiceBase::myThingie ( void  ) const
inlinefinalprotectedvirtual

Implements Football::Thingie.

Here is the caller graph for this function:

◆ newConnectionFromFile()

Connection * Football::ServiceBase::newConnectionFromFile ( const std::string &  filename)

Create a new "connection" that reads from a file.

Replies to the connection are transparently disposed. An appropriate event is dispatched to the connection when created, but nothing is read from the file yet. The caller may adjust the context or privileges; reading is done by the Arena (service manager) poll routines.

Parameters
filenameThe name of the file to read from.
Returns
An initialized Football::Connection, or NULL on error.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ newLoopbackConnection()

Connection * Football::ServiceBase::newLoopbackConnection ( int *  loopback)

Create a new connection that loops back to the service.

Bidirectional communication is supported. Replies to the connection are transparently disposed. An appropriate event is dispatched to the connection when created, but nothing is read from the file yet. The caller may adjust the context or privileges; reading is done by the Arena (service manager) poll routines.

Parameters
loopbackOn return, set to the socket used for loopback.
Returns
A socket number, or -1 on error.
Here is the call graph for this function:

◆ serviceShutdown()

void Football::ServiceBase::serviceShutdown ( void  )
virtual

Invoked when a service is shutting down.

Corresponds to FB_EVENT_STOPPED; by the time this is received, all connections have been closed.

Reimplemented in PianodService.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Arena

friend class Arena
friend

◆ Connection

friend class Connection
friend

◆ Iterator

friend class Iterator
friend

Member Data Documentation

◆ service

FB_SERVICE* Football::ServiceBase::service
protected

Pointer to underlying Football service structure.


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