"Fossies" - the Fresh Open Source Software Archive

Member "fimex-1.4.2/src/metgm/MetGmCDMWriterImpl.h" (6 Jan 2020, 3844 Bytes) of package /linux/privat/fimex-1.4.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "MetGmCDMWriterImpl.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.4.1_vs_1.4.2.

    1 /*
    2  * Fimex
    3  *
    4  * (C) Copyright 2011-2019, met.no
    5  *
    6  * Project Info:  https://wiki.met.no/fimex/start
    7  *
    8  * This library is free software; you can redistribute it and/or modify it
    9  * under the terms of the GNU Lesser General Public License as published by
   10  * the Free Software Foundation; either version 2.1 of the License, or
   11  * (at your option) any later version.
   12  *
   13  * This library is distributed in the hope that it will be useful, but
   14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
   16  * License for more details.
   17  *
   18  * You should have received a copy of the GNU Lesser General Public
   19  * License along with this library; if not, write to the Free Software
   20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
   21  * USA.
   22  */
   23 
   24 #ifndef METGM_CDMWRITERIMPL_HPP
   25 #define METGM_CDMWRITERIMPL_HPP
   26 
   27 // implementation stuff
   28 //
   29 #include "MetGmCDMVariableProfile.h"
   30 #include "MetGmConfigurationMappings.h"
   31 
   32 // fimex
   33 #include "fimex/CDMWriter.h"
   34 
   35 // standard
   36 //
   37 #include <map>
   38 #include <memory>
   39 #include <set>
   40 #include <string>
   41 #include <vector>
   42 
   43 namespace MetNoFimex {
   44 
   45 class CDMAttribute;
   46 class CDMVariable;
   47 class XMLDoc;
   48 
   49 /* forwrd decelarations */
   50 class MetGmVersion;
   51 class MetGmHandlePtr;
   52 class MetGmGroup3Ptr;
   53 class MetGmFileHandlePtr;
   54 class MetGmTags;
   55 class MetGmTimeTag;
   56 class MetGmXTag;
   57 class MetGmYTag;
   58 class MetGmTags;
   59 
   60 class MetGmCDMWriterImpl : public CDMWriter
   61 {
   62 public:
   63     /**
   64      * @param cdmReader dataSource
   65      * @param outputFile file-name to write to
   66      * @param configFile xml-configuration
   67      */
   68     explicit MetGmCDMWriterImpl(CDMReader_p cdmReader, const std::string& outputFile, const std::string& configFile);
   69 
   70     ~MetGmCDMWriterImpl();
   71 
   72     virtual void configureAndWrite();
   73 
   74     /**
   75      * @warning only public for testing
   76      * @return the new name of a variable, eventually changed by the writers config
   77      */
   78     const std::string& getVariableName(const std::string& varName) const;
   79     /**
   80      * @warning only public for testing
   81      * @return the new name of a dimension, eventually changed by the writers config
   82      */
   83     const std::string& getDimensionName(const std::string& dimName) const;
   84     /**
   85      * @warning only public for testing
   86      * @param varName original variable name  (before config: newname)
   87      * @param attName original attribute name (before config: newname)
   88      * @return an attribute contained in the writers attribute, possibly added by config
   89      */
   90     const CDMAttribute& getAttribute(const std::string& varName, const std::string& attName) const;
   91 
   92 protected:
   93     typedef std::shared_ptr<MetGmTags> MetGmTagsPtr;
   94 
   95     explicit MetGmCDMWriterImpl(CDMReader_p cdmReader, const std::string& outputFile);
   96 
   97     virtual void configure(const std::unique_ptr<XMLDoc>& doc);
   98     virtual void init();
   99     virtual void write();
  100 
  101     void writeGroup0Data();
  102     void writeGroup1Data();
  103     void writeGroup2Data();
  104     void writeHeader();
  105 
  106     void writeGroup3Data(const MetGmCDMVariableProfile& profile);
  107     void writeGroup3VerticalAxis(const MetGmTagsPtr& tags);
  108     void writeGroup3TimeAxis(const MetGmTagsPtr& tags);
  109     void writeGroup3HorizontalAxis(const MetGmTagsPtr& tags);
  110 
  111     void writeGroup4Data(const MetGmCDMVariableProfile& profile);
  112 
  113     virtual void writeGroup5Data(const MetGmCDMVariableProfile& profile, const CDMVariable* pVar);
  114 
  115 protected:
  116     std::unique_ptr<XMLDoc> xmlConfig_;
  117 
  118     std::shared_ptr<MetGmVersion> metgmVersion_;
  119     std::shared_ptr<MetGmHandlePtr> metgmHandle_;
  120     std::shared_ptr<MetGmFileHandlePtr> metgmFileHandle_;
  121     std::shared_ptr<MetGmTimeTag> metgmTimeTag_;
  122 
  123     xml_configuration xmlConfiguration_;
  124     cdm_configuration cdmConfiguration_;
  125 };
  126 
  127 } // namespace MetNoFimex
  128 
  129 #endif // METGM_CDMWRITERIMPL_HPP
  130