director.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef DIRECTOR_H
  2. #define DIRECTOR_H
  3. #include <functional>
  4. #include <string>
  5. typedef std::function<void(const std::string &)> stringFunc;
  6. struct OldValues {
  7. stringFunc server_line;
  8. stringFunc server_prompt;
  9. stringFunc client_input;
  10. bool to_client;
  11. };
  12. class Director;
  13. #include "session.h"
  14. #include "dispatchers.h"
  15. class Director {
  16. private:
  17. Session &session;
  18. public:
  19. Director(Session &);
  20. void server_line(const std::string &line);
  21. void server_prompt(const std::string &prompt);
  22. void client_input(const std::string &input);
  23. // These would be called by the Dispatch --
  24. // since it has direct access to us.
  25. void to_server(const std::string &send);
  26. void to_client(const std::string &send);
  27. const std::string &get_prompt(void);
  28. void set_server_line(stringFunc new_sl);
  29. void set_server_prompt(stringFunc new_sp);
  30. void set_client_input(stringFunc new_ci);
  31. OldValues get_state(void); // save state and reset to blanks/nullptr
  32. void restore_state(OldValues);
  33. private:
  34. stringFunc server_line_;
  35. stringFunc server_prompt_;
  36. stringFunc client_input_;
  37. bool to_client_; // Send server input to the client
  38. // bool client_to_server; // WHEN would I ever have the client talking
  39. // directly to the server? [NEVER]
  40. };
  41. #endif