Stimfit  0.13.15
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
recording.h
Go to the documentation of this file.
00001 // This program is free software; you can redistribute it and/or
00002 // modify it under the terms of the GNU General Public License
00003 // as published by the Free Software Foundation; either version 2
00004 // of the License, or (at your option) any later version.
00005 
00006 // This program is distributed in the hope that it will be useful,
00007 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00008 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00009 // GNU General Public License for more details.
00010 
00011 // You should have received a copy of the GNU General Public License
00012 // along with this program; if not, write to the Free Software
00013 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00014 
00021 #ifndef _RECORDING_H
00022 #define _RECORDING_H
00023 
00028 #include "./channel.h"
00029 // #include "./section.h"
00030 // #include "./stfio.h"
00031 
00032 class Section;
00033 
00035 
00039 class StfioDll Recording {
00040  public:
00041 
00042     //ctor/dtor-------------------------------------------------------
00044     explicit Recording();
00045 
00047 
00049     explicit Recording(const Channel& c_Channel); 
00050 
00052 
00054     explicit Recording(const std::vector<Channel>& ChannelList); 
00055 
00057 
00063     explicit Recording( std::size_t c_n_channels, std::size_t c_n_sections = 0, std::size_t c_n_points = 0 );
00064 
00066     virtual ~Recording();
00067 
00068     //member access functions: read-----------------------------------
00069     
00071 
00074     std::size_t GetChannelSize(std::size_t n_channel) const;
00075 
00077 
00079     const std::vector<Channel>& get() const { return ChannelArray; }
00080     
00082 
00084     std::vector<Channel>& get() { return ChannelArray; }
00085     
00087 
00089     const std::string& GetFileDescription() const { return file_description; }
00090 
00092 
00094     const std::string& GetGlobalSectionDescription() const { return global_section_description; }
00095 
00097 
00099     const std::string& GetScaling() const { return scaling; }
00100 
00102 
00104     const std::string& GetTime();
00105 
00107 
00109     const std::string& GetDate();
00110 
00112 
00114     struct tm GetDateTime() const { return datetime; };
00115 
00117 
00119     const std::string& GetComment() const { return comment; }
00120     
00122 
00124     const std::string& GetXUnits() const { return xunits; }
00125 
00127 
00129     std::size_t size() const { return ChannelArray.size(); }
00130     
00132 
00134     double GetXScale() const { return dt; }
00135     
00137 
00139     double GetSR() const { return 1.0/dt; }
00140 
00142 
00144     std::size_t GetCurChIndex() const { return cc; }
00145 
00147 
00149     std::size_t GetSecChIndex() const { return sc; }
00150 
00152 
00154     std::size_t GetCurSecIndex() const { return cs; }
00155     
00157 
00159     const std::vector<std::size_t>& GetSelectedSections() const { return selectedSections; } 
00160 
00162 
00164     std::vector<std::size_t>& GetSelectedSectionsW() { return selectedSections; } 
00165 
00167 
00169     const Vector_double& GetSelectBase() const { return selectBase; } 
00170 
00172 
00174     Vector_double& GetSelectBaseW() { return selectBase; }
00175 
00177 
00179     const Section& cursec() const { return (*this)[cc][cs]; }
00180 
00182 
00184     Section& cursec() { return (*this)[cc][cs]; }
00185 
00187 
00189     const Section& secsec() const { return (*this)[sc][cs]; }
00190 
00192 
00194     const Channel& curch() const { return (*this)[cc]; }
00195 
00197 
00199     Channel& curch() { return (*this)[cc]; }
00200 
00202 
00204     const Channel& secch() const { return (*this)[sc]; }
00205 
00207 
00211     const Channel& at(std::size_t n_c) const;
00212 
00214 
00218     Channel& at(std::size_t n_c);
00219 
00220     //member access functions: write---------------------------------
00221 
00223 
00225     void SetFileDescription(const std::string& value) { file_description=value; }
00226 
00228 
00230     void SetGlobalSectionDescription(const std::string& value) {
00231         global_section_description=value;
00232     }
00233 
00235 
00237     void SetScaling(const std::string& value) { scaling=value; }
00238  
00240 
00243     int SetTime(const std::string& value);
00244     int SetTime(int hour, int minute, int sec);
00245 
00247 
00250     int SetDate(const std::string& value);
00251     int SetDate(int year, int month, int mday);
00252 
00254 
00256     void SetDateTime(const struct tm &value) { memcpy(&datetime, &value, sizeof(struct tm)); }
00257     void SetDateTime(int year, int month, int mday, int hour, int minute, int sec) ;
00258 
00260 
00262     void SetComment(const std::string& value) { comment=value; }
00263     
00265 
00268     void SetGlobalYUnits(std::size_t n_channel, const std::string& value);
00269 
00271 
00273     void SetXUnits(const std::string& value) { xunits=value; }
00274 
00276 
00279     void SetXScale(double value);
00280 
00282 
00284     void SetCurChIndex(std::size_t value);
00285 
00287 
00289     void SetSecChIndex(std::size_t value);
00290 
00292 
00294     void SetCurSecIndex(std::size_t value);
00295 
00296     //misc-----------------------------------------------------------
00297 
00299 
00302     virtual void resize(std::size_t c_n_channels);
00303 
00305 
00309     virtual void InsertChannel(Channel& c_Channel, std::size_t pos);
00310 
00312 
00316     void CopyAttributes(const Recording& c_Recording);
00317 
00319 
00332     void MakeAverage( Section& AverageReturn, Section& SigReturn, std::size_t channel,
00333                       const std::vector<std::size_t>& section_index, bool isSig,
00334                       const std::vector<int>& shift) const;
00335 
00337 
00339     void AddRec(const Recording& toAdd);
00340 
00342 
00346     void SelectTrace(std::size_t sectionToSelect, std::size_t base_start, std::size_t base_end);
00347 
00349 
00352     bool UnselectTrace(std::size_t sectionToUnselect);
00353     
00354     //operators------------------------------------------------------
00355 
00357 
00360     Channel& operator[](std::size_t at) { return ChannelArray[at]; }
00361 
00363 
00366     const Channel& operator[](std::size_t at) const { return ChannelArray[at]; }
00367 
00368  private:
00369     std::vector<Channel> ChannelArray;
00370     std::string global_section_description, scaling;
00371 
00372     // only neeed for GetData() and GetTime(): should be replaced by alternative interface.
00373 #ifndef _MSC_VER
00374     __attribute__ ((deprecated))
00375 #endif
00376     std::string time0, date; 
00377 
00378     /* public: */
00379     
00380     double dt;
00381     std::string file_description, comment, xunits;
00382     struct tm datetime;
00383 
00384 
00385     // currently accessed channel:
00386     std::size_t cc;
00387     // second channel:
00388     std::size_t sc;
00389     // currently accessed section:
00390     std::size_t cs;
00391 
00392     // Indices of the selected sections
00393     std::vector<std::size_t> selectedSections;
00394     // Base line value for each selected trace
00395     Vector_double selectBase;
00396     
00397     void init();
00398 
00399 };
00400 
00403 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines