// header file:   Composite.hpp
// description:   Concrete Coder class which combines two Coder objects.
//                Design patterns: Strategy, concrete strategy; Composite.
//                No getters for 'first', 'second' since objects are immutable.
// variant:       2 with flexible composition
// author:        Karlheinz Hug
// creation date: 2012-07-06
// last update:   2012-08-09

#ifndef COMPOSITE_HPP_
#define COMPOSITE_HPP_

#include "Coder.hpp"

	class Composite : public Coder
	{
		public:
			Composite (Coder * const new_first, Coder * const new_second);
				// precondition: new_first != 0
				// precondition: new_second != 0

			virtual ~Composite ();

			virtual std::string name () const;

			virtual void encode (const std::vector<char> & source_buffer, std::vector<char> & target_buffer);
			virtual void decode (const std::vector<char> & source_buffer, std::vector<char> & target_buffer);
				// 'result()' may be 'failed_decode'.

		protected:
			Coder * const first,    // implementation invariant: first != 0
			      * const second;   // implementation invariant: second != 0
	};

#endif // COMPOSITE_HPP_
