NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
Public Member Functions | Protected Member Functions | List of all members
BiometricEvaluation::Process::Worker Class Referenceabstract

An abstraction of an instance that performs work on given data. More...

#include <be_process_worker.h>

Inherited by BiometricEvaluation::Process::MessageCenterListener, and BiometricEvaluation::Process::MessageCenterReceiver.

Public Member Functions

virtual int32_t workerMain ()=0
 The method that will get called to start execution by a ProcessManager. More...
 
std::shared_ptr< void > getParameter (const std::string &name)
 Obtain a parameter passed to this Worker. More...
 
double getParameterAsDouble (const std::string &name)
 Obtain a parameter passed to this Worker as a double. More...
 
int64_t getParameterAsInteger (const std::string &name)
 Obtain a parameter passed to this Worker as an integer. More...
 
std::string getParameterAsString (const std::string &name)
 Obtain a parameter passed to this Worker as a string. More...
 
void setParameter (const std::string &name, std::shared_ptr< void > argument)
 Pass a parameter to this Worker. More...
 
virtual void stop () final
 Tell this Worker to return ASAP. More...
 
void closeWorkerPipeEnds ()
 Perform initialization for communication from Worker to Manager. More...
 
void closeManagerPipeEnds ()
 Perform initialization for communication from Manager to Worker. More...
 
int getSendingPipe () const
 Obtain the pipe used to send messages to this Worker. More...
 
int getReceivingPipe () const
 Obtain the pipe used to receive messages to this Worker. More...
 
void sendMessageToManager (const Memory::uint8Array &message)
 Send a message to the Manager. More...
 
void receiveMessageFromManager (Memory::uint8Array &message)
 Receive a message from the Manager. More...
 
void _initCommunication ()
 Perform general communication initialization from Constructor. More...
 
virtual ~Worker ()
 Worker destructor. More...
 

Protected Member Functions

 Worker ()
 Worker constructor. More...
 
virtual bool stopRequested () const final
 Determine if the parent has requested this child to exit. More...
 
bool waitForMessage (int numSeconds=-1) const
 Block while waiting for a message from the Manager. More...
 

Detailed Description

An abstraction of an instance that performs work on given data.

Definition at line 29 of file be_process_worker.h.

Constructor & Destructor Documentation

◆ ~Worker()

virtual BiometricEvaluation::Process::Worker::~Worker ( )
virtual

Worker destructor.

◆ Worker()

BiometricEvaluation::Process::Worker::Worker ( )
protected

Worker constructor.

Member Function Documentation

◆ workerMain()

virtual int32_t BiometricEvaluation::Process::Worker::workerMain ( )
pure virtual

The method that will get called to start execution by a ProcessManager.

Returns
Status code.
Note
If an object of this class is added to a Process::ForkManager object, the implementation of Process::Worker::workerMain() should release all resources prior to returning.
Any exceptions thrown by this method will cause the worker to exit with a return status of EXIT_FAILURE. The type and contents of the exception is not maintained.

Implemented in BiometricEvaluation::Process::MessageCenterListener, and BiometricEvaluation::Process::MessageCenterReceiver.

◆ getParameter()

std::shared_ptr< void > BiometricEvaluation::Process::Worker::getParameter ( const std::string &  name)

Obtain a parameter passed to this Worker.

Parameters
nameThe parameter name to retrieve.
Returns
shared_ptr to the parameter argument.
Exceptions
std::out_of_rangename was not set.

◆ getParameterAsDouble()

double BiometricEvaluation::Process::Worker::getParameterAsDouble ( const std::string &  name)

Obtain a parameter passed to this Worker as a double.

Parameters
nameThe parameter name to retrieve.
Returns
Parameter as a double.
Exceptions
std::out_of_rangename was not set.

◆ getParameterAsInteger()

int64_t BiometricEvaluation::Process::Worker::getParameterAsInteger ( const std::string &  name)

Obtain a parameter passed to this Worker as an integer.

Parameters
nameThe parameter name to retrieve.
Returns
Parameter as an integer.
Exceptions
std::out_of_rangename was not set.

◆ getParameterAsString()

std::string BiometricEvaluation::Process::Worker::getParameterAsString ( const std::string &  name)

Obtain a parameter passed to this Worker as a string.

Parameters
nameThe parameter name to retrieve.
Returns
Parameter as a string.
Exceptions
std::out_of_rangename was not set.

◆ setParameter()

void BiometricEvaluation::Process::Worker::setParameter ( const std::string &  name,
std::shared_ptr< void >  argument 
)

Pass a parameter to this Worker.

Parameters
nameA unique identifier for this parameter
argumentA shared_ptr to the object to store.

◆ stop()

virtual void BiometricEvaluation::Process::Worker::stop ( )
finalvirtual

Tell this Worker to return ASAP.

◆ closeWorkerPipeEnds()

void BiometricEvaluation::Process::Worker::closeWorkerPipeEnds ( )

Perform initialization for communication from Worker to Manager.

Note
Behavior is undefined if called by a non-Manager.
Exceptions
Error::StrategyErrorCommunications not enabled.

◆ closeManagerPipeEnds()

void BiometricEvaluation::Process::Worker::closeManagerPipeEnds ( )

Perform initialization for communication from Manager to Worker.

Note
Behavior is undefined if called by a non-Worker.
Exceptions
Error::StrategyErrorCommunications not enabled.

◆ getSendingPipe()

int BiometricEvaluation::Process::Worker::getSendingPipe ( ) const

Obtain the pipe used to send messages to this Worker.

Returns
Sending pipe.
Exceptions
Error::ObjectDoesNotExistWorker exiting soon, communication disabled.
Error::StrategyErrorCommunications not enabled.

◆ getReceivingPipe()

int BiometricEvaluation::Process::Worker::getReceivingPipe ( ) const

Obtain the pipe used to receive messages to this Worker.

Returns
Receiving pipe.
Exceptions
Error::ObjectDoesNotExistWorker exiting soon, communication disabled.
Error::StrategyErrorCommunications not enabled.

◆ sendMessageToManager()

void BiometricEvaluation::Process::Worker::sendMessageToManager ( const Memory::uint8Array message)

Send a message to the Manager.

Parameters
[in]messageMessage to send.
Exceptions
Error::ObjectDoesNotExistWidowed pipe.
Error::StrategyErrorCommunications not enabled.

◆ receiveMessageFromManager()

void BiometricEvaluation::Process::Worker::receiveMessageFromManager ( Memory::uint8Array message)

Receive a message from the Manager.

Parameters
[out]messageBuffer to store the received message.
Exceptions
Error::ObjectDoesNotExistWidowed pipe.
Error::StrategyErrorCommunications not enabled.
See also
waitForMessage

◆ _initCommunication()

void BiometricEvaluation::Process::Worker::_initCommunication ( )

Perform general communication initialization from Constructor.

Exceptions
Error::StrategyErrorError in initialization.

◆ stopRequested()

virtual bool BiometricEvaluation::Process::Worker::stopRequested ( ) const
finalprotectedvirtual

Determine if the parent has requested this child to exit.

Returns
Whether or not this child should exit.

◆ waitForMessage()

bool BiometricEvaluation::Process::Worker::waitForMessage ( int  numSeconds = -1) const
protected

Block while waiting for a message from the Manager.

Parameters
numSecondsNumber of seconds to wait for a message, or any value < 0 to wait forever.
Returns
true once a message is ready to be read or false if an error occured.

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