#ifndef OpenTestSystem_OtxDiagManager_OtxDiagApi_OtxDiagFactory_H
#define OpenTestSystem_OtxDiagManager_OtxDiagApi_OtxDiagFactory_H

#include "ApiDefs.h"
#include "TypeDefs.h"

#include <string>
#include <memory>

namespace OpenTestSystem { namespace OtxDiagManager {  namespace Client {
	class Client;
}}}

namespace OpenTestSystem { namespace OtxDiagManager {  namespace Common {
	class ICommandProcessor;
	class IDiagRuntimeSystem;
}}}

namespace OpenTestSystem {
	/// <summary>
	/// Namespace containing all objects for the communication to various, interchangeable diagnostic runtime systems, e.g. standardized MVCI-Server or proprietary diagnostic runtime systems.
	/// </summary>
	namespace OtxDiagManager {
	/// <summary>
	/// Namespace covering all actions and terms of all diagnostic related OTX extension by an identical mehod. Therfore this namespace is 100% OTX standard compliant. The specification can be found in ISO 13209 parts 3 and 4.
	/// </summary>
	namespace OtxDiagApi {
	class IOtxDiag;
	/// <summary>
	/// Factory class for creating the DiagOtxApi
	/// </summary>
	class OtxDiagFactory
	{
	public:
		API_EXPORTS OtxDiagFactory();
		API_EXPORTS virtual ~OtxDiagFactory();

		/// <summary>
		/// Creates a DiagManager instance using an existing client instance
		/// </summary>
		///
		/// <param name="client">Client for which a DiagManager is to be created</param>
		///
		/// <exception cref="OpenTestSystem::OtxDiagManager::OtxDiagApi::OtxDataTypes::DiagRuntimeException">Thrown if the license is invalid or expired.</exception>
		API_EXPORTS std::shared_ptr<IOtxDiag> CreateOtxDiag(std::shared_ptr<OpenTestSystem::OtxDiagManager::Client::Client> client);

		/// <summary>
		/// Creates a DiagManager instance inside a separate process with inter process communication via Sockets
		/// </summary>
		///
		/// <param name="port">Port number of the DiagManager server e.g. "8888"</param>
		///
		/// <exception cref="OpenTestSystem::OtxDiagManager::OtxDiagApi::OtxDataTypes::DiagRuntimeException">Thrown if the license is invalid or expired.</exception>
		API_EXPORTS std::shared_ptr<IOtxDiag> CreateSocketOtxDiag(unsigned short port);

		/// <summary>
		/// Creates a DiagManager instance inside a separate process with inter process communication via NamedPipe
		/// </summary>
		///
		/// <exception cref="OpenTestSystem::OtxDiagManager::OtxDiagApi::OtxDataTypes::DiagRuntimeException">Thrown if the license is invalid or expired.</exception>
		API_EXPORTS std::shared_ptr<IOtxDiag> CreatePipeOtxDiag(const std::string & pipeName);

		/// <summary>
		/// Creates a DiagManager instance inside the same process
		/// </summary>
		///
		/// <exception cref="OpenTestSystem::OtxDiagManager::OtxDiagApi::OtxDataTypes::DiagRuntimeException">Thrown if the license is invalid or expired.</exception>
		///
		/// **Example**
		/// @snippet CodeSampleSnippets.cpp SampleCode_CreateRawRuntimeManager
		API_EXPORTS std::shared_ptr<IOtxDiag> CreateRawOtxDiag(OpenTestSystem::OtxDiagManager::Common::ICommandProcessor *commandProcessor);

	private:
		class impl;
		std::unique_ptr<impl> pimpl;
	};
}}}
#endif // OpenTestSystem_OtxDiagManager_OtxDiagApi_OtxDiagFactory_H