11#ifndef __BE_PROCESS_COMMANDCENTER_H__
12#define __BE_PROCESS_COMMANDCENTER_H__
30 typename =
typename std::enable_if<std::is_enum<T>::value>>
46 static_assert(std::is_enum<T>::value,
47 "Invalid templatization of CommandCenter.");
82 return (this->_messageCenter.
107 std::string invalidCommandResponse =
"")
111 command.
clientID, buffer, numSeconds))
124 i = Text::trimWhitespace(i);
129 command.
command = BiometricEvaluation::
130 Framework::Enumeration::to_enum<T>(
137 if (invalidCommandResponse !=
"")
140 invalidCommandResponse);
142 static const std::string
144 "command not recognized";
174 const std::string &response,
175 const std::string prefix =
">> ",
176 const std::string suffix =
"\n")
180 prefix + response + suffix);
206 template <
typename T>
242 command, numSeconds, this->
getUsage()));
257 const std::string &usage)
259 this->_usage = usage;
267 return (this->_usage);
std::string to_string(const BiometricEvaluation::Memory::AutoArray< T > &aa)
Convert a uint8_t or char AutoArray to a string.
The named object does not exist.
Parsed command received from the network.
T command
Enumeration value of the command.
std::vector< std::string > arguments
Arguments passed to command (optional).
uint32_t clientID
ID of the sender.
Receive enumerations as commands over the network.
CommandCenter(uint16_t port=MessageCenter::DEFAULT_PORT)
Constructor.
void sendResponse(uint32_t clientID, const std::string &response, const std::string prefix=">> ", const std::string suffix="\n")
Send a string response to a client.
void disconnectClient(uint32_t clientID)
Break the connection with a client.
bool getNextCommand(Command &command, int numSeconds=-1, std::string invalidCommandResponse="")
Get the next command.
bool hasPendingCommands()
Determine if there are commands waiting.
~CommandCenter()=default
Destructor (default).
Abstraction to parse messages received via CommandCenter.
CommandParser(uint16_t port=MessageCenter::DEFAULT_PORT)
Constructor.
std::string getUsage() const
virtual void parse(const typename CommandCenter< T >::Command &command)=0
Parse command.
bool getNextCommand(typename CommandCenter< T >::Command &command, int numSeconds=-1)
Get the next command.
void setUsage(const std::string &usage)
String sent when an invalid command is received.
virtual ~CommandParser()=default
Virtual destructor (default).
Convenience for asynchronous TCP socket message passing.
void disconnectClient(uint32_t clientID)
Break the connection with a client.
bool getNextMessage(uint32_t &clientID, Memory::uint8Array &message, int numSeconds=-1)
Get the next available message.
static const uint16_t DEFAULT_PORT
Default port used for messages.
void sendResponse(uint32_t clientID, const Memory::uint8Array &message) const
Send a message to a client.
void setString(AutoArray< T > &aa, const std::string &str)
Copy a string into an AutoAray of uint8_t or char.
std::vector< std::string > split(const std::string &str, const char delimiter, bool escape=true)
Return tokens bound by delimiters and the beginning and end of a string.
This software was developed at the National Institute of Standards and Technology (NIST) by employees...