annotate layer/LayerFactory.h @ 473:4f4f943bfdfc

* Merge from one-fftdataserver-per-fftmodel branch. This bit of reworking (which is not described very accurately by the title of the branch) turns the MatrixFile object into something that either reads or writes, but not both, and separates the FFT file cache reader and writer implementations separately. This allows the FFT data server to have a single thread owning writers and one reader per "customer" thread, and for all locking to be vastly simplified and concentrated in the data server alone (because none of the classes it makes use of is used in more than one thread at a time). The result is faster and more trustworthy code.
author Chris Cannam
date Tue, 27 Jan 2009 13:25:10 +0000
parents 96e4d7b9e165
children 765bb3774c4f
rev   line source
Chris@58 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@59 4 Sonic Visualiser
Chris@59 5 An audio file viewer and annotation editor.
Chris@59 6 Centre for Digital Music, Queen Mary, University of London.
Chris@59 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@59 9 This program is free software; you can redistribute it and/or
Chris@59 10 modify it under the terms of the GNU General Public License as
Chris@59 11 published by the Free Software Foundation; either version 2 of the
Chris@59 12 License, or (at your option) any later version. See the file
Chris@59 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #ifndef _LAYER_FACTORY_H_
Chris@0 17 #define _LAYER_FACTORY_H_
Chris@0 18
Chris@0 19 #include <QString>
Chris@0 20 #include <set>
Chris@0 21
Chris@0 22 class Layer;
Chris@0 23 class Model;
Chris@360 24 class Clipboard;
Chris@0 25
Chris@0 26 class LayerFactory
Chris@0 27 {
Chris@0 28 public:
Chris@0 29 enum LayerType {
Chris@0 30
Chris@0 31 // Standard layers
Chris@0 32 Waveform,
Chris@0 33 Spectrogram,
Chris@0 34 TimeRuler,
Chris@0 35 TimeInstants,
Chris@0 36 TimeValues,
Chris@30 37 Notes,
Chris@411 38 Regions,
Chris@35 39 Text,
Chris@303 40 Image,
Chris@0 41 Colour3DPlot,
Chris@133 42 Spectrum,
Chris@193 43 Slice,
Chris@0 44
Chris@0 45 // Layers with different initial parameters
Chris@0 46 MelodicRangeSpectrogram,
Chris@37 47 PeakFrequencySpectrogram,
Chris@0 48
Chris@0 49 // Not-a-layer-type
Chris@0 50 UnknownLayer = 255
Chris@0 51 };
Chris@0 52
Chris@125 53 static LayerFactory *getInstance();
Chris@0 54
Chris@0 55 virtual ~LayerFactory();
Chris@0 56
Chris@0 57 typedef std::set<LayerType> LayerTypeSet;
Chris@0 58 LayerTypeSet getValidLayerTypes(Model *model);
Chris@17 59 LayerTypeSet getValidEmptyLayerTypes();
Chris@0 60
Chris@6 61 LayerType getLayerType(const Layer *);
Chris@0 62
Chris@53 63 Layer *createLayer(LayerType type);
Chris@0 64
Chris@326 65 void setLayerDefaultProperties(LayerType type, Layer *layer);
Chris@326 66
Chris@0 67 QString getLayerPresentationName(LayerType type);
Chris@0 68
Chris@193 69 bool isLayerSliceable(const Layer *);
Chris@193 70
Chris@0 71 void setModel(Layer *layer, Model *model);
Chris@17 72 Model *createEmptyModel(LayerType type, Model *baseModel);
Chris@0 73
Chris@53 74 int getChannel(Layer *layer);
Chris@53 75 void setChannel(Layer *layer, int channel);
Chris@53 76
Chris@17 77 QString getLayerIconName(LayerType);
Chris@6 78 QString getLayerTypeName(LayerType);
Chris@6 79 LayerType getLayerTypeForName(QString);
Chris@6 80
Chris@360 81 LayerType getLayerTypeForClipboardContents(const Clipboard &);
Chris@360 82
Chris@0 83 protected:
Chris@0 84 template <typename LayerClass, typename ModelClass>
Chris@0 85 bool trySetModel(Layer *layerBase, Model *modelBase) {
Chris@0 86 LayerClass *layer = dynamic_cast<LayerClass *>(layerBase);
Chris@0 87 if (!layer) return false;
Chris@0 88 ModelClass *model = dynamic_cast<ModelClass *>(modelBase);
Chris@17 89 if (!model) return false;
Chris@0 90 layer->setModel(model);
Chris@0 91 return true;
Chris@0 92 }
Chris@0 93
Chris@0 94 static LayerFactory *m_instance;
Chris@0 95 };
Chris@0 96
Chris@0 97 #endif
Chris@0 98