1 /* 2 * Copyright (C) 2020 Luciano Iam <oss@lucianoiam.com> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License along 15 * with this program; if not, write to the Free Software Foundation, Inc., 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 */ 18 19 #ifndef _ardour_surface_websockets_state_h_ 20 #define _ardour_surface_websockets_state_h_ 21 22 #include <climits> 23 #include <cmath> 24 #include <cstring> 25 #include <stdint.h> 26 #include <vector> 27 28 #include "typed_value.h" 29 30 #define ADDR_NONE UINT_MAX 31 32 namespace ArdourSurface { 33 34 namespace Node 35 { 36 const std::string strip_description = "strip_description"; 37 const std::string strip_meter = "strip_meter"; 38 const std::string strip_gain = "strip_gain"; 39 const std::string strip_pan = "strip_pan"; 40 const std::string strip_mute = "strip_mute"; 41 const std::string strip_plugin_description = "strip_plugin_description"; 42 const std::string strip_plugin_enable = "strip_plugin_enable"; 43 const std::string strip_plugin_param_description = "strip_plugin_param_description"; 44 const std::string strip_plugin_param_value = "strip_plugin_param_value"; 45 const std::string transport_tempo = "transport_tempo"; 46 const std::string transport_time = "transport_time"; 47 const std::string transport_roll = "transport_roll"; 48 const std::string transport_record = "transport_record"; 49 } // namespace Node 50 51 typedef std::vector<uint32_t> AddressVector; 52 typedef std::vector<TypedValue> ValueVector; 53 54 class NodeState 55 { 56 public: 57 NodeState (); 58 NodeState (std::string); 59 NodeState (std::string, AddressVector, ValueVector = ValueVector ()); 60 61 std::string debug_str () const; 62 node()63 std::string node () const 64 { 65 return _node; 66 } 67 68 int n_addr () const; 69 uint32_t nth_addr (int) const; 70 void add_addr (uint32_t); 71 72 int n_val () const; 73 TypedValue nth_val (int) const; 74 void add_val (TypedValue); 75 76 std::size_t node_addr_hash () const; 77 78 bool operator== (const NodeState& other) const; 79 bool operator< (const NodeState& other) const; 80 81 private: 82 std::string _node; 83 AddressVector _addr; 84 ValueVector _val; 85 }; 86 87 std::size_t 88 hash_value (const NodeState&); 89 90 } // namespace ArdourSurface 91 92 #endif // _ardour_surface_websockets_state_h_ 93