Segment.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef _Segment_
00023 #define _Segment_
00024 
00025 #include "Frame.hxx"
00026 #include "DataTypes.hxx"
00027 #include "List.hxx"
00028 #include "Search.hxx"
00029 #include "ProcessingData.hxx"
00030 #include "Audio.hxx"
00031 
00032 namespace CLAM 
00033 {
00034 
00035 typedef Search < List < Frame >, Frame> FrameSearch;
00036 
00050 class Segment : public ProcessingData
00051 {
00052 public:
00053         DYNAMIC_TYPE_USING_INTERFACE (Segment, 8, ProcessingData);
00055         DYN_ATTRIBUTE (0, public, TTime, BeginTime);
00057         DYN_ATTRIBUTE (1, public, TTime, EndTime);
00058         DYN_ATTRIBUTE (2, private, bool, prHoldsData);
00059         DYN_ATTRIBUTE (3, private, List<Frame>, prFramesArray);
00060         DYN_ATTRIBUTE (4, public, Audio, Audio);
00061         DYN_ATTRIBUTE (5, public, List<Segment>, Children);
00062         DYN_ATTRIBUTE (6, public, TData, SamplingRate);
00063         DYN_ATTRIBUTE (7, public, std::string, Id);     
00064         
00065 private:
00067         FrameSearch mFramesSearch;
00069         Segment* pParent;
00070 
00071 public:
00072 
00073         void AddFramesArray()
00074         {
00075                 AddprFramesArray();
00076         }
00077         void RemoveFramesArray()
00078         {
00079                 RemoveprFramesArray();
00080         }
00081         
00082         void SetFramesArray(const List<Frame>& frames)
00083         {
00084                 SetprFramesArray(frames);
00085                 GetFramesSearch().Set(GetprFramesArray());
00086         }
00087         const List<Frame>& GetFramesArray() const {return GetprFramesArray();}
00088         List<Frame>& GetFramesArray() {return GetprFramesArray();}
00090         TIndex mCurrentFrameIndex;
00091         
00093         Segment* GetpParent(){return pParent;}
00095         void SetpParent(Segment*  newParent){pParent=newParent;}
00096         void DefaultInit();
00097 
00098 public:
00099         void CopyInit(const Segment& prototype);
00100 
00102         int GetnFrames() const;
00103 
00104 //Interface for accessing and modifying frames
00105 
00110         Frame& GetFrame(TIndex pos);
00112         const Frame& GetFrame(TIndex pos) const;
00114         void AddFrame(Frame& newFrame); // XXX: should really be a const reference as the frame is copied
00116         void DeleteFrame(TIndex pos);
00117 
00121         TIndex FindFrame(TTime time) const;
00122 
00127         Frame& GetFrame(TTime time);
00128 
00132         const Frame& GetFrame(TTime time) const;
00133 
00137         void DeleteFrame(TTime time);
00138         
00142         void SetHoldsData(bool HoldsData);
00143 
00147         bool GetHoldsData() const {return GetprHoldsData();}
00148 
00149 private:
00150         
00152         void SetFramesSearch (const FrameSearch & frame) 
00153         {
00154                 mFramesSearch=frame;
00155         }
00156         
00158         const FrameSearch & GetFramesSearch () const 
00159         {
00160                 return mFramesSearch;
00161         }
00162         
00164         FrameSearch & GetFramesSearch () 
00165         {
00166                 return mFramesSearch;
00167         }
00168         
00170         void CopyDataFromParent();
00171         void DefaultValues();
00172 };
00173 
00174 } //namespace CLAM
00175 
00176 #endif
00177 
Generated by  doxygen 1.6.3