indii/fmri/data/SeedWriter.hpp

00001 #ifndef INDII_FMRI_DATA_SEEDWRITER_HPP
00002 #define INDII_FMRI_DATA_SEEDWRITER_HPP
00003 
00004 #include "indii/ml/aux/vector.hpp"
00005 #include "indii/ml/aux/matrix.hpp"
00006 
00007 #include <iostream>
00008 
00009 namespace indii {
00010   namespace fmri {
00011     namespace data {
00012 
00013 /**
00014  * Abstract writer for seed %data files.
00015  *
00016  * @author Lawrence Murray <lawrence@indii.org>
00017  * @version $Rev: 285 $
00018  * @date $Date: 2007-07-20 17:25:40 +0100 (Fri, 20 Jul 2007) $
00019  */
00020 class SeedWriter {
00021 public:
00022   /**
00023    * Construct new seed writer from output stream.
00024    *
00025    * @param out Stream to which to write.
00026    */
00027   SeedWriter(std::ostream* out);
00028 
00029   /**
00030    * Construct new seed writer from file.
00031    *
00032    * @param file Name of file to which to write.
00033    */
00034   SeedWriter(const std::string file);
00035 
00036   /**
00037    * Destructor. The output stream is closed if the object was created
00038    * using a file name, but left open otherwise.
00039    */
00040   virtual ~SeedWriter();
00041 
00042   /**
00043    * Write single value.
00044    *
00045    * @param value Value to write.
00046    */
00047   virtual void write(const double value) = 0;
00048 
00049   /**
00050    * Write vector of values. All values are written to the current
00051    * line.
00052    *
00053    * @param values Vector of values to write.
00054    */
00055   virtual void write(const indii::ml::aux::vector values) = 0;
00056 
00057   /**
00058    * Write matrix of values. All values are written to the current
00059    * line in column-wise fashion.
00060    *
00061    * @param values Matrix of values to write.
00062    */
00063   virtual void write(const indii::ml::aux::matrix values) = 0;
00064 
00065   /**
00066    * Write symmetric matrix of values. All values from the lower
00067    * triangle of the matrix are written to the current line in
00068    * column-wise fashion.
00069    *
00070    * @param values Matrix of values to write.
00071    */
00072   virtual void write(const indii::ml::aux::symmetric_matrix values) = 0;
00073 
00074   /**
00075    * Write the end of the current line and begin a new line.
00076    */
00077   virtual void writeLine() = 0;
00078 
00079   /**
00080    * Convenience method equivalent to calling write(const double) then
00081    * writeLine().
00082    */
00083   void writeLine(const double value);
00084 
00085   /**
00086    * Convenience method equivalent to calling write(const
00087    * indii::ml::aux::vector) then writeLine().
00088    */
00089   void writeLine(const indii::ml::aux::vector values);
00090 
00091   /**
00092    * Convenience method equivalent to calling write(const
00093    * indii::ml::aux::matrix) then writeLine().
00094    */
00095   void writeLine(const indii::ml::aux::matrix values);
00096 
00097   /**
00098    * Convenience method equivalent to calling write(const
00099    * indii::ml::aux::symmetric_matrix) then writeLine().
00100    */
00101   void writeLine(const indii::ml::aux::symmetric_matrix values);
00102 
00103 protected:
00104   /**
00105    * The output stream.
00106    */
00107   std::ostream* out;
00108 
00109 private:
00110   /**
00111    * Does object own the output stream?
00112    */
00113   const bool ownStream;
00114 
00115 };
00116 
00117     }
00118   }
00119 }
00120 
00121 #endif

Generated on Tue Oct 9 22:02:07 2007 for fmrii fMRI Modelling Library by  doxygen 1.5.2