11#ifndef BE_FRAMEWORK_API_H_
12#define BE_FRAMEWORK_API_H_
48 BE_Framework_APICurrentState_EnumToStringMap);
113 inline explicit operator
138 }
catch (
const std::exception &e) {
169 if (this->currentState !=
172 "No exception handled, "
173 "current state is " +
175 this->currentState)};
176 if (!this->exceptionPtr)
178 "Exception was caught, but "
181 std::rethrow_exception(
194 std::exception_ptr e)
196 this->exceptionPtr = e;
201 std::exception_ptr exceptionPtr{};
243 const std::function<T(
void)> &operation,
244 const std::function<
void(
const Result&)>
246 const std::function<void(
const Result&)>
326 return (this->_rethrowExceptions);
344 const bool shouldRethrow)
346 this->_rethrowExceptions = shouldRethrow;
360 const bool catchExceptions)
362 this->_catchExceptions =
false;
378 return (this->_catchExceptions);
388 inline std::shared_ptr<BiometricEvaluation::Time::Timer>
402 inline std::shared_ptr<
417 inline std::shared_ptr<
427 bool _catchExceptions{
true};
429 bool _rethrowExceptions{
false};
431 std::shared_ptr<BiometricEvaluation::Time::Timer>
434 std::shared_ptr<BiometricEvaluation::Time::Watchdog>
452 _catchExceptions{true},
453 _rethrowExceptions{false},
465 const std::function<T(
void)> &operation,
474 if (this->willCatchExceptions()) {
475 this->getTimer()->start();
479 this->getTimer()->stop();
480 ret.
elapsed = this->getTimer()->elapsed();
488 if (this->_rethrowExceptions)
494 this->getTimer()->start();
497 this->getTimer()->stop();
500 if (this->getSignalManager()->sigHandled()) {
501 this->getTimer()->stop();
502 ret.
elapsed = this->getTimer()->elapsed();
507 }
else if (this->getWatchdog()->expired()) {
508 this->getTimer()->stop();
509 ret.
elapsed = this->getTimer()->elapsed();
516 ret.
elapsed = this->getTimer()->elapsed();
#define END_SIGNAL_BLOCK(_sigmgr, _blockname)
#define BEGIN_SIGNAL_BLOCK(_sigmgr, _blockname)
BE_FRAMEWORK_ENUMERATION_DECLARATIONS(BiometricEvaluation::Framework::APICurrentState, BE_Framework_APICurrentState_EnumToStringMap)
std::string to_string(const BiometricEvaluation::Memory::AutoArray< T > &aa)
Convert a uint8_t or char AutoArray to a string.
#define END_WATCHDOG_BLOCK(_watchdog, _blockname)
#define BEGIN_WATCHDOG_BLOCK(_watchdog, _blockname)
Macros that are used by applications to indicate the start and end of a watchdog timer block.
A SignalManager object is used to handle signals that come from the operating system.
A StrategyError object is thrown when the underlying implementation of this interface encounters an e...
The result of an operation.
APICurrentState currentState
Current state of operation.
bool operator!() const
Logical negation operator overload.
std::string getExceptionStr() const noexcept
Obtain the exception string.
void setException(std::exception_ptr e)
Save a thrown exception.
void rethrowException() const
Rethrow the caught exception.
T status
Value returned from operation.
uint64_t elapsed
Time elapsed while calling operation.
A convenient way to execute biometric technology evaluation API methods safely.
Result call(const std::function< T(void)> &operation, const std::function< void(const Result &)> &success={}, const std::function< void(const Result &)> &failure={})
Invoke an operation.
void setRethrowExceptions(const bool shouldRethrow)
Change whether or not exceptions caught in call() should be rethrown.
bool willCatchExceptions() const
Obtain whether or not exceptions raised in call() will be caught, triggering the failure block.
std::shared_ptr< BiometricEvaluation::Error::SignalManager > getSignalManager() noexcept
Obtain the signal manager object.
std::shared_ptr< BiometricEvaluation::Time::Watchdog > getWatchdog() noexcept
Obtain the watchdog timer object.
void setProtectionsEnabled(const bool protectionsEnabled)
Wholesale change of process protections enabled by this object.
std::shared_ptr< BiometricEvaluation::Time::Timer > getTimer() noexcept
Obtain the timer object.
bool protectionsEnabled() const
Obtain whether or not all protections enabled by this object are enabled.
bool willRethrowExceptions() const
Obtain whether or not exceptions caught in call() will be rethrown.
void setCatchExceptions(const bool catchExceptions)
Set whether or not to catch exceptions from call(), triggering the failure block.
A Watchdog object can be used by applications to limit the amount of processing time taken by a block...
APICurrentState
Reasons operations could not complete.
@ Completed
Operation has returned.
@ ExceptionCaught
An exception was caught.
@ Running
Operation is running.
@ NeverCalled
Operation was never executed.
@ SignalCaught
Signal handler was invoked.
@ WatchdogExpired
Watchdog timer expired.
This software was developed at the National Institute of Standards and Technology (NIST) by employees...