CLAM-Development  1.4.0
Segment.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #ifndef _Segment_
23 #define _Segment_
24 
25 #include "Frame.hxx"
26 #include "DataTypes.hxx"
27 #include "List.hxx"
28 #include "Search.hxx"
29 #include "ProcessingData.hxx"
30 #include "Audio.hxx"
31 
32 namespace CLAM
33 {
34 
36 
50 class Segment : public ProcessingData
51 {
52 public:
55  DYN_ATTRIBUTE (0, public, TTime, BeginTime);
57  DYN_ATTRIBUTE (1, public, TTime, EndTime);
58  DYN_ATTRIBUTE (2, private, bool, prHoldsData);
59  DYN_ATTRIBUTE (3, private, List<Frame>, prFramesArray);
60  DYN_ATTRIBUTE (4, public, Audio, Audio);
61  DYN_ATTRIBUTE (5, public, List<Segment>, Children);
62  DYN_ATTRIBUTE (6, public, TData, SamplingRate);
63  DYN_ATTRIBUTE (7, public, std::string, Id);
64 
65 private:
67  FrameSearch mFramesSearch;
69  Segment* pParent;
70 
71 public:
72 
74  {
75  AddprFramesArray();
76  }
78  {
79  RemoveprFramesArray();
80  }
81 
82  void SetFramesArray(const List<Frame>& frames)
83  {
84  SetprFramesArray(frames);
85  GetFramesSearch().Set(GetprFramesArray());
86  }
87  const List<Frame>& GetFramesArray() const {return GetprFramesArray();}
88  List<Frame>& GetFramesArray() {return GetprFramesArray();}
91 
93  Segment* GetpParent(){return pParent;}
95  void SetpParent(Segment* newParent){pParent=newParent;}
96  void DefaultInit();
97 
98 public:
99  void CopyInit(const Segment& prototype);
100 
102  int GetnFrames() const;
103 
104 //Interface for accessing and modifying frames
105 
110  Frame& GetFrame(TIndex pos);
112  const Frame& GetFrame(TIndex pos) const;
114  void AddFrame(Frame& newFrame); // XXX: should really be a const reference as the frame is copied
116  void DeleteFrame(TIndex pos);
117 
121  TIndex FindFrame(TTime time) const;
122 
127  Frame& GetFrame(TTime time);
128 
132  const Frame& GetFrame(TTime time) const;
133 
137  void DeleteFrame(TTime time);
138 
142  void SetHoldsData(bool HoldsData);
143 
147  bool GetHoldsData() const {return GetprHoldsData();}
148 
149 private:
150 
152  void SetFramesSearch (const FrameSearch & frame)
153  {
154  mFramesSearch=frame;
155  }
156 
158  const FrameSearch & GetFramesSearch () const
159  {
160  return mFramesSearch;
161  }
162 
164  FrameSearch & GetFramesSearch ()
165  {
166  return mFramesSearch;
167  }
168 
170  void CopyDataFromParent();
171  void DefaultValues();
172 };
173 
174 } //namespace CLAM
175 
176 #endif
177