diff options
author | cathook <b01902109@csie.ntu.edu.tw> | 2014-09-24 13:37:42 +0800 |
---|---|---|
committer | cathook <b01902109@csie.ntu.edu.tw> | 2014-09-29 16:55:57 +0800 |
commit | 8b76fbb408f8eedab24195655c45c891af01eaab (patch) | |
tree | 414d7fc87885cb77e181a3ab99e334b837621036 /meowpp/utility/operation.h | |
parent | ef9af0d577c3a6b5d11fdeed7a9149d09973171b (diff) | |
download | meow-8b76fbb408f8eedab24195655c45c891af01eaab.tar meow-8b76fbb408f8eedab24195655c45c891af01eaab.tar.gz meow-8b76fbb408f8eedab24195655c45c891af01eaab.tar.bz2 meow-8b76fbb408f8eedab24195655c45c891af01eaab.tar.lz meow-8b76fbb408f8eedab24195655c45c891af01eaab.tar.xz meow-8b76fbb408f8eedab24195655c45c891af01eaab.tar.zst meow-8b76fbb408f8eedab24195655c45c891af01eaab.zip |
Big change, detail see README.
Diffstat (limited to 'meowpp/utility/operation.h')
-rw-r--r-- | meowpp/utility/operation.h | 80 |
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__ |