libAlgAudio  v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParamController.hpp
Go to the documentation of this file.
1 #ifndef PARAMCONTROLLER_HPP
2 #define PARAMCONTROLLER_HPP
3 /*
4 This file is part of AlgAudio.
5 
6 AlgAudio, Copyright (C) 2015 CeTA - Audiovisual Technology Center
7 
8 AlgAudio is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
12 
13 AlgAudio is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with AlgAudio. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include <string>
23 #include <memory>
24 #include "ModuleTemplate.hpp"
25 #include "Utilities.hpp"
26 
27 namespace AlgAudio{
28 
29 class Module;
30 
38 public:
39  std::string id;
40  static std::shared_ptr<ParamController> Create(std::shared_ptr<Module> m, const std::shared_ptr<ParamTemplate> templ);
41  void Set(float value);
42  void SetRelative(float value);
43  void Reset();
44  inline float Get() const {return current_val;}
45  float GetRelative() const;
46  inline void SetRangeMin(float v) {
47  range_min = v;
49  //Set(current_val); // Will re-trigger set events with new relative value
50  }
51  inline void SetRangeMax(float v) {
52  range_max = v;
54  //Set(current_val); // Will re-trigger set events with new relative value
55  }
56  inline float GetRangeMin() const {return range_min;}
57  inline float GetRangeMax() const {return range_max;}
58 
66 
69 
70  const std::shared_ptr<ParamTemplate> templ;
71 private:
72  ParamController(std::shared_ptr<Module> m, const std::shared_ptr<ParamTemplate> t);
73  float current_val = 0.0;
74  float range_min = 0.0, range_max = 1.0;
75  std::weak_ptr<Module> module;
76 };
77 
85 public:
86  std::string id;
87  void Got(float v){ controller->Set(v); }
88  static std::shared_ptr<SendReplyController> Create(std::shared_ptr<Module> m, std::string id, std::shared_ptr<ParamController> ctrl);
90 private:
91  SendReplyController(std::shared_ptr<Module> m, std::string id, std::shared_ptr<ParamController> ctrl);
92  int sendreply_id, module_id;
93  std::shared_ptr<ParamController> controller;
94  std::weak_ptr<Module> module;
95 };
96 
97 
98 } // namespace AlgAudio
99 
100 #endif // PARAMCONTROLLER_HPP
Signal< float, float > on_set
Definition: ParamController.hpp:63
void Set(float value)
static std::shared_ptr< ParamController > Create(std::shared_ptr< Module > m, const std::shared_ptr< ParamTemplate > templ)
float GetRelative() const
void SetRelative(float value)
float Get() const
Definition: ParamController.hpp:44
float GetRangeMin() const
Definition: ParamController.hpp:56
const std::shared_ptr< ParamTemplate > templ
Definition: ParamController.hpp:70
void SetRangeMax(float v)
Definition: ParamController.hpp:51
bool Happen(Types...t)
Definition: Signal.hpp:187
void Got(float v)
Definition: ParamController.hpp:87
Definition: Alertable.hpp:26
Definition: ParamController.hpp:84
Signal< float > on_range_max_set
Definition: ParamController.hpp:68
Definition: ParamController.hpp:37
std::string id
Definition: ParamController.hpp:39
Signal< float > on_range_min_set
Definition: ParamController.hpp:67
float GetRangeMax() const
Definition: ParamController.hpp:57
static std::shared_ptr< SendReplyController > Create(std::shared_ptr< Module > m, std::string id, std::shared_ptr< ParamController > ctrl)
void SetRangeMin(float v)
Definition: ParamController.hpp:46
Signal< float, float > after_set
Definition: ParamController.hpp:65
std::string id
Definition: ParamController.hpp:86