$treeview $search $mathjax
Palabos  Version 1.1
$projectbrief
$projectbrief
$searchbox

multiBlockIdentifiers2D.h

Go to the documentation of this file.
00001 /* This file is part of the Palabos library.
00002  *
00003  * Copyright (C) 2011 FlowKit Sarl
00004  * Avenue de Chailly 23
00005  * 1012 Lausanne, Switzerland
00006  * E-mail contact: contact@flowkit.com
00007  *
00008  * The most recent release of Palabos can be downloaded at 
00009  * <http://www.palabos.org/>
00010  *
00011  * The library Palabos is free software: you can redistribute it and/or
00012  * modify it under the terms of the GNU Affero General Public License as
00013  * published by the Free Software Foundation, either version 3 of the
00014  * License, or (at your option) any later version.
00015  *
00016  * The library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Affero General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Affero General Public License
00022  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00023 */
00024 
00025 
00026 #ifndef MULTI_BLOCK_IDENTIFIERS_2D_H
00027 #define MULTI_BLOCK_IDENTIFIERS_2D_H
00028 
00029 #include "core/globalDefs.h"
00030 #include "multiBlock/multiBlock2D.h"
00031 #include <string>
00032 #include <map>
00033 
00034 namespace plb {
00035 
00036 namespace meta {
00037 
00038 struct MultiBlockGenerator2D {
00039     virtual ~MultiBlockGenerator2D() { }
00040     virtual MultiBlock2D* generate(MultiBlockManagement2D const& manager, plint nDim) const =0;
00041 };
00042 
00043 template<class MultiBlockGenT>
00044 class SpecificMultiBlockGenerator2D : public MultiBlockGenerator2D
00045 {
00046 public:
00047     SpecificMultiBlockGenerator2D(MultiBlockGenT multiBlockGen_)
00048         : multiBlockGen(multiBlockGen_)
00049     { }
00050     virtual MultiBlock2D* generate(MultiBlockManagement2D const& manager, plint nDim) const {
00051         return multiBlockGen(manager, nDim).release();
00052     }
00053 private:
00054     MultiBlockGenT multiBlockGen;
00055 };
00056 
00057 class MultiBlockRegistration2D {
00058 public:
00059     typedef std::map<std::string, MultiBlockGenerator2D*> Str_gen_map;
00060     typedef std::map<std::string, Str_gen_map> Str_str_gen_map;
00061     typedef std::map<std::string, Str_str_gen_map> Str_str_str_gen_map;
00062 public:
00063     ~MultiBlockRegistration2D();
00064     int announce( std::string T_name, std::string Descriptor_name,
00065                   std::string nameOfMultiBlock, MultiBlockGenerator2D* generator);
00066     MultiBlock2D* generate (
00067                       std::string T_name, std::string Descriptor_name,
00068                       std::string nameOfMultiBlock,
00069                       MultiBlockManagement2D const& manager, plint nDim=0 );
00070 public:
00073     MultiBlockRegistration2D()
00074         : numRegistered(0)
00075     { }
00076 private:
00077     MultiBlockRegistration2D(MultiBlockRegistration2D const& rhs)
00078         : numRegistered(rhs.numRegistered)
00079     { }
00080     MultiBlockRegistration2D& operator=(MultiBlockRegistration2D const& rhs)
00081     {
00082         numRegistered = rhs.numRegistered;
00083         return *this;
00084     }
00085 private:
00086     int numRegistered;
00087     Str_str_str_gen_map generators;
00088 };
00089 
00090 MultiBlockRegistration2D& multiBlockRegistration2D();
00091 
00092 template<class MultiBlockGenT>
00093 int registerMultiBlock2D (
00094              std::string T_name, std::string Descriptor_name, std::string nameOfMultiBlock,
00095              MultiBlockGenT multiBlockGen )
00096 {
00097     return multiBlockRegistration2D().announce (
00098                T_name, Descriptor_name, nameOfMultiBlock,
00099                new SpecificMultiBlockGenerator2D<MultiBlockGenT>(multiBlockGen) );
00100 }
00101 
00102 }  // namespace meta
00103 
00104 }  // namespace plb
00105 
00106 #endif  // MULTI_BLOCK_IDENTIFIERS_2D_H