AvCasterStore.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*\
  2. |*| Copyright 2015-2016 bill-auger <https://github.com/bill-auger/av-caster/issues>
  3. |*|
  4. |*| This file is part of the AvCaster program.
  5. |*|
  6. |*| AvCaster is free software: you can redistribute it and/or modify
  7. |*| it under the terms of the GNU General Public License version 3
  8. |*| as published by the Free Software Foundation.
  9. |*|
  10. |*| AvCaster is distributed in the hope that it will be useful,
  11. |*| but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. |*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. |*| GNU General Public License for more details.
  14. |*|
  15. |*| You should have received a copy of the GNU General Public License
  16. |*| along with AvCaster. If not, see <http://www.gnu.org/licenses/>.
  17. \*/
  18. #ifndef _AVCASTERSTORE_H_
  19. #define _AVCASTERSTORE_H_
  20. #include "../Constants/Constants.h"
  21. /**
  22. AvCasterStore is the model class for the AvCaster application.
  23. It holds the runtime configuration via shared value holders
  24. and handles persistence via JUCE binary storage.
  25. */
  26. class AvCasterStore : ValueTree::Listener
  27. {
  28. friend class AvCaster ;
  29. public:
  30. ~AvCasterStore() ;
  31. // class helpers
  32. static StringArray PropertyValues(ValueTree root_node , Identifier property_id) ;
  33. private:
  34. // initialize
  35. AvCasterStore() ;
  36. // validations
  37. void verifyConfig () ;
  38. void verifyRoot () ;
  39. void verifyPresets () ;
  40. void verifyPreset () ;
  41. void verifyNetworks () ;
  42. void verifyNetwork (ValueTree a_network_node) ;
  43. void sanitizeRoot () ;
  44. void sanitizePresets () ;
  45. void sanitizePreset () ;
  46. void verifyChildNode (ValueTree config_store , Identifier a_node_id) ;
  47. void verifyPresetChildNode (Identifier a_node_id) ;
  48. void verifyProperty (ValueTree config_store , Identifier a_key ,
  49. var a_default_value ) ;
  50. void verifyRootProperty (Identifier a_key , var a_default_value) ;
  51. void verifyNetworkProperty (Identifier a_key , var a_default_value) ;
  52. void verifyPresetProperty (Identifier a_key , var a_default_value) ;
  53. void restoreStaticPresets () ;
  54. bool hasDuplicatedNodes (ValueTree stored_config) ;
  55. int nDuplicatedNodes (ValueTree parent_node , StringArray node_ids) ;
  56. void removeConflictedNodes (ValueTree parent_node , Identifier node_id) ;
  57. void filterRogueKeys (ValueTree parent_node , StringArray persistent_keys) ;
  58. void filterRogueNodes (ValueTree parent_node , StringArray persistent_node_ids) ;
  59. void sanitizeIntProperty (ValueTree config_store , Identifier a_key ,
  60. int min_value , int max_value ) ;
  61. void sanitizeRootComboProperty (Identifier a_key , StringArray options) ;
  62. void sanitizePresetComboProperty(Identifier a_key , StringArray options) ;
  63. void restoreTransients () ;
  64. void restorePresetTransients (ValueTree a_preset_store) ;
  65. // persistence
  66. ValueTree loadConfig() ;
  67. void storeConfig () ;
  68. void loadPreset () ;
  69. void storePreset (String preset_name) ;
  70. void renamePreset(String preset_name) ;
  71. void deletePreset() ;
  72. void resetPreset () ;
  73. // runtime params
  74. // void detectDisplayDimensions () ;
  75. void detectCaptureDevices () ;
  76. // event handlers
  77. void listen (bool should_listen) ;
  78. void valueTreePropertyChanged(ValueTree& a_node , const Identifier& key) override ;
  79. // unused ValueTree::Listener interface implementations
  80. void valueTreeChildAdded (ValueTree& /*a_parent_node*/ , ValueTree& /*a_node*/ ) override {}
  81. void valueTreeChildRemoved (ValueTree& /*a_parent_node*/ , ValueTree& /*a_node*/ , int /*idx*/ ) override {}
  82. void valueTreeChildOrderChanged(ValueTree& /*a_parent_node*/ , int /*prev_idx*/ , int /*curr_idx*/) override {}
  83. void valueTreeParentChanged (ValueTree& /*a_node*/ ) override {}
  84. void valueTreeRedirected (ValueTree& /*a_node*/ ) override {}
  85. // getters/setters
  86. bool isMediaToggleKey (const Identifier& a_key) ;
  87. bool isPresetConfigKey (const Identifier& a_key) ;
  88. void deactivateControl (const Identifier& a_key) ;
  89. bool isKnownProperty (ValueTree a_node , const Identifier& a_key) ;
  90. void setProperty (ValueTree a_node , const Identifier& a_key ,
  91. const var a_value ) ;
  92. void setValue (ValueTree storage_node , const Identifier& a_key ,
  93. const var a_value ) ;
  94. void setValueViaGui (ValueTree storage_node , const Identifier& a_key ,
  95. const var a_value ) ;
  96. void updateChatters (StringArray nicks) ;
  97. StringArray presetsNames () ;
  98. StringArray cameraNames () ;
  99. StringArray audioNames () ;
  100. ValueTree getCameraStore () ;
  101. StringArray getCameraResolutions() ;
  102. StringArray getChatNicks () ;
  103. // configuration/persistence
  104. ValueTree root ; // persistent static config (STORAGE_ID node )
  105. ValueTree presets ; // persistent dynamic config (PRESETS_ID node )
  106. ValueTree config ; // volatile media config (VOLATILE_CONFIG_ID node)
  107. ValueTree network ; // volatile network config (NETWORK_ID node )
  108. ValueTree chatters ; // volatile nicks list (CHATTERS_ID node )
  109. ValueTree cameras ; // video devices info (CAMERA_DEVICES_ID node )
  110. ValueTree audios ; // audio devices info (AUDIO_DEVICES_ID node )
  111. File storageDir ;
  112. File storageFile ;
  113. } ;
  114. #endif // _AVCASTERSTORE_H_