comparison layer/LayerFactory.h @ 1266:a34a2a25907c

Untabify
author Chris Cannam
date Thu, 01 Mar 2018 18:02:22 +0000
parents b12cd1c2dad5
children 43a28a52f8ab
comparison
equal deleted inserted replaced
1265:6e724c81f18f 1266:a34a2a25907c
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