OpenDaVINCI  4.15.3
odcore::base::Service Class Referenceabstract

#include <Service.h>

Inheritance diagram for odcore::base::Service:
Inheritance graph

Public Member Functions

 Service () throw (exceptions::ThreadException)
 
virtual ~Service ()
 
void start ()
 
void stop ()
 
void serviceReady ()
 

Protected Member Functions

virtual void beforeStop ()=0
 
virtual void run ()=0
 
virtual bool isRunning ()
 

Detailed Description

This class combines wrapper::Runnable and wrapper::Thread for convenience:

class MyService : public Service {
virtual void beforeStop() {
// This block is executed right before the thread will be stopped.
}
virtual void run() {
// Do some initialization
// Do something.
}
};
int32_t main(int32_t argc, char **argv) {
MyService s;
s.start();
s.stop();
}

Constructor & Destructor Documentation

odcore::base::Service::Service ( )
throw (exceptions::ThreadException
)
odcore::base::Service::~Service ( )
virtual

Member Function Documentation

virtual void odcore::base::Service::beforeStop ( )
protectedpure virtual

This method is called right before this service gets stopped.

Implemented in odcontext::base::TimeTriggeredConferenceClientModuleRunner.

bool odcore::base::Service::isRunning ( )
protectedvirtual

This method returns true, iff this runnable is in its internal state for running.

Returns
true iff this runnable is in its internal state for running.

Implements odcore::wrapper::Runnable.

virtual void odcore::base::Service::run ( )
protectedpure virtual

This method implements the body of the function to be "threadified".

Implements odcore::wrapper::Runnable.

Implemented in odcontext::base::TimeTriggeredConferenceClientModuleRunner.

void odcore::base::Service::serviceReady ( )

This method has to be called by the run() method to unblock the start() method when the service is fully initialized.

Referenced by odcontext::base::TimeTriggeredConferenceClientModuleRunner::run().

void odcore::base::Service::start ( )

This method starts the service and will block the calling thread until serviceReady() is called.

Referenced by odcontext::base::TimeTriggeredConferenceClientModuleRunner::step(), and odcore::io::udp::UDPReceiver::UDPReceiver().

void odcore::base::Service::stop ( )

This method stops the service. A stopped service CANNOT get restarted.

Referenced by odcore::io::PacketPipeline::~PacketPipeline(), and odcore::io::udp::UDPReceiver::~UDPReceiver().