Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

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-2004 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 //
00048 //  Class Marker represents a labeled time point in a set of Partials
00049 //  or a vector of samples. Collections of Markers (see the MarkerContainer
00050 //  definition below) are held by the File I/O classes in Loris (AiffFile,
00051 //  SdifFile, and SpcFile) to identify temporal features in imported
00052 //  and exported data.
00053 //
00054 class Marker
00055 {
00056 //  -- implementation --
00057     double m_time;
00058     std::string m_name;
00059             
00060 //  -- public interface --
00061 public:
00062 //  -- construction --
00063     Marker( void );
00064     /*  Default constructor - initialize a Marker at time zero with no label.
00065      */
00066      
00067     Marker( double t, const std::string & s );
00068     /*  Initialize a Marker with the specified time (in seconds) and name.
00069      */
00070      
00071     Marker( const Marker & other );
00072     /*  Initialize a Marker that is an exact copy of another Marker, that is,
00073         having the same time and name.
00074      */
00075     
00076     Marker & operator=( const Marker & rhs );
00077     /*  Make this Marker an exact copy, having the same time and name, 
00078         as the Marker rhs.
00079      */
00080      
00081 //  -- comparison --
00082     bool operator< ( const Marker & rhs ) const;
00083     /*  Return true if this Marker must appear earlier than rhs in a sorted
00084         collection of Markers, and false otherwise. (Markers are sorted by time.)
00085      */
00086      
00087 //  -- access --
00088     std::string & name( void );
00089     const std::string & name( void ) const;
00090     /*  Return a reference (or const reference) to the name string
00091         for this Marker.
00092      */
00093      
00094     double time( void ) const;
00095     /*  Return the time (in seconds) associated with this Marker.
00096      */
00097      
00098 //  -- mutation --
00099     void setName( const std::string & s );
00100     /*  Set the name of the Marker.
00101      */
00102      
00103     void setTime( double t );
00104     /*  Set the time (in seconds) associated with this Marker.
00105      */
00106 
00107 //  -- comparitors --
00108     /*  Comparitor (binary) functor returning true if its first Marker
00109         argument should appear before the second in a range sorted
00110         by Marker name.
00111      */
00112     struct sortByName : 
00113         public std::binary_function< const Marker, const Marker, bool >
00114     {
00115         bool operator()( const Marker & lhs, const Marker & rhs ) const 
00116             { return lhs.name() < rhs.name(); }
00117     };
00118     
00119     
00120     /*  Comparitor (binary) functor returning true if its first Marker
00121         argument should appear before the second in a range sorted
00122         by Marker time.
00123      */
00124     struct sortByTime : 
00125         public std::binary_function< const Marker, const Marker, bool >
00126     {
00127         bool operator()( const Marker & lhs, const Marker & rhs ) const 
00128             { return lhs.time() < rhs.time(); }
00129     };
00130     
00131     
00132 };  //  end of class Marker
00133 
00134 }   //  end of namespace Loris
00135 
00136 #endif /* ndef INCLUDE_MARKER_H */

Generated on Thu Apr 14 22:01:55 2005 for Loris by doxygen 1.3.4