ColumnDataWriter.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #ifndef COLUMNDATAWRITER_HPP_
00030 #define COLUMNDATAWRITER_HPP_
00031 
00032 #include <string>
00033 #include <vector>
00034 
00035 #include "AbstractDataWriter.hpp"
00036 #include "DataWriterVariable.hpp"
00037 #include "OutputFileHandler.hpp"
00038 
00039 
00045 class ColumnDataWriter : public AbstractDataWriter
00046 {
00047 protected:
00048 
00049     OutputFileHandler mOutputFileHandler; 
00051     std::string mDirectory; 
00052     std::string mBaseName; 
00053     bool mIsInDefineMode; 
00054     bool mIsFixedDimensionSet; 
00055     bool mIsUnlimitedDimensionSet; 
00056     long mUnlimitedDimensionPosition; 
00057     long mFixedDimensionSize; 
00058     out_stream mpCurrentOutputFile; 
00059     out_stream mpCurrentAncillaryFile; 
00060     DataWriterVariable* mpUnlimitedDimensionVariable; 
00061     DataWriterVariable* mpFixedDimensionVariable; 
00063     std::string mUnlimitedDimensionName; 
00064     std::string mUnlimitedDimensionUnits; 
00066     std::string mFixedDimensionName; 
00067     std::string mFixedDimensionUnits; 
00069     std::vector<DataWriterVariable> mVariables; 
00071     const unsigned mFieldWidth; 
00072     const unsigned mPrecision; 
00073     static const int SPACING = 2; 
00074     static const int FIXED_DIMENSION_VAR_ID = -1; 
00075     static const int UNLIMITED_DIMENSION_VAR_ID = -2; 
00077     std::string mFileExtension; 
00079     int mRowStartPosition; 
00080     int mRowWidth; 
00082     int mAncillaryRowStartPosition; 
00083     int mAncillaryRowWidth; 
00085     bool mHasPutVariable; 
00086     bool mNeedAdvanceAlongUnlimitedDimension; 
00093     void CreateFixedDimensionFile(const std::string& rFileName);
00094 
00100     void CreateInfoFile(const std::string& rFileName);
00101 
00107     void CheckVariableName(const std::string& rName);
00108 
00114     void CheckUnitsName(const std::string& rName);
00115 
00120     void DoAdvanceAlongUnlimitedDimension();
00121 
00122 public:
00133     ColumnDataWriter(const std::string& rDirectory,
00134                      const std::string& rBaseName,
00135                      bool cleanDirectory=true,
00136                      unsigned precision=8);
00137 
00141     virtual ~ColumnDataWriter();
00142 
00151     int DefineUnlimitedDimension(const std::string& rDimensionName,
00152                                  const std::string& rDimensionUnits);
00153 
00163     int DefineFixedDimension(const std::string& rDimensionName,
00164                              const std::string& rDimensionUnits,
00165                              long dimensionSize);
00166 
00175     int DefineVariable(const std::string& rVariableName,
00176                        const std::string& rVariableUnits);
00177 
00181     virtual void EndDefineMode();
00182 
00186     virtual void AdvanceAlongUnlimitedDimension();
00187 
00196     virtual void PutVariable(int variableID, double variableValue, long dimensionPosition = -1);
00197 
00201     virtual void Close();
00202 
00206     std::string GetOutputDirectory();
00207 };
00208 
00209 #endif //COLUMNDATAWRITER_HPP_

Generated on Mon Nov 1 12:35:17 2010 for Chaste by  doxygen 1.5.5