NAP
parameterguiservice.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 // External Includes
8 #include <nap/service.h>
9 #include <parameter.h>
10 #include <unordered_map>
11 
12 namespace nap
13 {
19  class NAPAPI ParameterGUIService : public Service
20  {
21  RTTI_ENABLE(Service)
22  public:
27 
44  using CreateParameterEditor = std::function<void(Parameter&)>;
45 
56  void registerParameterEditor(const rtti::TypeInfo& type, const CreateParameterEditor& createParameterEditorFunc);
57 
63  const CreateParameterEditor* findEditor(const nap::Parameter& parameter) const;
64 
70  const CreateParameterEditor* findEditor(rtti::TypeInfo parameterType) const;
71 
72  protected:
78  virtual bool init(nap::utility::ErrorState& errorState) override;
79 
84  virtual void getDependentServices(std::vector<rtti::TypeInfo>& dependencies) override;
85 
86  private:
87  using ParameterEditorMap = std::unordered_map<rtti::TypeInfo, CreateParameterEditor>;
88  ParameterEditorMap mParameterEditors;
89 
93  void registerDefaultParameterEditors();
94  };
95 }
nap::Parameter
Definition: parameter.h:20
nap::ParameterGUIService
Definition: parameterguiservice.h:19
nap::utility::ErrorState
Definition: errorstate.h:19
nap::ServiceConfiguration
Definition: service.h:28
nap::Service
Definition: templateservice.h:8
nap
Definition: templateapp.h:17
nap::ParameterGUIService::CreateParameterEditor
std::function< void(Parameter &)> CreateParameterEditor
Definition: parameterguiservice.h:44
nap::rtti::TypeInfo
rttr::type TypeInfo
Definition: typeinfo.h:140