| Apache Ignite C++

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