userioman.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. bool verbose;
  24. /**
  25. * Format and pretty print json for terminal output
  26. */
  27. void printJson(Json::Value root);
  28. /**
  29. * Method prototypes for printing json output
  30. */
  31. /* printing commands go here */
  32. void printError(Json::Value root);
  33. void printConnect(Json::Value root);
  34. void printHelp(Json::Value root);
  35. void printStatus(Json::Value root);
  36. void printExtendedstatus(Json::Value root);
  37. void printDisconnect(Json::Value root);
  38. void printPut(Json::Value root);
  39. void printGet(Json::Value root);
  40. void printList(Json::Value root);
  41. void printExtendedlist(Json::Value root);
  42. void printVersion(Json::Value root);
  43. void printLogin(Json::Value root);
  44. void printSignup(Json::Value root);
  45. void printPutdata(Json::Value root);
  46. void printGetdata(Json::Value root);
  47. void printListdata(Json::Value root);
  48. void printHead(Json::Value root);
  49. void printDeletefile(Json::Value root);
  50. void printQueue(Json::Value root);
  51. void printDequeue(Json::Value root);
  52. void printDeleteme(Json::Value root);
  53. void printKeyfile(Json::Value root);
  54. void printClosekey(Json::Value root);
  55. void printNotifications(Json::Value root);
  56. /**
  57. * Mutex for synchronized message output
  58. */
  59. std::mutex msgmutex;
  60. public:
  61. /**
  62. * Constructor and destructor
  63. */
  64. UserIoMan(bool usessl, const char *certfile, bool verbose);
  65. ~UserIoMan();
  66. protected:
  67. /**
  68. * Specific implementations for printing messages
  69. */
  70. void printMessage(std::string msg, OutMsgType type);
  71. void printWelcomeMessage();
  72. /**
  73. * Return the specific prompt strings for IoMan prompts
  74. */
  75. std::string getCmdPrompt();
  76. };
  77. #endif