ewmscp  ..
Classes | Public Member Functions | Private Attributes | Static Private Attributes | List of all members
commandSender Class Reference

class used to send messages via stdout. More...

Collaboration diagram for commandSender:
[legend]

Classes

class  flushDomain
 class to flush output on scope basis. More...
 

Public Member Functions

 commandSender ()
 
void sendCommand (const char *command, std::chrono::system_clock::time_point when, const std::string &path)
 
void sendCommand (const char *command, std::chrono::system_clock::time_point when, const std::string &path1, const std::string &path2)
 
void flush ()
 
void keepalive ()
 

Private Attributes

char delimiter
 
clock_type::time_point lastSendTime
 
bool needFlush
 

Static Private Attributes

static options::single< bool > nullDelimiter
 
static options::single< unsigned > keepaliveTimeout
 

Detailed Description

class used to send messages via stdout.

Makes sure uniform format is produced for all messages, heelps to create keepalive messages

Definition at line 591 of file inotify_watch.cpp.

Constructor & Destructor Documentation

◆ commandSender()

commandSender::commandSender ( )
inline

Definition at line 598 of file inotify_watch.cpp.

598  {
599  delimiter = nullDelimiter ? '\0' : '\n';
600  std::cout << std::fixed; // proper format for time stamps
601  }

References delimiter, and nullDelimiter.

Member Function Documentation

◆ flush()

void commandSender::flush ( )
inline

Definition at line 613 of file inotify_watch.cpp.

613  {
614  std::cout.flush();
615  }

Referenced by keepalive(), and commandSender::flushDomain::~flushDomain().

Here is the caller graph for this function:

◆ keepalive()

void commandSender::keepalive ( )
inline

Definition at line 616 of file inotify_watch.cpp.

616  {
617  auto now = clock_type::now();
618  if (now - lastSendTime > std::chrono::seconds(keepaliveTimeout)) {
619  sendCommand("ig", now, "keepalive");
620  flush();
621  }
622  }

References flush(), keepaliveTimeout, lastSendTime, and sendCommand().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendCommand() [1/2]

void commandSender::sendCommand ( const char *  command,
std::chrono::system_clock::time_point  when,
const std::string &  path 
)
inline

Definition at line 602 of file inotify_watch.cpp.

603  {
604  std::cout << command << ' ' << when << ' ' << path << delimiter;
605  lastSendTime = when;
606  needFlush = true;
607  }

References delimiter, lastSendTime, and needFlush.

Referenced by keepalive(), main(), and sendCommand().

Here is the caller graph for this function:

◆ sendCommand() [2/2]

void commandSender::sendCommand ( const char *  command,
std::chrono::system_clock::time_point  when,
const std::string &  path1,
const std::string &  path2 
)
inline

Definition at line 608 of file inotify_watch.cpp.

609  {
610  sendCommand(command, when, path1);
611  std::cout << path2 << delimiter;
612  }

References delimiter, and sendCommand().

Here is the call graph for this function:

Member Data Documentation

◆ delimiter

char commandSender::delimiter
private

Definition at line 594 of file inotify_watch.cpp.

Referenced by commandSender(), and sendCommand().

◆ keepaliveTimeout

options::single<unsigned> commandSender::keepaliveTimeout
staticprivate

Definition at line 593 of file inotify_watch.cpp.

Referenced by keepalive().

◆ lastSendTime

clock_type::time_point commandSender::lastSendTime
private

Definition at line 595 of file inotify_watch.cpp.

Referenced by keepalive(), and sendCommand().

◆ needFlush

bool commandSender::needFlush
private

◆ nullDelimiter

options::single<bool> commandSender::nullDelimiter
staticprivate

Definition at line 592 of file inotify_watch.cpp.

Referenced by commandSender().


The documentation for this class was generated from the following file:
commandSender::nullDelimiter
static options::single< bool > nullDelimiter
Definition: inotify_watch.cpp:592
commandSender::sendCommand
void sendCommand(const char *command, std::chrono::system_clock::time_point when, const std::string &path)
Definition: inotify_watch.cpp:602
commandSender::flush
void flush()
Definition: inotify_watch.cpp:613
commandSender::keepaliveTimeout
static options::single< unsigned > keepaliveTimeout
Definition: inotify_watch.cpp:593
commandSender::needFlush
bool needFlush
Definition: inotify_watch.cpp:596
commandSender::lastSendTime
clock_type::time_point lastSendTime
Definition: inotify_watch.cpp:595
commandSender::delimiter
char delimiter
Definition: inotify_watch.cpp:594