aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/utility/operation.h
diff options
context:
space:
mode:
Diffstat (limited to 'meowpp/utility/operation.h')
-rw-r--r--meowpp/utility/operation.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/meowpp/utility/operation.h b/meowpp/utility/operation.h
new file mode 100644
index 0000000..d595668
--- /dev/null
+++ b/meowpp/utility/operation.h
@@ -0,0 +1,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__