#ifndef COVERGLASS_HPP_INCLUDED
#define COVERGLASS_HPP_INCLUDED

#include <iostream>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <vector>
#include <NBO/NBO/CoverGlassNr_Type.h>
#include <NBO/NBO/LSID_Type.h>
#include <NBO/NBO/ManufacturerSpec_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 CoverGlass.
*
* This element describes a rectangular or circular piece of thin glass used to cover a microscopical preparation.
*/
class NBO_EXPORT CoverGlass : public ManufacturerSpec_Type {

public:
	
	CoverGlass();
	~CoverGlass();

	/*!
	* \brief Cast a NBOBaseClass to a CoverGlass.
	*
	* \param base The base class to cast
	* \return The casted element, or nullptr if the cast fails
	*/
	static std::shared_ptr<CoverGlass> 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 ID attribute.
	*
	* A Unique Identifier for this component.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setID(const Inscoper::NBO::LSID_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the ID attribute.
	*
	* A Unique Identifier for this component.
	*
	* \return The value of the attribute
	*/
	LSID_TypePtr getID() const;

	/*!
	* \brief Resets the ID attribute to an unset state.
	*
	* A Unique Identifier for this component.
	*/
	void resetID();

	/*!
	* \brief Checks whether the optional ID attribute is present.
	*
	* A Unique Identifier for this component.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasID() const;

	/*!
	* \brief Sets the value of the Coating attribute.
	*
	* This field reports a description for any Coating that was layered on the Cover Glass, either by the Manufacturer or after purchase (e.g., Poly-L-Lysine, Collagen).
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setCoating(const std::string& value, bool validate = true);

	/*!
	* \brief Returns the value of the Coating attribute.
	*
	* This field reports a description for any Coating that was layered on the Cover Glass, either by the Manufacturer or after purchase (e.g., Poly-L-Lysine, Collagen).
	*
	* \return The value of the attribute
	*/
	std::string getCoating() const;

	/*!
	* \brief Resets the Coating attribute to an unset state.
	*
	* This field reports a description for any Coating that was layered on the Cover Glass, either by the Manufacturer or after purchase (e.g., Poly-L-Lysine, Collagen).
	*/
	void resetCoating();

	/*!
	* \brief Checks whether the Coating attribute is present.
	*
	* This field reports a description for any Coating that was layered on the Cover Glass, either by the Manufacturer or after purchase (e.g., Poly-L-Lysine, Collagen).
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasCoating() const;

	/*!
	* \brief Returns the allowed values for this attribut.
	*
	* This field reports a description for any Coating that was layered on the Cover Glass, either by the Manufacturer or after purchase (e.g., Poly-L-Lysine, Collagen).
	*
	* \return The list of allowed values
	*/
	static const std::set<std::string>& getCoatingAllowedValues();

	/*!
	* \brief Sets the value of the CoverGlassNo attribute.
	*
	* This fields reports the numerical designation that describes the expected thickness of this Coverslip (e.g., #1.5) and the relative expected thickness range expressed in mm.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setCoverGlassNo(const Inscoper::NBO::CoverGlassNr_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the CoverGlassNo attribute.
	*
	* This fields reports the numerical designation that describes the expected thickness of this Coverslip (e.g., #1.5) and the relative expected thickness range expressed in mm.
	*
	* \return The value of the attribute
	*/
	CoverGlassNr_TypePtr getCoverGlassNo() const;

	/*!
	* \brief Resets the CoverGlassNo attribute to an unset state.
	*
	* This fields reports the numerical designation that describes the expected thickness of this Coverslip (e.g., #1.5) and the relative expected thickness range expressed in mm.
	*/
	void resetCoverGlassNo();

	/*!
	* \brief Checks whether the optional CoverGlassNo attribute is present.
	*
	* This fields reports the numerical designation that describes the expected thickness of this Coverslip (e.g., #1.5) and the relative expected thickness range expressed in mm.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasCoverGlassNo() const;

	/*!
	* \brief Sets the value of the Thickness attribute.
	*
	* This fields reports the measured thickness of this Coverslip expressed in mm.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setThickness(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the Thickness attribute.
	*
	* This fields reports the measured thickness of this Coverslip expressed in mm.
	*
	* \return The value of the attribute
	*/
	float getThickness() const;

	/*!
	* \brief Resets the Thickness attribute to an unset state.
	*
	* This fields reports the measured thickness of this Coverslip expressed in mm.
	*/
	void resetThickness();

	/*!
	* \brief Checks whether the Thickness attribute is present.
	*
	* This fields reports the measured thickness of this Coverslip expressed in mm.
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasThickness() const;


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

	LSID_TypePtr ID = nullptr; // Required attribute
    std::optional<std::string> Coating; // Required attribute
    static const std::set<std::string> CoatingAllowedValues;
	CoverGlassNr_TypePtr CoverGlassNo = nullptr; // Required attribute
    std::optional<float> Thickness; // Optional attribute
};

/*! Shared pointer for CoverGlass*/
typedef std::shared_ptr<CoverGlass> CoverGlassPtr;

} // namespace Inscoper::NBO

#endif // COVERGLASS_HPP_INCLUDED