userioman.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef USERIOMAN_H
  2. #define USERIOMAN_H
  3. #include "ioman.h"
  4. /**
  5. * @class UserIoMan
  6. *
  7. * Provides specific implementations of IoMan outputs and prompts
  8. * for interactive user sessions
  9. */
  10. class UserIoMan : public IoMan {
  11. private:
  12. /**
  13. * Map containing pointers to the appropriate member functions for printing
  14. * formatted json output
  15. */
  16. map<string, void (UserIoMan::*)(Json::Value)> printmap;
  17. /**
  18. * Class-wide json functionality
  19. */
  20. Json::CharReader *reader;
  21. Json::StreamWriterBuilder wbuilder;
  22. string jsonerror;
  23. /**
  24. * Format and pretty print json for terminal output
  25. */
  26. void printJson(Json::Value root);
  27. /**
  28. * Method prototypes for printing json output
  29. */
  30. /* printing commands go here */
  31. void printError(Json::Value root);
  32. void printConnect(Json::Value root);
  33. void printHelp(Json::Value root);
  34. void printStatus(Json::Value root);
  35. void printDisconnect(Json::Value root);
  36. void printPut(Json::Value root);
  37. void printGet(Json::Value root);
  38. void printList(Json::Value root);
  39. void printVersion(Json::Value root);
  40. void printLogin(Json::Value root);
  41. void printSignup(Json::Value root);
  42. void printPutdata(Json::Value root);
  43. void printGetdata(Json::Value root);
  44. void printListdata(Json::Value root);
  45. void printHead(Json::Value root);
  46. void printDeleteme(Json::Value root);
  47. /**
  48. * Mutex for synchronized message output
  49. */
  50. std::recursive_mutex msgmutex;
  51. public:
  52. /**
  53. * Constructor and destructor
  54. */
  55. UserIoMan(char *ipcstring);
  56. UserIoMan(char *ipcstring, bool usessl);
  57. ~UserIoMan();
  58. protected:
  59. /**
  60. * Specific implementations for printing messages
  61. */
  62. void printMessage(std::string msg, OutMsgType type);
  63. void printWelcomeMessage();
  64. /**
  65. * Return the specific prompt strings for IoMan prompts
  66. */
  67. std::string getCmdPrompt();
  68. std::string getUserPrompt();
  69. std::string getPassPrompt();
  70. };
  71. #endif