command.h
Go to the documentation of this file.
1 
6 #pragma once
7 #include <string>
8 #include <boost/function.hpp>
9 #include <boost/thread.hpp>
10 #ifdef TESTING
11 #include "gtest/gtest.h"
12 #endif
13 
19 {
22 };
23 
32 typedef boost::function<void(BgCommandStatus status, const std::string& line, int exit_code)> bg_command_status_handler_function;
33 
40 class Command
41 {
42 public:
43  Command();
44  static std::string GetStdoutFromCommand(std::string cmd);
45  static int GetExternalProcessId( std::string name );
46  static int executeCommand(const std::string &cmd);
47  static void GetStdoutFromBackgroundCommand(bg_command_status_handler_function handler, const std::string& binaryFile);
48  static FILE* myPopen(const char *command, const char *type);
49  virtual ~Command();
50 private:
51 
52  static void runBackgroundCommand(bg_command_status_handler_function handler, const std::string& binaryFile);
53 
54 #ifdef TESTING
55 public:
56  FRIEND_TEST(Command_test,myPopenError);
57  FRIEND_TEST(Command_test,myPopenCorrect);
58 
59 #endif //TESTING
60 };
boost::function< void(BgCommandStatus status, const std::string &line, int exit_code)> bg_command_status_handler_function
Handler for background command status function callback.
Definition: command.h:32
Definition: command.h:21
Definition: command.h:20
Executes commands.
Definition: command.h:40
BgCommandStatus
Definition: command.h:18