NAP
parameterservice.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local Includes
8 #include "parametergroup.h"
9 
10 // External Includes
11 #include <nap/service.h>
12 #include <nap/resourceptr.h>
13 #include <nap/signalslot.h>
14 
15 namespace nap
16 {
20  class NAPAPI ParameterService : public Service
21  {
22  RTTI_ENABLE(Service)
23 
24  public:
25  using PresetFileList = std::vector<std::string>;
26  ParameterService(ServiceConfiguration* configuration);
27 
32  PresetFileList getPresets(const ParameterGroup& group) const;
33 
44  bool loadPreset(ParameterGroup& group, const std::string& presetFile, utility::ErrorState& errorState);
45 
55  bool savePreset(ParameterGroup& group, const std::string& presetFile, utility::ErrorState& errorState);
56 
63  std::string getPresetPath(const std::string& groupID, const std::string& filename) const;
64 
71  std::string getGroupPresetDirectory(const std::string& groupID) const;
72 
77 
78 
83 
84  protected:
88  virtual void postResourcesLoaded() override;
89 
90  private:
91 
98  void setParametersRecursive(const ParameterGroup& sourceParameters, ParameterGroup& destinationParameters);
99  };
100 
101 
107  {
108  RTTI_ENABLE(ServiceConfiguration)
109  public:
110 
114  virtual rtti::TypeInfo getServiceType() const override
115  {
116  return RTTI_OF(ParameterService);
117  }
118 
119  public:
120  std::string mPresetsDirectory = "Presets";
121  };
122 }
nap::ParameterService
Definition: parameterservice.h:20
nap::ParameterServiceConfiguration
Definition: parameterservice.h:106
nap::utility::ErrorState
Definition: errorstate.h:19
nap::ServiceConfiguration
Definition: service.h:28
nap::ParameterService::fileLoaded
nap::Signal fileLoaded
Definition: parameterservice.h:82
nap::Signal
Definition: signalslot.h:28
nap::ParameterService::PresetFileList
std::vector< std::string > PresetFileList
Definition: parameterservice.h:25
nap::Service
Definition: templateservice.h:8
nap
Definition: templateapp.h:17
nap::ParameterService::presetLoaded
nap::Signal presetLoaded
Definition: parameterservice.h:76
nap::rtti::TypeInfo
rttr::type TypeInfo
Definition: typeinfo.h:140
nap::Group
Definition: group.h:83
nap::ParameterServiceConfiguration::getServiceType
virtual rtti::TypeInfo getServiceType() const override
Definition: parameterservice.h:114