comparison layer/LayerFactory.h @ 1324:13d9b422f7fe zoom

Merge from default branch
author Chris Cannam
date Mon, 17 Sep 2018 13:51:31 +0100
parents 43a28a52f8ab
children 9e846af73f3e
comparison
equal deleted inserted replaced
1183:57d192e26331 1324:13d9b422f7fe
11 published by the Free Software Foundation; either version 2 of the 11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file 12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #ifndef _LAYER_FACTORY_H_ 16 #ifndef SV_LAYER_FACTORY_H
17 #define _LAYER_FACTORY_H_ 17 #define SV_LAYER_FACTORY_H
18 18
19 #include <QString> 19 #include <QString>
20 #include <set> 20 #include <set>
21 21
22 class Layer; 22 class Layer;
26 class LayerFactory 26 class LayerFactory
27 { 27 {
28 public: 28 public:
29 enum LayerType { 29 enum LayerType {
30 30
31 // Standard layers 31 // Standard layers
32 Waveform, 32 Waveform,
33 Spectrogram, 33 Spectrogram,
34 TimeRuler, 34 TimeRuler,
35 TimeInstants, 35 TimeInstants,
36 TimeValues, 36 TimeValues,
37 Notes, 37 Notes,
38 FlexiNotes, 38 FlexiNotes,
39 Regions, 39 Regions,
40 Text, 40 Text,
41 Image, 41 Image,
42 Colour3DPlot, 42 Colour3DPlot,
43 Spectrum, 43 Spectrum,
44 Slice, 44 Slice,
45 45
46 // Layers with different initial parameters 46 // Layers with different initial parameters
47 MelodicRangeSpectrogram, 47 MelodicRangeSpectrogram,
48 PeakFrequencySpectrogram, 48 PeakFrequencySpectrogram,
49 49
50 // Not-a-layer-type 50 // Not-a-layer-type
51 UnknownLayer = 255 51 UnknownLayer = 255
52 }; 52 };
53 53
54 static LayerFactory *getInstance(); 54 static LayerFactory *getInstance();
55 55
56 virtual ~LayerFactory(); 56 virtual ~LayerFactory();
87 LayerType getLayerTypeForClipboardContents(const Clipboard &); 87 LayerType getLayerTypeForClipboardContents(const Clipboard &);
88 88
89 protected: 89 protected:
90 template <typename LayerClass, typename ModelClass> 90 template <typename LayerClass, typename ModelClass>
91 bool trySetModel(Layer *layerBase, Model *modelBase) { 91 bool trySetModel(Layer *layerBase, Model *modelBase) {
92 LayerClass *layer = dynamic_cast<LayerClass *>(layerBase); 92 LayerClass *layer = dynamic_cast<LayerClass *>(layerBase);
93 if (!layer) return false; 93 if (!layer) return false;
94 ModelClass *model = dynamic_cast<ModelClass *>(modelBase); 94 ModelClass *model = dynamic_cast<ModelClass *>(modelBase);
95 if (!model) return false; 95 if (!model) return false;
96 layer->setModel(model); 96 layer->setModel(model);
97 return true; 97 return true;
98 } 98 }
99 99
100 static LayerFactory *m_instance; 100 static LayerFactory *m_instance;
101 }; 101 };
102 102