// header file:   Coder.hpp
// description:   General concept and interface class for coding using a source and a target buffer.
//                Design pattern: Strategy. FileCoder is context, Coder is abstract strategy.
//                Design scheme for bad cases: Action-query.
// variant:       2 with flexible composition
// author:        Karlheinz Hug
// creation date: 2012-07-05
// last update:   2012-08-09

#ifndef CODER_HPP_
#define CODER_HPP_

#include <string>
#include <vector>

	class Coder
	{
		public:
			virtual std::string name () const;

			virtual void encode (const std::vector<char> & source_buffer, std::vector<char> & target_buffer) = 0;
			virtual void decode (const std::vector<char> & source_buffer, std::vector<char> & target_buffer) = 0;
				// 'encode' and 'decode' must be inverse to each other, i.e. for each 'a', 'b', 'c',
				// after 'encode(a, b); decode(b, c);', the contents of 'a' and 'c' must be equal.

			int result () const {return a_result;}

			static const int done          = 0;
			static const int failed_decode = 11;
				// Values for result().

		protected:
			int a_result;
	};

#endif // CODER_HPP_
