hydrogen 1.2.3
AutomationPath.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program 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 General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#ifndef H2C_AUTOMATION_PATH_H
24#define H2C_AUTOMATION_PATH_H
25
26#include <core/Object.h>
27#include <map>
28
29#if __cplusplus <= 199711L
30# define noexcept
31#endif
32
33namespace H2Core
34{
35
37class AutomationPath : public Object<AutomationPath>
38{
40
41 public:
42 typedef std::map<float,float>::iterator iterator;
43 typedef std::map<float,float>::const_iterator const_iterator;
44
45 private:
46
47 float _min;
48 float _max;
49 float _def;
50
51 std::map<float,float> _points;
52
53 public:
54
55 AutomationPath(float min, float max, float def);
56
57 bool empty() const noexcept { return _points.empty(); }
58 float get_min() const noexcept { return _min; }
59 float get_max() const noexcept { return _max; }
60 float get_default() const noexcept { return _def; }
61
62 float get_value(float x) const noexcept;
63
64 void add_point(float x, float y);
65 void remove_point(float x);
66
67 friend bool operator==(const AutomationPath &lhs, const AutomationPath &rhs);
68 friend bool operator!=(const AutomationPath &lhs, const AutomationPath &rhs);
69
70 iterator begin() { return _points.begin(); }
71 iterator end() { return _points.end(); }
72 const_iterator begin() const { return _points.begin(); }
73 const_iterator end() const { return _points.end(); }
74
75 iterator find(float x);
76 iterator move(iterator &in, float x, float y);
77
86 QString toQString( const QString& sPrefix = "", bool bShort = true ) const override;
87};
88};
89
90#endif
#define noexcept
#define H2_OBJECT(name)
Definition Object.h:224
friend bool operator==(const AutomationPath &lhs, const AutomationPath &rhs)
Compare two paths.
std::map< float, float >::iterator iterator
const_iterator begin() const
float get_default() const noexcept
bool empty() const noexcept
AutomationPath(float min, float max, float def)
std::map< float, float > _points
float get_max() const noexcept
std::map< float, float >::const_iterator const_iterator
float get_value(float x) const noexcept
Get value at given location.
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
const_iterator end() const
void remove_point(float x)
Remove point from path.
friend bool operator!=(const AutomationPath &lhs, const AutomationPath &rhs)
iterator move(iterator &in, float x, float y)
Move point to other location.
iterator find(float x)
Find point near specific location.
void add_point(float x, float y)
Add a point to path.
float get_min() const noexcept