URI: 
       tFactory.hh - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
  HTML git clone git://src.adamsgaard.dk/pism
   DIR Log
   DIR Files
   DIR Refs
   DIR LICENSE
       ---
       tFactory.hh (2379B)
       ---
            1 // Copyright (C) 2011, 2014, 2015, 2017, 2018, 2019 PISM Authors
            2 //
            3 // This file is part of PISM.
            4 //
            5 // PISM is free software; you can redistribute it and/or modify it under the
            6 // terms of the GNU General Public License as published by the Free Software
            7 // Foundation; either version 3 of the License, or (at your option) any later
            8 // version.
            9 //
           10 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
           11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
           12 // FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
           13 // details.
           14 //
           15 // You should have received a copy of the GNU General Public License
           16 // along with PISM; if not, write to the Free Software
           17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
           18 
           19 #ifndef _PSFACTORY_H_
           20 #define _PSFACTORY_H_
           21 
           22 #include "pism/coupler/SurfaceModel.hh"
           23 #include "pism/coupler/util/PCFactory.hh"
           24 
           25 namespace pism {
           26 namespace surface {
           27 class Factory : public PCFactory<SurfaceModel> {
           28 public:
           29   typedef atmosphere::AtmosphereModel InputModel;
           30   Factory(IceGrid::ConstPtr g, std::shared_ptr<InputModel> input);
           31   ~Factory();
           32 
           33   using PCFactory<SurfaceModel>::create;
           34   std::shared_ptr<SurfaceModel> create(const std::string &type);
           35 
           36 private:
           37   class SurfaceModelCreator {
           38   public:
           39     virtual std::shared_ptr<SurfaceModel> create(IceGrid::ConstPtr grid,
           40                                                  std::shared_ptr<InputModel> input) = 0;
           41     virtual ~SurfaceModelCreator() {}
           42   };
           43 
           44   // Creator for a specific model class M.
           45   template <class M>
           46   class SpecificSurfaceModelCreator : public SurfaceModelCreator {
           47   public:
           48     std::shared_ptr<SurfaceModel> create(IceGrid::ConstPtr grid,
           49                                          std::shared_ptr<InputModel> input) {
           50       return std::shared_ptr<SurfaceModel>(new M(grid, input));
           51     }
           52   };
           53 
           54   template <class M>
           55   void add_surface_model(const std::string &name) {
           56     m_surface_models[name].reset(new SpecificSurfaceModelCreator<M>);
           57   }
           58 
           59   std::shared_ptr<SurfaceModel> surface_model(const std::string &type,
           60                                               std::shared_ptr<InputModel> input);
           61 
           62   std::shared_ptr<InputModel> m_input;
           63 
           64   std::map<std::string, std::shared_ptr<SurfaceModelCreator> > m_surface_models;
           65 };
           66 } // end of namespace surface
           67 } // end of namespace pism
           68 
           69 #endif /* _PSFACTORY_H_ */