TrackContainer.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * TrackContainer.h - base-class for all track-containers like Song-Editor,
  3. * BB-Editor...
  4. *
  5. * Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  6. *
  7. * This file is part of LMMS - https://lmms.io
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2 of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public
  20. * License along with this program (see COPYING); if not, write to the
  21. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  22. * Boston, MA 02110-1301 USA.
  23. *
  24. */
  25. #ifndef TRACK_CONTAINER_H
  26. #define TRACK_CONTAINER_H
  27. #include <QtCore/QReadWriteLock>
  28. #include "Track.h"
  29. #include "JournallingObject.h"
  30. class AutomationPattern;
  31. class InstrumentTrack;
  32. class TrackContainerView;
  33. class LMMS_EXPORT TrackContainer : public Model, public JournallingObject
  34. {
  35. Q_OBJECT
  36. public:
  37. typedef QVector<Track *> TrackList;
  38. enum TrackContainerTypes
  39. {
  40. BBContainer,
  41. SongContainer
  42. } ;
  43. TrackContainer();
  44. virtual ~TrackContainer();
  45. void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
  46. void loadSettings( const QDomElement & _this ) override;
  47. virtual AutomationPattern * tempoAutomationPattern()
  48. {
  49. return NULL;
  50. }
  51. int countTracks( Track::TrackTypes _tt = Track::NumTrackTypes ) const;
  52. void addTrack( Track * _track );
  53. void removeTrack( Track * _track );
  54. virtual void updateAfterTrackAdd();
  55. void clearAllTracks();
  56. const TrackList & tracks() const
  57. {
  58. return m_tracks;
  59. }
  60. bool isEmpty() const;
  61. static const QString classNodeName()
  62. {
  63. return "trackcontainer";
  64. }
  65. inline void setType( TrackContainerTypes newType )
  66. {
  67. m_TrackContainerType = newType;
  68. }
  69. inline TrackContainerTypes type() const
  70. {
  71. return m_TrackContainerType;
  72. }
  73. virtual AutomatedValueMap automatedValuesAt(MidiTime time, int tcoNum = -1) const;
  74. signals:
  75. void trackAdded( Track * _track );
  76. protected:
  77. static AutomatedValueMap automatedValuesFromTracks(const TrackList &tracks, MidiTime timeStart, int tcoNum = -1);
  78. mutable QReadWriteLock m_tracksMutex;
  79. private:
  80. TrackList m_tracks;
  81. TrackContainerTypes m_TrackContainerType;
  82. friend class TrackContainerView;
  83. friend class Track;
  84. } ;
  85. class DummyTrackContainer : public TrackContainer
  86. {
  87. public:
  88. DummyTrackContainer();
  89. virtual ~DummyTrackContainer()
  90. {
  91. }
  92. QString nodeName() const override
  93. {
  94. return "DummyTrackContainer";
  95. }
  96. InstrumentTrack * dummyInstrumentTrack()
  97. {
  98. return m_dummyInstrumentTrack;
  99. }
  100. private:
  101. InstrumentTrack * m_dummyInstrumentTrack;
  102. } ;
  103. #endif