#ifndef OpenTestSystem_OtxDiagManager_Server_ServerFactory_H
#define OpenTestSystem_OtxDiagManager_Server_ServerFactory_H

#include "ServerDefs.h"
#include "Server.h"
#include <memory>

namespace OpenTestSystem
{
	namespace OtxDiagManager
	{
		/// <summary>
		/// Namespace containing all methods for the DiagManager server
		/// </summary>
		namespace Server
		{
			/// <summary>
			/// Types of the DiagManager server
			/// </summary>
			enum SERVER_DEFS ServerType
			{
				/// <summary>
				/// The DiagManager server listens on a socket port
				/// </summary>
				Socket,
				/// <summary>
				/// The DiagManager server has no inter process communication. It is inside the process off the application.
				/// </summary>
				Raw,
				/// <summary>
				/// The DiagManager server listens on a named pipe
				/// </summary>
				Pipe
			};
			
			/// <summary>
			/// DiagManager server with inter process communication via socket
			/// </summary>
			class SocketServer;
			/// <summary>
			/// DiagManager server without inter process communication. The server is inside the process of the application.
			/// </summary>
			class RawServer;
			/// <summary>
			/// DiagManager server with inter process communication via named pipes
			/// </summary>
			class PipeServer;

			/// <summary>
			/// Creates the DiagManager server
			/// </summary>
			class SERVER_DEFS ServerFactory
			{
			public:
				ServerFactory();
				virtual ~ServerFactory();
				/// <summary>
				/// Creates DiagManager server of the given server type
				/// </summary>
				/// <returns>A DiagManager server instance</returns>
				/// <param name="serverType">Type of the server</param>
				Server* Create(ServerType serverType);
				/// <summary>
				/// Sets the port of the server of server type SOCKET
				/// </summary>
				/// <param name="port">Port number which the DiagManager server listens on, e.g. 8888</param>
				void SetSocketPort(const int& port);

			private:
				SocketServer* _socketServer;
				RawServer* _rawServer;
				PipeServer* _pipeServer;
				int _socketPort;
			};
		}
	}
}
#endif // OpenTestSystem_OtxDiagManager_Server_ServerFactory_H