Marker.h

00001 #ifndef INCLUDE_MARKER_H
00002 #define INCLUDE_MARKER_H
00003 /*
00004  * This is the Loris C++ Class Library, implementing analysis, 
00005  * manipulation, and synthesis of digitized sounds using the Reassigned 
00006  * Bandwidth-Enhanced Additive Sound Model.
00007  *
00008  * Loris is Copyright (c) 1999-2007 by Kelly Fitz and Lippold Haken
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY, without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  *
00025  * Marker.h
00026  *
00027  * Definition of classes Marker and MarkerContainer representing labeled
00028  * time points or temporal features in imported and exported data. Used by 
00029  * file I/O classes AiffFile, SdifFile, and SpcFile.
00030  *
00031  * Kelly Fitz, 8 Jan 2003 
00032  * loris@cerlsoundgroup.org
00033  *
00034  * http://www.cerlsoundgroup.org/Loris/
00035  *
00036  */
00037 
00038 #include <functional>
00039 #include <string>
00040 #include <vector>
00041 
00042 //  begin namespace
00043 namespace Loris {
00044 
00045 // ---------------------------------------------------------------------------
00046 //  class Marker
00047 //
00053 //
00054 class Marker
00055 {
00056 //  -- public interface --
00057 public:
00058 //  -- construction --
00059 
00061     Marker( void );
00062      
00067     Marker( double t, const std::string & s );
00068      
00073     Marker( const Marker & other );
00074     
00080     Marker & operator=( const Marker & rhs );
00081      
00082 //  -- comparison --
00083 
00091     bool operator< ( const Marker & rhs ) const;
00092      
00093 //  -- access --
00094     
00097     std::string & name( void );
00098 
00101     const std::string & name( void ) const;
00102      
00104     double time( void ) const;
00105 
00106      
00107 //  -- mutation --
00109     void setName( const std::string & s );
00110      
00112     void setTime( double t );
00113 
00114 //  -- comparitors --
00115 
00119     struct compareNameLess : 
00120         public std::binary_function< const Marker, const Marker, bool >
00121     {
00125         bool operator()( const Marker & lhs, const Marker & rhs ) const 
00126             { return lhs.name() < rhs.name(); }
00127     };
00128     
00131     typedef compareNameLess sortByName; 
00132     
00133     
00137     struct compareTimeLess : 
00138         public std::binary_function< const Marker, const Marker, bool >
00139     {
00143         bool operator()( const Marker & lhs, const Marker & rhs ) const 
00144             { return lhs.time() < rhs.time(); }
00145     };
00146     
00149     typedef compareTimeLess sortByTime; 
00150     
00153     class isNameEqual : public std::unary_function< const Marker, bool >
00154     {
00155     public:
00157         isNameEqual( const std::string & s ) : name(s) {}
00158         
00160         bool operator()( const Marker & m ) const 
00161             { return m.name() == name; }
00162             
00163     private:    
00164         std::string name;   
00165     };
00166 
00167 private:
00168 
00169 //  -- implementation --
00170 
00171     double m_time;          
00172     std::string m_name;     
00173             
00174 };  //  end of class Marker
00175 
00176 }   //  end of namespace Loris
00177 
00178 #endif /* ndef INCLUDE_MARKER_H */

Generated on Sat Jan 19 19:02:50 2008 for Loris by  doxygen 1.5.2