Flow123d  3.9.0-127d9ed9b
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/asserts.hh"
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  ASSERT_PERMANENT_LT(param_name, param_.size()).error("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
FunctorCommon::param
double param(unsigned int param_name)
Returns parameter.
Definition: functors_impl.hh:60
IFunctorBase::IFunctorBase
IFunctorBase()
Constructor.
Definition: functors_impl.hh:78
ASSERT_PERMANENT_LT
#define ASSERT_PERMANENT_LT(a, b)
Definition of comparative assert macro (Less Than)
Definition: asserts.hh:297
asserts.hh
Definitions of ASSERTS.
FunctorCommon::set_param
void set_param(unsigned int param_name, double param_value)
Sets a functor's parameter.
Definition: functors_impl.hh:32
FunctorCommon::param_
std::vector< double > param_
Definition: functors.hh:68
FunctorCommon::FunctorCommon
friend class FunctorCommon
Setting these friend classes to be able to access param_ vector.
Definition: functors.hh:71
FunctorBase::~FunctorBase
virtual ~FunctorBase()
Destructor.
Definition: functors_impl.hh:73
FunctorBase::FunctorBase
FunctorBase()
Constructor.
Definition: functors_impl.hh:70
FunctorCommon::~FunctorCommon
virtual ~FunctorCommon()
Destructor.
Definition: functors_impl.hh:29
FunctorCommon::set_param_from_func
void set_param_from_func(FunctorCommon< TType > *func)
Sets a functor's parameters from another functor.
Definition: functors_impl.hh:46
IFunctorBase::~IFunctorBase
virtual ~IFunctorBase()
Destructor.
Definition: functors_impl.hh:81
functors.hh
FunctorCommon
Class provides common functionality for functors.
Definition: functors.hh:36