Muesli
 All Classes Namespaces Files Functions Typedefs Enumerations
functor_base.h
1 /*
2  * functor_base.h
3  *
4  * Author: Steffen Ernsting <s.ernsting@uni-muenster.de>
5  *
6  * -------------------------------------------------------------------------------
7  *
8  * The MIT License
9  *
10  * Copyright 2014 Steffen Ernsting <s.ernsting@uni-muenster.de>,
11  * Herbert Kuchen <kuchen@uni-muenster.de.
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a copy
14  * of this software and associated documentation files (the "Software"), to deal
15  * in the Software without restriction, including without limitation the rights
16  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17  * copies of the Software, and to permit persons to whom the Software is
18  * furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included in
21  * all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29  * THE SOFTWARE.
30  *
31  */
32 
33 #pragma once
34 
35 #include <vector>
36 #include "lmatrix.h"
37 
38 namespace msl {
43 namespace detail {
44 
53 {
54 public:
59  : tile_width(-1), local_indices(false)
60  {
61  }
62 
68  bool useLocalIndices() const
69  {
70  return local_indices;
71  }
72 
79  void setLocalIndices(bool value)
80  {
81  local_indices = value;
82  }
83 
89  int getTileWidth() const
90  {
91  return tile_width;
92  }
93 
99  void setTileWidth(int value)
100  {
101  tile_width = value;
102  }
103 
107  void notify()
108  {
109  for (size_t i = 0; i < args.size(); i++) {
110  args.at(i)->update();
111  }
112  }
113 
120  {
121  args.push_back(arg);
122  }
123 
127  virtual ~FunctorBase()
128  {
129  }
130 
131 protected:
132  std::vector<ArgumentType*> args;
133  int tile_width;
134  bool local_indices;
135 };
136 
142 {
143 public:
152  void init(int nl, int ml, int fr, int fc)
153  {
154  nLocal = nl;
155  mLocal = ml;
156  firstRow = fr;
157  firstCol = fc;
158  }
159 
160 protected:
161  int nLocal, mLocal, firstRow, firstCol;
162 };
163 
169 {
170 public:
177  void init(int nl, int f)
178  {
179  nLocal = nl;
180  first = f;
181  }
182 
183 protected:
184  int nLocal, first;
185 };
186 
192 {
193 public:
197  void notify()
198  {
199  for (size_t i = 0; i < args.size(); i++) {
200  args.at(i)->update();
201  }
202  }
203 
210  {
211  args.push_back(arg);
212  }
213 protected:
214  std::vector<ArgumentType*> args;
215 };
216 
217 }
218 }
219 
220 
221 
222 
223 
224 
225 
226 
bool useLocalIndices() const
Checks whether indices are local or global.
Definition: functor_base.h:68
void addArgument(ArgumentType *arg)
Adds an additional argument to the functor.
Definition: functor_base.h:209
virtual ~FunctorBase()
Destructor.
Definition: functor_base.h:127
Class ArrayFunctorBase represents the base class for all functors to be used with any distributed arr...
Definition: functor_base.h:168
void setTileWidth(int value)
Sets the tile width.
Definition: functor_base.h:99
Class MatrixFunctorBase represents the base class for all functors to be used with any distributed ma...
Definition: functor_base.h:141
void init(int nl, int f)
Initializes its attributes.
Definition: functor_base.h:177
void notify()
Notifies all observed objects (additional arguments) to update.
Definition: functor_base.h:107
void setLocalIndices(bool value)
Use this function to configure your functor to use local indices instead of global indices...
Definition: functor_base.h:79
Class FunctorBase represents the base class for all functor classes.
Definition: functor_base.h:52
void init(int nl, int ml, int fr, int fc)
Initializes its attributes.
Definition: functor_base.h:152
void addArgument(ArgumentType *arg)
Adds an additional argument to the functor.
Definition: functor_base.h:119
FunctorBase()
Default constructor.
Definition: functor_base.h:58
int getTileWidth() const
Returns the tile_width. If tiling is not used, -1 will be returned.
Definition: functor_base.h:89
void notify()
Notifies all observed objects (additional arguments) to update.
Definition: functor_base.h:197
Base class for argument types of functors.
Definition: argtype.h:47
Class FarmFunctorBase represents the base class for all functors to be used with the farm skeleton...
Definition: functor_base.h:191