#ifndef LINE_HPP_INCLUDED
#define LINE_HPP_INCLUDED

#include <iostream>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <vector>
#include <NBO/NBO/Marker_Type.h>
#include <NBO/NBO/Shape_Type.h>
#include <NBO/NBO/ENBOType.h>
#include <NBO/NBOGlobal.h>
#include <NBO/Shared/Base/NBOBaseClass.h>


namespace Inscoper::NBO {

/*!
* \brief Represents the XML element Line.
*
* A straight line defined by it's end points. 
*/
class NBO_EXPORT Line : public Shape_Type {

public:
	
	Line();
	~Line();

	/*!
	* \brief Cast a NBOBaseClass to a Line.
	*
	* \param base The base class to cast
	* \return The casted element, or nullptr if the cast fails
	*/
	static std::shared_ptr<Line> fromBase(NBOBaseClassPtr base);

	/*!
	* \brief Returns the class type name.
	*
	* \return The class type name
	*/
	std::string getTypeName() const override;

	/*!
	* \brief Returns the XML element name corresponding to this class.
	*
	* \return The XML element name
	*/
	std::string getXMLName() const override;

	/*!
	* \brief Returns the NBO Type corresponding to this class.
	*
	* \return The NBO Type value
	*/
	ENBOType getNBOType() const override;

	/*!
	* \brief Returns a list of all classes derived from this class.
	*
	* \return The list of derived classes
	*/
	std::vector<NBOBaseClassPtr> getChildren() const override;

	/*!
	* \brief Returns a list of all child elements contained in this class.
	*
	* \return The list of child classes
	*/
	std::vector<NBOBaseClassPtr> getSubElements() const override;

	/*!
	* \brief Populates this object from a JSON file.
	*
	* \param path The path to the JSON file
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void fromJsonFile(const std::string& path, bool validate = true);

	/*!
	* \brief Populates this object from a JSON string.
	*
	* \param json_string The JSON content as a string
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void fromJsonString(const std::string& json_string, bool validate = true);

	/*!
	* \brief Populates this object from a XML file.
	*
	* \param path The path to the XML file
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void fromXmlFile(const std::string& path, bool validate = true);

	/*!
	* \brief Populates this object from a XML string.
	*
	* \param xml_string The XML content as a string
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void fromXmlString(const std::string& xml_string, bool validate = true);

	/*!
	* \brief Serializes this object to an XML file.
	*
	* \param filename The path to the output XML file
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void toXmlFile(const std::string& filename, bool validate = true) const;

	/*!
	* \brief Serializes this object to an XML string.
	*
	* \param validate If true, validates constraints on value. Default is true.
	* \return A string containing the XML representation of this object
	*/
	std::string toXmlString(bool validate = true) const;

	/*!
	* \brief Sets the value of the X1 attribute.
	*
	* The X coordinate of the start of the line. [units pixels] 
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setX1(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the X1 attribute.
	*
	* The X coordinate of the start of the line. [units pixels] 
	*
	* \return The value of the attribute
	*/
	float getX1() const;

	/*!
	* \brief Resets the X1 attribute to an unset state.
	*
	* The X coordinate of the start of the line. [units pixels] 
	*/
	void resetX1();

	/*!
	* \brief Checks whether the X1 attribute is present.
	*
	* The X coordinate of the start of the line. [units pixels] 
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasX1() const;

	/*!
	* \brief Sets the value of the Y1 attribute.
	*
	* The Y coordinate of the start of the line. [units pixels] 
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setY1(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the Y1 attribute.
	*
	* The Y coordinate of the start of the line. [units pixels] 
	*
	* \return The value of the attribute
	*/
	float getY1() const;

	/*!
	* \brief Resets the Y1 attribute to an unset state.
	*
	* The Y coordinate of the start of the line. [units pixels] 
	*/
	void resetY1();

	/*!
	* \brief Checks whether the Y1 attribute is present.
	*
	* The Y coordinate of the start of the line. [units pixels] 
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasY1() const;

	/*!
	* \brief Sets the value of the X2 attribute.
	*
	* The X coordinate of the end of the line. [units pixels] 
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setX2(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the X2 attribute.
	*
	* The X coordinate of the end of the line. [units pixels] 
	*
	* \return The value of the attribute
	*/
	float getX2() const;

	/*!
	* \brief Resets the X2 attribute to an unset state.
	*
	* The X coordinate of the end of the line. [units pixels] 
	*/
	void resetX2();

	/*!
	* \brief Checks whether the X2 attribute is present.
	*
	* The X coordinate of the end of the line. [units pixels] 
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasX2() const;

	/*!
	* \brief Sets the value of the Y2 attribute.
	*
	* The Y coordinate of the end of the line. [units pixels] 
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setY2(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the Y2 attribute.
	*
	* The Y coordinate of the end of the line. [units pixels] 
	*
	* \return The value of the attribute
	*/
	float getY2() const;

	/*!
	* \brief Resets the Y2 attribute to an unset state.
	*
	* The Y coordinate of the end of the line. [units pixels] 
	*/
	void resetY2();

	/*!
	* \brief Checks whether the Y2 attribute is present.
	*
	* The Y coordinate of the end of the line. [units pixels] 
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasY2() const;

	/*!
	* \brief Sets the value of the MarkerStart attribute.
	*
	* No description available in the XSD standard.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setMarkerStart(const Inscoper::NBO::Marker_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the MarkerStart attribute.
	*
	* No description available in the XSD standard.
	*
	* \return The value of the attribute
	*/
	Marker_TypePtr getMarkerStart() const;

	/*!
	* \brief Resets the MarkerStart attribute to an unset state.
	*
	* No description available in the XSD standard.
	*/
	void resetMarkerStart();

	/*!
	* \brief Checks whether the optional MarkerStart attribute is present.
	*
	* No description available in the XSD standard.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasMarkerStart() const;

	/*!
	* \brief Sets the value of the MarkerEnd attribute.
	*
	* No description available in the XSD standard.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setMarkerEnd(const Inscoper::NBO::Marker_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the MarkerEnd attribute.
	*
	* No description available in the XSD standard.
	*
	* \return The value of the attribute
	*/
	Marker_TypePtr getMarkerEnd() const;

	/*!
	* \brief Resets the MarkerEnd attribute to an unset state.
	*
	* No description available in the XSD standard.
	*/
	void resetMarkerEnd();

	/*!
	* \brief Checks whether the optional MarkerEnd attribute is present.
	*
	* No description available in the XSD standard.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasMarkerEnd() const;


private:
	class Impl;
	std::unique_ptr<Impl> pImpl;

    std::optional<float> X1; // Required attribute
    std::optional<float> Y1; // Required attribute
    std::optional<float> X2; // Required attribute
    std::optional<float> Y2; // Required attribute
	Marker_TypePtr MarkerStart = nullptr; // Optional attribute
	Marker_TypePtr MarkerEnd = nullptr; // Optional attribute
};

/*! Shared pointer for Line*/
typedef std::shared_ptr<Line> LinePtr;

} // namespace Inscoper::NBO

#endif // LINE_HPP_INCLUDED