HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
HF::Application Namespace Reference

This namespace contains the declaration of the functions that implement the HAN-FUN example applications. More...

Data Structures

class  Link
 Transport Layer link implementation over TCP/IP using libuv. More...
 
class  Transport
 Transport Layer implementation over TCP/IP using libuv. More...
 

Functions

void Initialize (HF::Transport::Layer &transport)
 Initialize the application. More...
 
bool Handle (std::string command)
 Handle the command. More...
 
void Save ()
 Save application configuration.
 
void Saved ()
 Callback indicating that the application configuration has been saved.
 
void Restore ()
 Restore application configuration.
 
void Restored ()
 Callback indicating that the application configuration has been restored.
 

Detailed Description

This namespace contains the declaration of the functions that implement the HAN-FUN example applications.

Function Documentation

◆ Handle()

bool HF::Application::Handle ( std::string  command)

Handle the command.

Parameters
[in]commandstring containing the command issued by the user.
Return values
truequit command requested,
falseotherwise.

Definition at line 197 of file common.cpp.

References LOG.

198 {
199  LOG(TRACE) << __PRETTY_FUNCTION__ << NL;
200 
201  if (command.empty() || (command.size() == 1 && command[0] == '\n'))
202  {
203  ICommand::help(std::cout);
204  return false;
205  }
206 
207  std::istringstream buf(command);
208  std::istream_iterator<std::string> beg(buf), end;
209 
210  std::vector<std::string> tokens(beg, end);
211 
212  std::string cmd = *tokens.begin();
213 
214  std::vector<std::string> args(tokens.begin() + 1, tokens.end());
215 
216  if (cmd == "q" || cmd == "Q")
217  {
218  return true;
219  }
220  else if (cmd == "h" || cmd == "?")
221  {
222  LOG(APP) << "";
223  ICommand::help(std::cout);
224  }
225  else
226  {
227  ICommand::run(cmd, args);
228  }
229 
230  LOG(APP) << "> " << std::flush;
231 
232  return false;
233 }
virtual void run(std::vector< std::string > &args)=0
Execute the command code.
#define NL
Helper define for new-line and stream clear.
Definition: debug.h:34
#define LOG(X)
Log messages with the level given by X.
Definition: debug.h:81
static std::ostream & help(std::ostream &stream)
Generate the help screen, based on the commands in the registry.
Definition: common.cpp:71