Chris@0: /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ Chris@0: Chris@0: /* Chris@0: A waveform viewer and audio annotation editor. Chris@5: Chris Cannam, Queen Mary University of London, 2005-2006 Chris@0: Chris@0: This is experimental software. Not for distribution. Chris@0: */ Chris@0: Chris@0: #ifndef _LAYER_FACTORY_H_ Chris@0: #define _LAYER_FACTORY_H_ Chris@0: Chris@0: #include Chris@0: #include Chris@0: Chris@0: class Layer; Chris@0: class View; Chris@0: class Model; Chris@0: Chris@0: class LayerFactory Chris@0: { Chris@0: public: Chris@0: enum LayerType { Chris@0: Chris@0: // Standard layers Chris@0: Waveform, Chris@0: Spectrogram, Chris@0: TimeRuler, Chris@0: TimeInstants, Chris@0: TimeValues, Chris@0: Colour3DPlot, Chris@0: Chris@0: // Layers with different initial parameters Chris@0: MelodicRangeSpectrogram, Chris@0: Chris@0: // Not-a-layer-type Chris@0: UnknownLayer = 255 Chris@0: }; Chris@0: Chris@0: static LayerFactory *instance(); Chris@0: Chris@0: virtual ~LayerFactory(); Chris@0: Chris@0: typedef std::set LayerTypeSet; Chris@0: LayerTypeSet getValidLayerTypes(Model *model); Chris@17: LayerTypeSet getValidEmptyLayerTypes(); Chris@0: Chris@6: LayerType getLayerType(const Layer *); Chris@0: Chris@0: Layer *createLayer(LayerType type, View *view, Chris@0: Model *model = 0, int channel = -1); Chris@0: Chris@0: QString getLayerPresentationName(LayerType type); Chris@0: Chris@0: void setModel(Layer *layer, Model *model); Chris@17: Model *createEmptyModel(LayerType type, Model *baseModel); Chris@0: Chris@17: QString getLayerIconName(LayerType); Chris@6: QString getLayerTypeName(LayerType); Chris@6: LayerType getLayerTypeForName(QString); Chris@6: Chris@0: protected: Chris@0: template Chris@0: bool trySetModel(Layer *layerBase, Model *modelBase) { Chris@0: LayerClass *layer = dynamic_cast(layerBase); Chris@0: if (!layer) return false; Chris@0: ModelClass *model = dynamic_cast(modelBase); Chris@17: if (!model) return false; Chris@0: layer->setModel(model); Chris@0: return true; Chris@0: } Chris@0: Chris@0: static LayerFactory *m_instance; Chris@0: }; Chris@0: Chris@0: #endif Chris@0: