blob: d5956682e5258b9d39601542916974ff45a9c632 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*!
* @file operation.h
* @brief Contains a base class for most of all operations in meowpp.
*
* @author cathook
*/
#ifndef __MEOWPP_UTILITY_OPERATION_H__
#define __MEOWPP_UTILITY_OPERATION_H__
#include "../debug/assert.h"
#include "object.h"
#include "pointer.h"
#include "state.h"
namespace meow {
/*!
* @brief Base class for operations.
*/
class Operation : public Object {
private:
int inputs_size_;
int outputs_size_;
protected:
/*!
* @brief A protected constructor to prevent developers create an instance of
* Operation directly.
* @param arg_inputs_size Number of inputs for the operation.
* @param arg_outputs_size Number of outputs for the operation.
*/
Operation(int arg_inputs_size, int arg_outputs_size) :
inputs_size_(arg_inputs_size), outputs_size_(arg_outputs_size) {}
public:
/*!
* @brief Virtual destructor.
*/
virtual ~Operation() {}
/*!
* @brief Pure virtual method for running the operation.
* @param [in] inputs_ptr An array with each elements being a pointer points
* to the input elements.
* @param [out] outputs_ptr An array with each elements being a pointer points
* to the output elements.
* @return The state of the operation (ex: fail, success, ...)
*/
virtual State Operate(Pointer<Object const> const * inputs_ptr,
Pointer<Object> const * outputs_ptr) const = 0;
/*!
* @brief Gets the number of inputs for the operation.
* @return Number of inputs.
*/
int inputs_size() const {
return inputs_size_;
}
/*!
* @brief Gets the number of outputs for the operation.
* @return Number of outputs.
*/
int outputs_size() const {
return outputs_size_;
}
#ifdef MEOWPP_UTILITY_OPERATION_TESTING
friend class OperationTest;
#endif // MEOWPP_UTILITY_OPERATION_TESTING
};
} // meow
#endif // __MEOWPP_UTILITY_OPERATION_H__
|