Flow123d  release_3.0.0-1192-gc7b86c0
functors_impl.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file functors_impl.hh
15  * @brief
16  */
17 
18 #ifndef FUNCTORBASE_IMPL_H
19 #define FUNCTORBASE_IMPL_H
20 
21 #include "tools/functors.hh"
22 #include "system/global_defs.h"
23 
24 /**************************************** FunctorCommon *****************************************/
25 template<class Type>
27 
28 template<class Type>
30 
31 template<class Type>
32 void FunctorCommon<Type>::set_param(unsigned int param_name, double param_value)
33 {
34  if(param_name < param_.size())
35  {
36  param_[param_name] = param_value;
37  }
38  else
39  {
40  param_.push_back(param_value);
41  }
42 }
43 
44 template<class Type>
45 template<class TType>
47 {
48  unsigned int n = func->param_.size();
49  //DebugOut().fmt("param_size = {}\n",n);
50  param_.resize(n);
51 
52  for(unsigned int i=0; i < n; i++) //copying vector
53  {
54  //DebugOut().fmt("get_param = {}\n",i);
55  param_[i] = func->param(i);
56  }
57 }
58 
59 template<class Type>
60 double FunctorCommon<Type>::param(unsigned int param_name)
61 {
62  OLD_ASSERT(param_name < param_.size(),"Parameter of the functor was not set.");
63 
64  return param_[param_name];
65 }
66 
67 
68 /************************************************ FunctorBase ************************************/
69 template<class Type>
71 
72 template<class Type>
74 
75 
76 /************************************************ IFunctorBase ***********************************/
77 template<class Type>
79 
80 template<class Type>
82 
83 
84 #endif //FUNCTORBASE_IMPL_H
void set_param(unsigned int param_name, double param_value)
Sets a functor&#39;s parameter.
std::vector< double > param_
Definition: functors.hh:71
Class provides common functionality for functors.
Definition: functors.hh:39
FunctorBase()
Constructor.
IFunctorBase()
Constructor.
virtual ~FunctorBase()
Destructor.
#define OLD_ASSERT(...)
Definition: global_defs.h:131
Global macros to enhance readability and debugging, general constants.
FunctorCommon()
Constructor.
virtual ~IFunctorBase()
Destructor.
void set_param_from_func(FunctorCommon< TType > *func)
Sets a functor&#39;s parameters from another functor.
virtual ~FunctorCommon()
Destructor.
double param(unsigned int param_name)
Returns parameter.