comparison data/model/Model.h @ 1735:d91ff235e69d by-id

Some messing with Model and AlignmentModel
author Chris Cannam
date Tue, 25 Jun 2019 15:29:34 +0100
parents 87b4c596c0ef
children 9d82b164f264
comparison
equal deleted inserted replaced
1733:c3b5564cfb78 1735:d91ff235e69d
38 public Playable 38 public Playable
39 { 39 {
40 Q_OBJECT 40 Q_OBJECT
41 41
42 public: 42 public:
43 typedef Id ModelId;
44
43 virtual ~Model(); 45 virtual ~Model();
44 46
45 /** 47 /**
46 * Return true if the model was constructed successfully. Classes 48 * Return true if the model was constructed successfully. Classes
47 * that refer to the model should always test this before use. 49 * that refer to the model should always test this before use.
137 * model API is concerned, this does nothing more than tell the 139 * model API is concerned, this does nothing more than tell the
138 * model to return true from isAbandoning(). The actual response 140 * model to return true from isAbandoning(). The actual response
139 * to this will depend on the model's context -- it's possible 141 * to this will depend on the model's context -- it's possible
140 * nothing at all will change. 142 * nothing at all will change.
141 */ 143 */
144 //!!! aim to lose this
145 /*!!!
142 virtual void abandon() { 146 virtual void abandon() {
143 m_abandoning = true; 147 m_abandoning = true;
144 } 148 }
145 149 */
150
146 /** 151 /**
147 * Query whether the model has been marked as abandoning. 152 * Query whether the model has been marked as abandoning.
148 */ 153 */
154 //!!! aim to lose this
155 /*!!!
149 virtual bool isAbandoning() const { 156 virtual bool isAbandoning() const {
150 return m_abandoning; 157 return m_abandoning;
151 } 158 }
152 159 */
153 /** 160 /**
154 * Return true if the model has finished loading or calculating 161 * Return true if the model has finished loading or calculating
155 * all its data, for a model that is capable of calculating in a 162 * all its data, for a model that is capable of calculating in a
156 * background thread. 163 * background thread.
157 * 164 *
198 virtual const ZoomConstraint *getZoomConstraint() const { 205 virtual const ZoomConstraint *getZoomConstraint() const {
199 return 0; 206 return 0;
200 } 207 }
201 208
202 /** 209 /**
203 * If this model was derived from another, return the model it was 210 * If this model was derived from another, return the id of the
204 * derived from. The assumption is that the source model's 211 * model it was derived from. The assumption is that the source
205 * alignment will also apply to this model, unless some other 212 * model's alignment will also apply to this model, unless some
206 * property (such as a specific alignment model set on this model) 213 * other property (such as a specific alignment model set on this
207 * indicates otherwise. 214 * model) indicates otherwise.
208 */ 215 */
209 virtual Model *getSourceModel() const { 216 virtual ModelId getSourceModel() const {
210 return m_sourceModel; 217 return m_sourceModel;
211 } 218 }
212 219
213 /** 220 /**
214 * Set the source model for this model. 221 * Set the source model for this model.
215 */ 222 */
216 virtual void setSourceModel(Model *model); 223 virtual void setSourceModel(ModelId model);
217 224
218 /** 225 /**
219 * Specify an aligment between this model's timeline and that of a 226 * Specify an alignment between this model's timeline and that of
220 * reference model. The alignment model records both the 227 * a reference model. The alignment model, of type AlignmentModel,
221 * reference and the alignment. This model takes ownership of the 228 * records both the reference and the alignment. This model "takes
222 * alignment model. 229 * ownership" of alignmentModel, in that we take responsibility
223 */ 230 * for calling ModelById::release() for it from our own destructor
224 virtual void setAlignment(AlignmentModel *alignment); 231 * (no other class needs to know about the alignment model).
232
233 *!!! I don't think the above is a good idea - I think document
234 should record alignment models and release them
235 */
236 virtual void setAlignment(ModelId alignmentModel);
225 237
226 /** 238 /**
227 * Retrieve the alignment model for this model. This is not a 239 * Retrieve the alignment model for this model. This is not a
228 * generally useful function, as the alignment you really want may 240 * generally useful function, as the alignment you really want may
229 * be performed by the source model instead. You should normally 241 * be performed by the source model instead. You should normally
230 * use getAlignmentReference, alignToReference and 242 * use getAlignmentReference, alignToReference and
231 * alignFromReference instead of this. The main intended 243 * alignFromReference instead of this. The main intended
232 * application for this function is in streaming out alignments to 244 * application for this function is in streaming out alignments to
233 * the session file. 245 * the session file.
234 */ 246 */
235 virtual const AlignmentModel *getAlignment() const; 247 virtual const ModelId getAlignment() const;
236 248
237 /** 249 /**
238 * Return the reference model for the current alignment timeline, 250 * Return the reference model for the current alignment timeline,
239 * if any. 251 * if any.
240 */ 252 */
241 virtual const Model *getAlignmentReference() const; 253 virtual const ModelId getAlignmentReference() const;
242 254
243 /** 255 /**
244 * Return the frame number of the reference model that corresponds 256 * Return the frame number of the reference model that corresponds
245 * to the given frame number in this model. 257 * to the given frame number in this model.
246 */ 258 */
280 virtual QString toDelimitedDataString(QString delimiter, 292 virtual QString toDelimitedDataString(QString delimiter,
281 DataExportOptions options, 293 DataExportOptions options,
282 sv_frame_t startFrame, 294 sv_frame_t startFrame,
283 sv_frame_t duration) const = 0; 295 sv_frame_t duration) const = 0;
284 296
297 /*!!!
285 public slots: 298 public slots:
286 void aboutToDelete(); 299 void aboutToDelete();
287 void sourceModelAboutToBeDeleted(); 300 void sourceModelAboutToBeDeleted();
288 301 */
302
289 signals: 303 signals:
290 /** 304 /**
291 * Emitted when a model has been edited (or more data retrieved 305 * Emitted when a model has been edited (or more data retrieved
292 * from cache, in the case of a cached model that generates slowly) 306 * from cache, in the case of a cached model that generates slowly)
293 */ 307 */
326 * owning model telling the model that it is about to delete it; 340 * owning model telling the model that it is about to delete it;
327 * there is nothing in the model to guarantee that this signal 341 * there is nothing in the model to guarantee that this signal
328 * will be emitted before the actual deletion. 342 * will be emitted before the actual deletion.
329 */ 343 */
330 //!!! our goal is to get rid of (the need for) this 344 //!!! our goal is to get rid of (the need for) this
331 void aboutToBeDeleted(); 345 //!!! void aboutToBeDeleted();
332 346
333 protected: 347 protected:
334 Model() : 348 Model() :
335 m_sourceModel(0), 349 //!!! m_abandoning(false),
336 m_alignment(0), 350 //!!! m_aboutToDelete(false),
337 m_abandoning(false),
338 m_aboutToDelete(false),
339 m_extendTo(0) { } 351 m_extendTo(0) { }
340 352
341 // Not provided. 353 // Not provided.
342 Model(const Model &); 354 Model(const Model &) =delete;
343 Model &operator=(const Model &); 355 Model &operator=(const Model &) =delete;
344 356
345 Model *m_sourceModel; 357 ModelId m_sourceModel;
346 AlignmentModel *m_alignment; 358 ModelId m_alignmentModel;
347 QString m_typeUri; 359 QString m_typeUri;
348 bool m_abandoning; 360 //!!! bool m_abandoning;
349 bool m_aboutToDelete; 361 //!!! bool m_aboutToDelete;
350 sv_frame_t m_extendTo; 362 sv_frame_t m_extendTo;
351 }; 363 };
352 364
353 typedef Model::Id ModelId; 365 typedef Model::ModelId ModelId;
354 typedef StaticById<Model, ModelId> ModelById; 366 typedef StaticById<Model, ModelId> ModelById;
355 367
356 #endif 368 #endif