Templates -- Meow  2.0.-1
A C++ template contains kinds of interesting classes and functions
operation.h
Go to the documentation of this file.
1 
8 #ifndef __MEOWPP_UTILITY_OPERATION_H__
9 #define __MEOWPP_UTILITY_OPERATION_H__
10 
11 #include "../debug/assert.h"
12 #include "object.h"
13 #include "pointer.h"
14 #include "state.h"
15 
16 namespace meow {
17 
18 
22 class Operation : public Object {
23  private:
24  int inputs_size_;
25  int outputs_size_;
26 
27  protected:
28 
35  Operation(int arg_inputs_size, int arg_outputs_size) :
36  inputs_size_(arg_inputs_size), outputs_size_(arg_outputs_size) {}
37 
38  public:
39 
43  virtual ~Operation() {}
44 
53  virtual State Operate(Pointer<Object const> const * inputs_ptr,
54  Pointer<Object> const * outputs_ptr) const = 0;
55 
60  int inputs_size() const {
61  return inputs_size_;
62  }
63 
68  int outputs_size() const {
69  return outputs_size_;
70  }
71 
72 #ifdef MEOWPP_UTILITY_OPERATION_TESTING
73  friend class OperationTest;
74 #endif // MEOWPP_UTILITY_OPERATION_TESTING
75 
76 };
77 
78 } // meow
79 
80 #endif // __MEOWPP_UTILITY_OPERATION_H__
A pointer points to the template Type.
Definition: pointer.h:33
Operation(int arg_inputs_size, int arg_outputs_size)
A protected constructor to prevent developers create an instance of Operation directly.
Definition: operation.h:35
virtual ~Operation()
Virtual destructor.
Definition: operation.h:43
Base class for operations.
Definition: operation.h:22
The base class.
Definition: object.h:20
Contains a base class for most of all the classes in meowpp.
Contains a base class for a state (in meowpp, most of all the return value of a function (or to say...
virtual State Operate(Pointer< Object const > const *inputs_ptr, Pointer< Object > const *outputs_ptr) const =0
Pure virtual method for running the operation.
Contains a pointer class which has a counter-mechanism to prevent memory leak.
The base class for state.
Definition: state.h:51
int inputs_size() const
Gets the number of inputs for the operation.
Definition: operation.h:60
int outputs_size() const
Gets the number of outputs for the operation.
Definition: operation.h:68