#ifndef SPATIALLIGHTMODULATOR_HPP_INCLUDED
#define SPATIALLIGHTMODULATOR_HPP_INCLUDED

#include <iostream>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <vector>
#include <NBO/NBO/ElectroOpticalDevice_Type.h>
#include <NBO/NBO/NonNegativeInt_Type.h>
#include <NBO/NBO/SLMType_Type.h>
#include <NBO/NBO/UnitsTime_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 SpatialLightModulator.
*
* A Spatial Light Modulator (SLM) is device that imposes a changeable spatially varying modulation on a beam of light. The modulation can be in Intensity or in Phase or both.
*/
class NBO_EXPORT SpatialLightModulator : public ElectroOpticalDevice_Type {

public:
	
	SpatialLightModulator();
	~SpatialLightModulator();

	/*!
	* \brief Cast a NBOBaseClass to a SpatialLightModulator.
	*
	* \param base The base class to cast
	* \return The casted element, or nullptr if the cast fails
	*/
	static std::shared_ptr<SpatialLightModulator> 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 Type attribute.
	*
	* This field records the category to which this Spatial Light Modulator belongs.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setType(const Inscoper::NBO::SLMType_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the Type attribute.
	*
	* This field records the category to which this Spatial Light Modulator belongs.
	*
	* \return The value of the attribute
	*/
	SLMType_TypePtr getType() const;

	/*!
	* \brief Resets the Type attribute to an unset state.
	*
	* This field records the category to which this Spatial Light Modulator belongs.
	*/
	void resetType();

	/*!
	* \brief Checks whether the optional Type attribute is present.
	*
	* This field records the category to which this Spatial Light Modulator belongs.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasType() const;

	/*!
	* \brief Sets the value of the ArrayWidth attribute.
	*
	* This field records the number of spatial elements (pixels) this Spatial Light Modulator contains in the X direction.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setArrayWidth(const Inscoper::NBO::NonNegativeInt_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the ArrayWidth attribute.
	*
	* This field records the number of spatial elements (pixels) this Spatial Light Modulator contains in the X direction.
	*
	* \return The value of the attribute
	*/
	NonNegativeInt_TypePtr getArrayWidth() const;

	/*!
	* \brief Resets the ArrayWidth attribute to an unset state.
	*
	* This field records the number of spatial elements (pixels) this Spatial Light Modulator contains in the X direction.
	*/
	void resetArrayWidth();

	/*!
	* \brief Checks whether the optional ArrayWidth attribute is present.
	*
	* This field records the number of spatial elements (pixels) this Spatial Light Modulator contains in the X direction.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasArrayWidth() const;

	/*!
	* \brief Sets the value of the ArrayHeight attribute.
	*
	* This field records the number of spatial elements (pixels) this Spatial Light Modulator contains in the Y direction.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setArrayHeight(const Inscoper::NBO::NonNegativeInt_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the ArrayHeight attribute.
	*
	* This field records the number of spatial elements (pixels) this Spatial Light Modulator contains in the Y direction.
	*
	* \return The value of the attribute
	*/
	NonNegativeInt_TypePtr getArrayHeight() const;

	/*!
	* \brief Resets the ArrayHeight attribute to an unset state.
	*
	* This field records the number of spatial elements (pixels) this Spatial Light Modulator contains in the Y direction.
	*/
	void resetArrayHeight();

	/*!
	* \brief Checks whether the optional ArrayHeight attribute is present.
	*
	* This field records the number of spatial elements (pixels) this Spatial Light Modulator contains in the Y direction.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasArrayHeight() const;

	/*!
	* \brief Sets the value of the ResponseTime attribute.
	*
	* This field records the rate at which this Spatial Light Modulator can change patterns.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setResponseTime(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the ResponseTime attribute.
	*
	* This field records the rate at which this Spatial Light Modulator can change patterns.
	*
	* \return The value of the attribute
	*/
	float getResponseTime() const;

	/*!
	* \brief Resets the ResponseTime attribute to an unset state.
	*
	* This field records the rate at which this Spatial Light Modulator can change patterns.
	*/
	void resetResponseTime();

	/*!
	* \brief Checks whether the ResponseTime attribute is present.
	*
	* This field records the rate at which this Spatial Light Modulator can change patterns.
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasResponseTime() const;

	/*!
	* \brief Sets the value of the ResponseTimeUnit 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 setResponseTimeUnit(const Inscoper::NBO::UnitsTime_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the ResponseTimeUnit attribute.
	*
	* No description available in the XSD standard.
	*
	* \return The value of the attribute
	*/
	UnitsTime_TypePtr getResponseTimeUnit() const;

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

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


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

	SLMType_TypePtr Type = nullptr; // Optional attribute
	NonNegativeInt_TypePtr ArrayWidth = nullptr; // Optional attribute
	NonNegativeInt_TypePtr ArrayHeight = nullptr; // Optional attribute
    std::optional<float> ResponseTime; // Optional attribute
	UnitsTime_TypePtr ResponseTimeUnit = nullptr; // Optional attribute
};

/*! Shared pointer for SpatialLightModulator*/
typedef std::shared_ptr<SpatialLightModulator> SpatialLightModulatorPtr;

} // namespace Inscoper::NBO

#endif // SPATIALLIGHTMODULATOR_HPP_INCLUDED