#ifndef OpenTestSystem_OtxDiagManager_Common_ICommandProcessor_H
#define OpenTestSystem_OtxDiagManager_Common_ICommandProcessor_H

#include "CommonDefs.h"
#include "CommonClasses.h"
#include <functional>

namespace OpenTestSystem
{
	namespace OtxDiagManager
	{
		namespace Common
		{
			class COMMON_EXPORTS ICommandProcessor
			{
			protected:
				ICommandProcessor() {};

			public:
				virtual ~ICommandProcessor() {};

				/// <summary>
				/// Execute the command synchronously.
				/// </summary>
				/// <param name="command"> The command to execute. It contains the kind of service need to be execute, parameters, etc. </param>
				/// <returns> Result type object, contains the result of the execution </returns>
				virtual Result * Execute(const Command & cmd) = 0;

				/// <summary>
				/// Execute the command asynchronously, within another thread.
				/// </summary>
				/// <param name="command"> The command to execute. It contains the kind of service need to be execute, parameters, etc </param>
				/// <returns> Result type object, contains the result of the execution </returns>
				virtual Result * ExecuteAsync(const Command & command) = 0;

				/// <summary>
				/// Set an async result handler into CommandProcessor. 
				/// </summary>
				/// <remarks>
				/// At asynchonous execution, the CommandProcessor will call and give the result to the set handler when the execution finishes.
				/// </remarks>
				/// <param name="handler"> the function will handle the result. </param>
				virtual void SetAsyncResultHandler(std::function<void(const Result&)> handler) = 0;

				/// <summary>
				/// Set an exception handler into CommandProcessor. 
				/// </summary>
				/// <remarks>
				/// At asynchonous execution, the CommandProcessor will call and give the exception to the set handler when the execution has an exception.
				/// </remarks>
				/// <param name="handler"> the function will handle the Exception. </param>
				virtual void SetExceptionHandler(std::function<void(const Exception&)> handler) = 0;
			};
		}
	}
}
#endif // OpenTestSystem_OtxDiagManager_Common_ICommandProcessor_H
