GridGain C++
compute_func.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 GridGain Systems, Inc. and Contributors.
3  *
4  * Licensed under the GridGain Community Edition License (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
22 #ifndef _IGNITE_COMPUTE_COMPUTE_FUNC
23 #define _IGNITE_COMPUTE_COMPUTE_FUNC
24 
25 namespace ignite
26 {
27  class Ignite;
28  class IgniteBinding;
29 
30  namespace compute
31  {
40  template<typename R>
42  {
43  template<typename TF, typename TR>
44  friend class ignite::impl::compute::ComputeJobHolderImpl;
45  friend class ignite::IgniteBinding;
46 
47  typedef R ReturnType;
48  public:
53  ignite(0)
54  {
55  // No-op.
56  }
57 
61  virtual ~ComputeFunc()
62  {
63  // No-op.
64  }
65 
71  virtual R Call() = 0;
72 
73  protected:
74  /*
75  * Get ignite node pointer.
76  * Return pointer to the node on which this function was called.
77  *
78  * @return Ignite node pointer.
79  */
80  Ignite& GetIgnite()
81  {
82  assert(ignite != 0);
83 
84  return *ignite;
85  }
86 
87  private:
88  /*
89  * Set ignite node pointer.
90  *
91  * @param ignite Ignite node pointer.
92  */
93  void SetIgnite(Ignite* ignite)
94  {
95  this->ignite = ignite;
96  }
97 
99  Ignite* ignite;
100  };
101  }
102 }
103 
104 #endif //_IGNITE_COMPUTE_COMPUTE_FUNC
ignite::IgniteBinding
Ignite Binding.
Definition: ignite_binding.h:37
ignite
Ignite API.
Definition: cache.h:47
ignite::compute::ComputeFunc::~ComputeFunc
virtual ~ComputeFunc()
Destructor.
Definition: compute_func.h:61
ignite::Ignite
Main interface to operate with Ignite.
Definition: ignite.h:44
ignite::compute::ComputeFunc
Interface for a simple compute function that can be serialized and called on the remote nodes.
Definition: compute_func.h:41
ignite::compute::ComputeFunc::Call
virtual R Call()=0
Called upon execution by compute.
ignite::compute::ComputeFunc::ComputeFunc
ComputeFunc()
Constructor.
Definition: compute_func.h:52