ColumnDataWriter.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
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     static const int FIELD_WIDTH = 10; 
00072     static const int SPACING = 2; 
00073     static const int FIXED_DIMENSION_VAR_ID = -1; 
00074     static const int UNLIMITED_DIMENSION_VAR_ID = -2;
00076     std::string mFileExtension; 
00078     int mRowStartPosition; 
00079     int mRowWidth; 
00081     int mAncillaryRowStartPosition; 
00082     int mAncillaryRowWidth; 
00084     bool mHasPutVariable; 
00085     bool mNeedAdvanceAlongUnlimitedDimension; 
00092     void CreateFixedDimensionFile(const std::string& rFileName);
00093 
00099     void CreateInfoFile(const std::string& rFileName);
00100 
00106     void CheckVariableName(const std::string& rName);
00107 
00113     void CheckUnitsName(const std::string& rName);
00114 
00119     void DoAdvanceAlongUnlimitedDimension();
00120 
00121 public:
00122 
00130     ColumnDataWriter(const std::string& rDirectory,
00131                      const std::string& rBaseName,
00132                      bool cleanDirectory=true);
00133 
00137     virtual ~ColumnDataWriter();
00138 
00147     int DefineUnlimitedDimension(const std::string& rDimensionName,
00148                                  const std::string& rDimensionUnits);
00149 
00159     int DefineFixedDimension(const std::string& rDimensionName,
00160                              const std::string& rDimensionUnits,
00161                              long dimensionSize);
00162 
00171     int DefineVariable(const std::string& rVariableName,
00172                        const std::string& rVariableUnits);
00173 
00177     virtual void EndDefineMode();
00178 
00182     virtual void AdvanceAlongUnlimitedDimension();
00183 
00192     virtual void PutVariable(int variableID, double variableValue, long dimensionPosition = -1);
00193 
00197     virtual void Close();
00198 
00202     std::string GetOutputDirectory();
00203 };
00204 
00205 #endif //COLUMNDATAWRITER_HPP_

Generated on Tue Aug 4 16:10:22 2009 for Chaste by  doxygen 1.5.5