Ardour  9.0-pre0-582-g084a23a80d
uri_map.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-2016 David Robillard <d@drobilla.net>
3  * Copyright (C) 2013-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #pragma once
22 
23 #include <map>
24 
25 #include <glibmm/threads.h>
26 
27 #ifdef HAVE_LV2_1_18_6
28 #include <lv2/core/lv2.h>
29 #include <lv2/urid/urid.h>
30 #else
31 #include <lv2/lv2plug.in/ns/lv2core/lv2.h>
32 #include <lv2/lv2plug.in/ns/ext/urid/urid.h>
33 #endif
34 
36 
37 namespace ARDOUR {
38 
45 public:
46  static URIMap& instance();
47 
48  URIMap();
49  URIMap(const URIMap&) = delete;
50  URIMap& operator=(const URIMap&) = delete;
51 
52  LV2_Feature* urid_map_feature() { return &_urid_map_feature; }
53  LV2_Feature* urid_unmap_feature() { return &_urid_unmap_feature; }
54 
55  LV2_URID_Map* urid_map() { return &_urid_map_feature_data; }
56  LV2_URID_Unmap* urid_unmap() { return &_urid_unmap_feature_data; }
57 
58  uint32_t uri_to_id(const char* uri);
59  const char* id_to_uri(uint32_t id) const;
60 
61  // Cached URIDs for use in real-time code
62  struct URIDs {
63  void init(URIMap& uri_map);
64 
65  uint32_t atom_Chunk;
66  uint32_t atom_Path;
67  uint32_t atom_Sequence;
69  uint32_t atom_URID;
70  uint32_t atom_Blank;
71  uint32_t atom_Object;
72  uint32_t atom_Double;
73  uint32_t atom_Float;
74  uint32_t atom_Long;
75  uint32_t atom_Int;
76  uint32_t log_Error;
77  uint32_t log_Note;
78  uint32_t log_Trace;
79  uint32_t log_Warning;
80  uint32_t midi_MidiEvent;
81  uint32_t time_Position;
82  uint32_t time_bar;
83  uint32_t time_barBeat;
84  uint32_t time_beatUnit;
85  uint32_t time_beatsPerBar;
87  uint32_t time_frame;
88  uint32_t time_speed;
89  uint32_t time_scale;
90  uint32_t patch_Get;
91  uint32_t patch_Set;
92  uint32_t patch_property;
93  uint32_t patch_value;
95 #ifdef LV2_EXTENDED
96  uint32_t auto_event;
97  uint32_t auto_setup;
98  uint32_t auto_finalize;
99  uint32_t auto_start;
100  uint32_t auto_end;
101  uint32_t auto_parameter;
102  uint32_t auto_value;
103  uint32_t surr_MetaData;
104  uint32_t surr_Channel;
105  uint32_t surr_PosX;
106  uint32_t surr_PosY;
107  uint32_t surr_PosZ;
108  uint32_t surr_Size;
109  uint32_t surr_Snap;
110  uint32_t surr_ElevEn;
111  uint32_t surr_Zones;
112  uint32_t surr_Ramp;
113  uint32_t surr_Settings;
122  uint32_t surr_ContentFPS;
125  uint32_t surr_WarpMode;
127  uint32_t surr_ExportStop;
129 #endif
130  };
131 
133 
134 private:
135  typedef std::map<const std::string, uint32_t> Map;
136  typedef std::map<uint32_t, const std::string> Unmap;
137 
140 
141  LV2_Feature _urid_map_feature;
143  LV2_Feature _urid_unmap_feature;
144  LV2_URID_Unmap _urid_unmap_feature_data;
145 
146  mutable Glib::Threads::Mutex _lock;
147 
148  static URIMap* uri_map;
149 };
150 
151 } // namespace ARDOUR
152 
LV2_Feature _urid_map_feature
Definition: uri_map.h:141
URIMap & operator=(const URIMap &)=delete
uint32_t uri_to_id(const char *uri)
URIMap(const URIMap &)=delete
LV2_URID_Unmap _urid_unmap_feature_data
Definition: uri_map.h:144
Glib::Threads::Mutex _lock
Definition: uri_map.h:146
LV2_Feature * urid_map_feature()
Definition: uri_map.h:52
std::map< const std::string, uint32_t > Map
Definition: uri_map.h:135
static URIMap * uri_map
Definition: uri_map.h:148
LV2_Feature * urid_unmap_feature()
Definition: uri_map.h:53
LV2_URID_Map * urid_map()
Definition: uri_map.h:55
URIDs urids
Definition: uri_map.h:132
const char * id_to_uri(uint32_t id) const
LV2_URID_Map _urid_map_feature_data
Definition: uri_map.h:142
std::map< uint32_t, const std::string > Unmap
Definition: uri_map.h:136
Unmap _unmap
Definition: uri_map.h:139
LV2_URID_Unmap * urid_unmap()
Definition: uri_map.h:56
static URIMap & instance()
LV2_Feature _urid_unmap_feature
Definition: uri_map.h:143
#define LIBARDOUR_API
uint32_t surr_ChannelTypes
Definition: uri_map.h:117
uint32_t midi_MidiEvent
Definition: uri_map.h:80
uint32_t auto_start
Definition: uri_map.h:99
uint32_t surr_ChannelDescription
Definition: uri_map.h:116
uint32_t surr_ContentFPS
Definition: uri_map.h:122
uint32_t atom_Int
Definition: uri_map.h:75
uint32_t time_beatUnit
Definition: uri_map.h:84
uint32_t surr_PosY
Definition: uri_map.h:106
uint32_t patch_property
Definition: uri_map.h:92
uint32_t log_Error
Definition: uri_map.h:76
uint32_t surr_BinauralRenderMode
Definition: uri_map.h:114
uint32_t patch_value
Definition: uri_map.h:93
uint32_t patch_Get
Definition: uri_map.h:90
uint32_t atom_Double
Definition: uri_map.h:72
uint32_t time_barBeat
Definition: uri_map.h:83
uint32_t time_frame
Definition: uri_map.h:87
uint32_t atom_Path
Definition: uri_map.h:66
uint32_t surr_Zones
Definition: uri_map.h:111
uint32_t atom_URID
Definition: uri_map.h:69
uint32_t surr_ProgramData
Definition: uri_map.h:119
uint32_t surr_Settings
Definition: uri_map.h:113
uint32_t time_beatsPerBar
Definition: uri_map.h:85
uint32_t auto_parameter
Definition: uri_map.h:101
uint32_t surr_DownmixMode
Definition: uri_map.h:123
uint32_t time_beatsPerMinute
Definition: uri_map.h:86
uint32_t atom_Long
Definition: uri_map.h:74
uint32_t auto_value
Definition: uri_map.h:102
uint32_t surr_ContentStart
Definition: uri_map.h:121
uint32_t time_speed
Definition: uri_map.h:88
uint32_t surr_WarpMode
Definition: uri_map.h:125
uint32_t atom_Chunk
Definition: uri_map.h:65
uint32_t surr_MetaData
Definition: uri_map.h:103
uint32_t surr_ElevEn
Definition: uri_map.h:110
uint32_t patch_Set
Definition: uri_map.h:91
uint32_t surr_ChannelBedIds
Definition: uri_map.h:118
uint32_t auto_setup
Definition: uri_map.h:97
uint32_t surr_ExportStart
Definition: uri_map.h:126
uint32_t log_Note
Definition: uri_map.h:77
void init(URIMap &uri_map)
uint32_t surr_Snap
Definition: uri_map.h:109
uint32_t surr_ContentFFOA
Definition: uri_map.h:120
uint32_t log_Trace
Definition: uri_map.h:78
uint32_t atom_Float
Definition: uri_map.h:73
uint32_t surr_ChannelCount
Definition: uri_map.h:115
uint32_t atom_Sequence
Definition: uri_map.h:67
uint32_t surr_ExportStop
Definition: uri_map.h:127
uint32_t state_StateChanged
Definition: uri_map.h:94
uint32_t time_scale
Definition: uri_map.h:89
uint32_t atom_eventTransfer
Definition: uri_map.h:68
uint32_t surr_PosX
Definition: uri_map.h:105
uint32_t atom_Blank
Definition: uri_map.h:70
uint32_t surr_ReferenceFile
Definition: uri_map.h:128
uint32_t surr_PosZ
Definition: uri_map.h:107
uint32_t auto_finalize
Definition: uri_map.h:98
uint32_t surr_Channel
Definition: uri_map.h:104
uint32_t log_Warning
Definition: uri_map.h:79
uint32_t surr_Ramp
Definition: uri_map.h:112
uint32_t auto_event
Definition: uri_map.h:96
uint32_t surr_Size
Definition: uri_map.h:108
uint32_t surr_OutputFormat
Definition: uri_map.h:124
uint32_t time_Position
Definition: uri_map.h:81
uint32_t time_bar
Definition: uri_map.h:82
uint32_t atom_Object
Definition: uri_map.h:71