#ifndef DEFORMABLEMIRROR_HPP_INCLUDED
#define DEFORMABLEMIRROR_HPP_INCLUDED

#include <iostream>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <vector>
#include <NBO/NBO/DeformableMirrorType_Type.h>
#include <NBO/NBO/ElectroOpticalDevice_Type.h>
#include <NBO/NBO/UnitsLength_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 DeformableMirror.
*
* A Deformable Mirror (DM) is a Mechano Electro-Optical Device that has a controllable spatially varying mirror surface to modulate the wavefront of a beam of light impinging on it. This type of device is typically used in adaptive optics.
*/
class NBO_EXPORT DeformableMirror : public ElectroOpticalDevice_Type {

public:
	
	DeformableMirror();
	~DeformableMirror();

	/*!
	* \brief Cast a NBOBaseClass to a DeformableMirror.
	*
	* \param base The base class to cast
	* \return The casted element, or nullptr if the cast fails
	*/
	static std::shared_ptr<DeformableMirror> 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 type of this Deformable Mirror.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setType(const Inscoper::NBO::DeformableMirrorType_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the Type attribute.
	*
	* This field records the type of this Deformable Mirror.
	*
	* \return The value of the attribute
	*/
	DeformableMirrorType_TypePtr getType() const;

	/*!
	* \brief Resets the Type attribute to an unset state.
	*
	* This field records the type of this Deformable Mirror.
	*/
	void resetType();

	/*!
	* \brief Checks whether the optional Type attribute is present.
	*
	* This field records the type of this Deformable Mirror.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasType() const;

	/*!
	* \brief Sets the value of the Actuators attribute.
	*
	* This field records the number of Actuators available for this device.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setActuators(const int& value, bool validate = true);

	/*!
	* \brief Returns the value of the Actuators attribute.
	*
	* This field records the number of Actuators available for this device.
	*
	* \return The value of the attribute
	*/
	int getActuators() const;

	/*!
	* \brief Resets the Actuators attribute to an unset state.
	*
	* This field records the number of Actuators available for this device.
	*/
	void resetActuators();

	/*!
	* \brief Checks whether the Actuators attribute is present.
	*
	* This field records the number of Actuators available for this device.
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasActuators() const;

	/*!
	* \brief Sets the value of the ActuatorPitch attribute.
	*
	* This field records the distance between the center of each Actuator in this device.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setActuatorPitch(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the ActuatorPitch attribute.
	*
	* This field records the distance between the center of each Actuator in this device.
	*
	* \return The value of the attribute
	*/
	float getActuatorPitch() const;

	/*!
	* \brief Resets the ActuatorPitch attribute to an unset state.
	*
	* This field records the distance between the center of each Actuator in this device.
	*/
	void resetActuatorPitch();

	/*!
	* \brief Checks whether the ActuatorPitch attribute is present.
	*
	* This field records the distance between the center of each Actuator in this device.
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasActuatorPitch() const;

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

	/*!
	* \brief Returns the value of the ActuatorPitchUnit attribute.
	*
	* No description available in the XSD standard.
	*
	* \return The value of the attribute
	*/
	UnitsLength_TypePtr getActuatorPitchUnit() const;

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

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

	/*!
	* \brief Sets the value of the ActuatorStroke attribute.
	*
	* This field records the maximum possible Actuator displacement available for this device.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setActuatorStroke(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the ActuatorStroke attribute.
	*
	* This field records the maximum possible Actuator displacement available for this device.
	*
	* \return The value of the attribute
	*/
	float getActuatorStroke() const;

	/*!
	* \brief Resets the ActuatorStroke attribute to an unset state.
	*
	* This field records the maximum possible Actuator displacement available for this device.
	*/
	void resetActuatorStroke();

	/*!
	* \brief Checks whether the ActuatorStroke attribute is present.
	*
	* This field records the maximum possible Actuator displacement available for this device.
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasActuatorStroke() const;

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

	/*!
	* \brief Returns the value of the ActuatorStrokeUnit attribute.
	*
	* No description available in the XSD standard.
	*
	* \return The value of the attribute
	*/
	UnitsLength_TypePtr getActuatorStrokeUnit() const;

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

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

	/*!
	* \brief Sets the value of the ResponseTime attribute.
	*
	* This field records the rate at which this Deformable Mirror 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 Deformable Mirror 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 Deformable Mirror can change patterns.
	*/
	void resetResponseTime();

	/*!
	* \brief Checks whether the ResponseTime attribute is present.
	*
	* This field records the rate at which this Deformable Mirror 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 std::string& 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
	*/
	std::string getResponseTimeUnit() const;

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

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

	/*!
	* \brief Returns the allowed values for this attribut.
	*
	* No description available in the XSD standard.
	*
	* \return The list of allowed values
	*/
	static const std::set<std::string>& getResponseTimeUnitAllowedValues();


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

	DeformableMirrorType_TypePtr Type = nullptr; // Required attribute
    std::optional<int> Actuators; // Optional attribute
    std::optional<float> ActuatorPitch; // Optional attribute
	UnitsLength_TypePtr ActuatorPitchUnit = nullptr; // Optional attribute
    std::optional<float> ActuatorStroke; // Optional attribute
	UnitsLength_TypePtr ActuatorStrokeUnit = nullptr; // Optional attribute
    std::optional<float> ResponseTime; // Optional attribute
    std::optional<std::string> ResponseTimeUnit; // Optional attribute
    static const std::set<std::string> ResponseTimeUnitAllowedValues;
};

/*! Shared pointer for DeformableMirror*/
typedef std::shared_ptr<DeformableMirror> DeformableMirrorPtr;

} // namespace Inscoper::NBO

#endif // DEFORMABLEMIRROR_HPP_INCLUDED