NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
be_process_worker.h
Go to the documentation of this file.
1/*
2 * This software was developed at the National Institute of Standards and
3 * Technology (NIST) by employees of the Federal Government in the course
4 * of their official duties. Pursuant to title 17 Section 105 of the
5 * United States Code, this software is not subject to copyright protection
6 * and is in the public domain. NIST assumes no responsibility whatsoever for
7 * its use by other parties, and makes no guarantees, expressed or implied,
8 * about its quality, reliability, or any other characteristic.
9 */
10
11#ifndef __BE_PROCESS_WORKER_H__
12#define __BE_PROCESS_WORKER_H__
13
14#include <cstdint>
15
16#include <be_error_exception.h>
17#include <be_memory_autoarray.h>
18#include <be_process.h>
19
20namespace BiometricEvaluation
21{
22 namespace Process
23 {
29 class Worker
30 {
31 public:
51 virtual int32_t
53
67 std::shared_ptr<void>
69 const std::string &name);
70
85 double
87 const std::string &name);
88
103 int64_t
105 const std::string &name);
106
121 std::string
123 const std::string &name);
124
134 void
136 const std::string &name,
137 std::shared_ptr<void> argument);
138
143 virtual void
145 final;
146
158 void
160
172 void
174
188 int
190
204 int
206
219 void
221 const Memory::uint8Array &message);
222
236 void
238 Memory::uint8Array &message);
239
248 void
250
255 virtual ~Worker();
256
257 protected:
263
272 virtual bool
274 const
275 final;
276
289 bool
291 int numSeconds = -1)
292 const;
293
294 private:
296 volatile bool _stopRequested;
297
299 ParameterList _parameters;
300
302 bool _communicationEnabled;
304 int _pipeToChild[2];
306 int _pipeFromChild[2];
307 };
308 }
309}
310
311#endif /* __BE_PROCESS_WORKER_H__ */
An abstraction of an instance that performs work on given data.
void closeManagerPipeEnds()
Perform initialization for communication from Manager to Worker.
void sendMessageToManager(const Memory::uint8Array &message)
Send a message to the Manager.
int getReceivingPipe() const
Obtain the pipe used to receive messages to this Worker.
void _initCommunication()
Perform general communication initialization from Constructor.
std::shared_ptr< void > getParameter(const std::string &name)
Obtain a parameter passed to this Worker.
double getParameterAsDouble(const std::string &name)
Obtain a parameter passed to this Worker as a double.
virtual int32_t workerMain()=0
The method that will get called to start execution by a ProcessManager.
int64_t getParameterAsInteger(const std::string &name)
Obtain a parameter passed to this Worker as an integer.
void setParameter(const std::string &name, std::shared_ptr< void > argument)
Pass a parameter to this Worker.
virtual void stop() final
Tell this Worker to return ASAP.
int getSendingPipe() const
Obtain the pipe used to send messages to this Worker.
void closeWorkerPipeEnds()
Perform initialization for communication from Worker to Manager.
std::string getParameterAsString(const std::string &name)
Obtain a parameter passed to this Worker as a string.
void receiveMessageFromManager(Memory::uint8Array &message)
Receive a message from the Manager.
bool waitForMessage(int numSeconds=-1) const
Block while waiting for a message from the Manager.
virtual bool stopRequested() const final
Determine if the parent has requested this child to exit.
AutoArray< uint8_t > uint8Array
std::map< std::string, std::shared_ptr< void > > ParameterList
Convenience alias for parameter lists to child routines.
Definition: be_process.h:31
This software was developed at the National Institute of Standards and Technology (NIST) by employees...