addToRunTimeSelectionTable.H 6.13 KB
Newer Older
1 2 3 4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           | www.openfoam.com
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2016 OpenFOAM Foundation
9 10 11 12
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

13 14 15 16
    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
17 18 19 20 21 22 23

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
24
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
25 26

Description
27
    Macros for easy insertion into run-time selection tables
28 29 30 31 32 33 34 35

\*---------------------------------------------------------------------------*/

#ifndef addToRunTimeSelectionTable_H
#define addToRunTimeSelectionTable_H

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

36
//- Add to hash-table of functions with typename as the key
37
#define addToRunTimeSelectionTable\
38 39 40 41
(baseType,thisType,argNames)                                                   \
                                                                               \
    /* Add the thisType constructor function to the table */                   \
    baseType::add##argNames##ConstructorToTable<thisType>                      \
42 43
        add##thisType##argNames##ConstructorTo##baseType##Table_

44

45
//- Add to hash-table of functions with 'lookup' as the key
46
#define addNamedToRunTimeSelectionTable\
47 48 49 50 51
(baseType,thisType,argNames,lookup)                                            \
                                                                               \
    /* Add the thisType constructor function to the table, find by lookup */   \
    baseType::add##argNames##ConstructorToTable<thisType>                      \
        add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_   \
52
        (#lookup)
53

54

55
//- Add to hash-table of functions with typename as the key
56
#define addRemovableToRunTimeSelectionTable\
57 58 59 60
(baseType,thisType,argNames)                                                   \
                                                                               \
    /* Add the thisType constructor function to the table */                   \
    baseType::addRemovable##argNames##ConstructorToTable<thisType>             \
61 62 63
        addRemovable##thisType##argNames##ConstructorTo##baseType##Table_


64
//- Add to hash-table of functions with 'lookup' as the key
65
#define addRemovableNamedToRunTimeSelectionTable\
66 67 68 69 70
(baseType,thisType,argNames,lookup)                                            \
                                                                               \
    /* Add the thisType constructor function to the table, find by lookup */   \
    baseType::addRemovable##argNames##ConstructorToTable<thisType>             \
        addRemovable_##lookup##_##thisType##argNames##ConstructorTo            \
71 72 73
        ##baseType##Table_(#lookup)


74 75
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

76 77
//- Add to hash-table of functions with typename as the key.
//  Use when baseType doesn't need a template argument (eg, is a typedef)
78
#define addTemplateToRunTimeSelectionTable\
79 80 81 82
(baseType,thisType,Targ,argNames)                                              \
                                                                               \
    /* Add the thisType constructor function to the table */                   \
    baseType::add##argNames##ConstructorToTable<thisType<Targ>>                \
83 84
        add##thisType##Targ##argNames##ConstructorTo##baseType##Table_

85

86 87
//- Add to hash-table of functions with 'lookup' as the key.
//  Use when baseType doesn't need a template argument (eg, is a typedef)
88
#define addNamedTemplateToRunTimeSelectionTable\
89 90 91 92 93
(baseType,thisType,Targ,argNames,lookup)                                       \
                                                                               \
    /* Add the thisType constructor function to the table, find by lookup */   \
    baseType::add##argNames##ConstructorToTable<thisType<Targ>>                \
        add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType     \
94
        ##Table_(#lookup)
95

96 97 98

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

99 100
//- Add to hash-table of functions with typename as the key.
//  Use when baseType requires the Targ template argument as well
101
#define addTemplatedToRunTimeSelectionTable\
102 103 104 105
(baseType,thisType,Targ,argNames)                                              \
                                                                               \
    /* Add the thisType constructor function to the table */                   \
    baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ>>          \
106 107
        add##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_

108

109 110
//- Add to hash-table of functions with 'lookup' as the key.
//  Use when baseType requires the Targ template argument as well
111
#define addNamedTemplatedToRunTimeSelectionTable\
112 113 114 115 116
(baseType,thisType,Targ,argNames,lookup)                                       \
                                                                               \
    /* Add the thisType constructor function to the table, find by lookup */   \
    baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ>>          \
        add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType##   \
117
        Targ##Table_(#lookup)
118

119

120 121 122 123 124
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //