#ifndef OpenTestSystem_OtxDiagManager_SystemApi_Util_H
#define OpenTestSystem_OtxDiagManager_SystemApi_Util_H

#include "ApiDefs.h"
#include <string>
#include <memory>

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

namespace OpenTestSystem { namespace OtxDiagManager { namespace Common {
	class ILog;
}}}

namespace OpenTestSystem { namespace OtxDiagManager { 
	/// <summary>
	/// Namespace containing all commands that are not standardized in OTX and are generally required, e.g. System versions of all relevant modules
	/// </summary>
	namespace SystemApi {
	/// <summary>
	/// Class for general utils
	/// </summary>
	class API_EXPORTS Util
	{
	private:
		Util() {}
		~Util() {}
		static OpenTestSystem::OtxDiagManager::Common::ILog *_log;
	public:
		/// <summary>
		/// Sets a name for a client
		/// </summary>
		/// <param name="client">Client, which name is set</param>
		/// <param name="clientName">Name of the client. The name should not be longer than 15 characters.</param>
		static void SetClientName(std::shared_ptr<OpenTestSystem::OtxDiagManager::Client::Client> client, const std::string & clientName);

		/// <summary>
		/// Checks, if the server is alive.
		/// </summary>
		/// <param name="port">Port number of the DiagManager server e.g. "8888"</param>
		/// <returns>Returns TRUE if the server is alive, otherwise FALSE. A server is alive, if it has been started and has not yet died.</returns>
		static bool IsAlive(unsigned short port);

		/// <summary>
		/// Checks, if the server is alive.
		/// </summary>
		/// <param name="pipeName">Pipe name which the DiagManager listens on</param>
		/// <returns>Returns TRUE if the server is alive, otherwise FALSE. A server is alive, if it has been started and has not yet died.</returns>
		static bool IsAlive(const std::string & pipeName);

		/// <summary>
		/// Sets a valid license key to active DiagManagerServer
		/// </summary>
		/// <param name="port">Port number of the DiagManager server e.g. "8888"</param>
		/// <param name="licenseKey">License key has the format "XXXX-XXXX-XXXX-XXXX-XXXX".</param>
		static void SetLicenseKey(unsigned short port, std::string& licenseKey);

		/// <summary>
		/// Sets a valid license key to active DiagManagerServer
		/// </summary>
		/// <param name="pipeName">Pipe name which the DiagManager listens on</param>
		/// <param name="licenseKey">License key has the format "XXXX-XXXX-XXXX-XXXX-XXXX".</param>
		static void SetLicenseKey(const std::string & pipeName, std::string& licenseKey);

		/// <summary>
		/// Sets a valid license key to active DiagManagerServer
		/// </summary>
		/// <param name="client">Client, which sends the request to active DiagManagerServerServer</param>
		/// <param name="licenseKey">License key has the format "XXXX-XXXX-XXXX-XXXX-XXXX".</param>
		static void SetLicenseKey(std::shared_ptr<OpenTestSystem::OtxDiagManager::Client::Client> client, std::string& licenseKey);
	};
}}}
#endif//OpenTestSystem_OtxDiagManager_SystemApi_Util_H