Mercurial > hg > svgui
comparison layer/LayerFactory.h @ 0:2a4f26e85b4c
initial import
author | Chris Cannam |
---|---|
date | Tue, 10 Jan 2006 16:33:16 +0000 |
parents | |
children | 37b110168acf |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2a4f26e85b4c |
---|---|
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 A waveform viewer and audio annotation editor. | |
5 Chris Cannam, Queen Mary University of London, 2005 | |
6 | |
7 This is experimental software. Not for distribution. | |
8 */ | |
9 | |
10 #ifndef _LAYER_FACTORY_H_ | |
11 #define _LAYER_FACTORY_H_ | |
12 | |
13 #include <QString> | |
14 #include <set> | |
15 | |
16 class Layer; | |
17 class View; | |
18 class Model; | |
19 | |
20 class LayerFactory | |
21 { | |
22 public: | |
23 enum LayerType { | |
24 | |
25 // Standard layers | |
26 Waveform, | |
27 Spectrogram, | |
28 TimeRuler, | |
29 TimeInstants, | |
30 TimeValues, | |
31 Colour3DPlot, | |
32 | |
33 // Layers with different initial parameters | |
34 MelodicRangeSpectrogram, | |
35 | |
36 // Not-a-layer-type | |
37 UnknownLayer = 255 | |
38 }; | |
39 | |
40 static LayerFactory *instance(); | |
41 | |
42 virtual ~LayerFactory(); | |
43 | |
44 typedef std::set<LayerType> LayerTypeSet; | |
45 LayerTypeSet getValidLayerTypes(Model *model); | |
46 | |
47 LayerType getLayerType(Layer *); | |
48 | |
49 Layer *createLayer(LayerType type, View *view, | |
50 Model *model = 0, int channel = -1); | |
51 | |
52 QString getLayerPresentationName(LayerType type); | |
53 | |
54 void setModel(Layer *layer, Model *model); | |
55 | |
56 protected: | |
57 template <typename LayerClass, typename ModelClass> | |
58 bool trySetModel(Layer *layerBase, Model *modelBase) { | |
59 LayerClass *layer = dynamic_cast<LayerClass *>(layerBase); | |
60 if (!layer) return false; | |
61 ModelClass *model = dynamic_cast<ModelClass *>(modelBase); | |
62 layer->setModel(model); | |
63 return true; | |
64 } | |
65 | |
66 static LayerFactory *m_instance; | |
67 }; | |
68 | |
69 #endif | |
70 |