You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

patch.hpp 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include <jansson.h>
  3. #include <common.hpp>
  4. namespace rack {
  5. /** Handles the Rack patch file state */
  6. namespace patch {
  7. /** Handles the Rack patch file state. */
  8. struct Manager {
  9. struct Internal;
  10. Internal* internal;
  11. /** The currently loaded patch file path */
  12. std::string path;
  13. /** Path to autosave dir */
  14. std::string autosavePath;
  15. /** Path to user template patch */
  16. std::string templatePath;
  17. /** Path to factory template patch */
  18. std::string factoryTemplatePath;
  19. /** Append to this while loading/saving a patch to display messages to the user after success. */
  20. std::string warningLog;
  21. PRIVATE Manager();
  22. PRIVATE ~Manager();
  23. PRIVATE void launch(std::string pathArg);
  24. /** Clears the patch. */
  25. void clear();
  26. /** Saves the patch and nothing else. */
  27. void save(std::string path);
  28. void saveDialog();
  29. void saveAsDialog(bool setPath = true);
  30. void saveTemplateDialog();
  31. void saveAutosave();
  32. /** Delete and re-create autosave dir. */
  33. void clearAutosave();
  34. /** Clean up nonexistent module patch storage dirs in autosave dir. */
  35. void cleanAutosave();
  36. /** Loads a patch and nothing else.
  37. Returns whether the patch was loaded successfully.
  38. */
  39. void load(std::string path);
  40. /** Loads the template patch. */
  41. void loadTemplate();
  42. void loadTemplateDialog();
  43. bool hasAutosave();
  44. void loadAutosave();
  45. /** Loads a patch, sets the current path, and updates the recent patches. */
  46. void loadAction(std::string path);
  47. void loadDialog();
  48. void loadPathDialog(std::string path);
  49. /** Asks the user to reload the current patch. */
  50. void revertDialog();
  51. void pushRecentPath(std::string path);
  52. /** Disconnects all cables. */
  53. void disconnectDialog();
  54. json_t* toJson();
  55. void fromJson(json_t* rootJ);
  56. void log(std::string msg);
  57. };
  58. } // namespace patch
  59. } // namespace rack