/**
 * \file    M_Xml.hpp
 * \author  Silvan Murer
 * \date    01 Aug 2022
 *
 * \brief   Internal class helps for get access to the XML content of a GenTL component (interface, device, ...)
 */

#ifndef SRC_M_XML
#define SRC_M_XML

#include "GTL_Producer.hpp"
#include "Mimic_Exception.hpp"

namespace mimic {

/**
 * static helpe class for XML (device description) file access
 */
class M_Xml {
private:
	M_Xml() {};

public:
	~M_Xml() {};

	/**
	 * \brief	reading the number of available XML (device dexription) files
	 *
	 * \param[in]     hPort       handle of the GenTL port
	 *
	 * \return        the numbrer of available XML (device description) files
	 * 
	 * \exception     GS_GenTL_Exception	is thrown when GenTL producer returns an error
	 */
	static uint32_t getNofXMLs(std::shared_ptr<genSDK::GTL_Producer> gtl_producer, GenTL::PORT_HANDLE hPort);

	/**
	 * \brief	reading the meta information where the XML (device description) file is
	 *
	 * The method reads the xml file name, its size and address where to read the file.
	 * Now, the method just returns the information of the first XML file.
	 *
	 * \param[in]     hPort       handle of the GenTL port
	 * \param[in]     urlIdx      url index where the meta information is read from
	 * \param[out]    xmlName     XML file name
	 * \param[out]    xmlAddress  XML file address where it could be read on the port
	 * \param[out]    xmlSize     XML file size
	 * 
	 * \exception     GS_GenTL_Exception	   is thrown when GenTL producer returns an error
	 *                GS_OutOfRange_Exception  if the given urlIdx out of range
	 */
	static void getXMLInfo(std::shared_ptr<genSDK::GTL_Producer> gtl_producer, GenTL::PORT_HANDLE hPort, uint32_t urlIdx, std::string& xmlName, uint64_t& xmlAddress, uint64_t& xmlSize);
	static std::string getXMLContent(std::shared_ptr<genSDK::GTL_Producer> gtl_producer, GenTL::PORT_HANDLE hPort, uint64_t xmlAddress, uint64_t xmlSize);

};

} /* namespace genSDK */

#endif
