#ifndef MICROLENSARRAY_HPP_INCLUDED
#define MICROLENSARRAY_HPP_INCLUDED

#include <iostream>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <vector>
#include <NBO/NBO/AnnotationRef.h>
#include <NBO/NBO/Denomination_Type.h>
#include <NBO/NBO/ElectroOpticalDeviceID_Type.h>
#include <NBO/NBO/LensShapeType_Type.h>
#include <NBO/NBO/LensletShape_Type.h>
#include <NBO/NBO/OpticalMaterialName_Type.h>
#include <NBO/NBO/UnitsLength_Type.h>
#include <NBO/NBO/WavelengthRange.h>
#include <NBO/NBO/ENBOType.h>
#include <NBO/NBOGlobal.h>
#include <NBO/Shared/Base/NBOBaseClass.h>


namespace Inscoper::NBO {

/*!
* \brief Represents the XML element MicrolensArray.
*
* Micro-lens arrays contain multiple micro-lenses forming a one- or two-dimensional array on a supporting substrate.
*/
class NBO_EXPORT MicrolensArray : public NBOBaseClass {

public:
	
	MicrolensArray();
	~MicrolensArray();

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

	/*!
	* \brief Returns the value of the Name attribute.
	*
	* A User-defined Name for this component.
	*
	* \return The value of the attribute
	*/
	Denomination_TypePtr getName() const;

	/*!
	* \brief Resets the Name attribute to an unset state.
	*
	* A User-defined Name for this component.
	*/
	void resetName();

	/*!
	* \brief Checks whether the optional Name attribute is present.
	*
	* A User-defined Name for this component.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasName() const;

	/*!
	* \brief Sets the value of the LensletDiameter attribute.
	*
	* This field records the physical Dameter of the Lenslets that compose this Micro Lens Array.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setLensletDiameter(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the LensletDiameter attribute.
	*
	* This field records the physical Dameter of the Lenslets that compose this Micro Lens Array.
	*
	* \return The value of the attribute
	*/
	float getLensletDiameter() const;

	/*!
	* \brief Resets the LensletDiameter attribute to an unset state.
	*
	* This field records the physical Dameter of the Lenslets that compose this Micro Lens Array.
	*/
	void resetLensletDiameter();

	/*!
	* \brief Checks whether the LensletDiameter attribute is present.
	*
	* This field records the physical Dameter of the Lenslets that compose this Micro Lens Array.
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasLensletDiameter() const;

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

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

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

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

	/*!
	* \brief Sets the value of the LensletPitch attribute.
	*
	* This field records the distance between Lenslets in this Micro Lens Array.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setLensletPitch(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the LensletPitch attribute.
	*
	* This field records the distance between Lenslets in this Micro Lens Array.
	*
	* \return The value of the attribute
	*/
	float getLensletPitch() const;

	/*!
	* \brief Resets the LensletPitch attribute to an unset state.
	*
	* This field records the distance between Lenslets in this Micro Lens Array.
	*/
	void resetLensletPitch();

	/*!
	* \brief Checks whether the LensletPitch attribute is present.
	*
	* This field records the distance between Lenslets in this Micro Lens Array.
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasLensletPitch() const;

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

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

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

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

	/*!
	* \brief Sets the value of the LensletArrangement attribute.
	*
	* This field records the arrangement of individual Lenslets on this Array.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setLensletArrangement(const std::string& value, bool validate = true);

	/*!
	* \brief Returns the value of the LensletArrangement attribute.
	*
	* This field records the arrangement of individual Lenslets on this Array.
	*
	* \return The value of the attribute
	*/
	std::string getLensletArrangement() const;

	/*!
	* \brief Resets the LensletArrangement attribute to an unset state.
	*
	* This field records the arrangement of individual Lenslets on this Array.
	*/
	void resetLensletArrangement();

	/*!
	* \brief Checks whether the LensletArrangement attribute is present.
	*
	* This field records the arrangement of individual Lenslets on this Array.
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasLensletArrangement() const;

	/*!
	* \brief Returns the allowed values for this attribut.
	*
	* This field records the arrangement of individual Lenslets on this Array.
	*
	* \return The list of allowed values
	*/
	static const std::set<std::string>& getLensletArrangementAllowedValues();

	/*!
	* \brief Sets the value of the LensletShape attribute.
	*
	* This field records the geometrical shape (e.g., round vs. square) of the individual Lenslets composing this Micro Lens Array.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setLensletShape(const Inscoper::NBO::LensletShape_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the LensletShape attribute.
	*
	* This field records the geometrical shape (e.g., round vs. square) of the individual Lenslets composing this Micro Lens Array.
	*
	* \return The value of the attribute
	*/
	LensletShape_TypePtr getLensletShape() const;

	/*!
	* \brief Resets the LensletShape attribute to an unset state.
	*
	* This field records the geometrical shape (e.g., round vs. square) of the individual Lenslets composing this Micro Lens Array.
	*/
	void resetLensletShape();

	/*!
	* \brief Checks whether the optional LensletShape attribute is present.
	*
	* This field records the geometrical shape (e.g., round vs. square) of the individual Lenslets composing this Micro Lens Array.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasLensletShape() const;

	/*!
	* \brief Sets the value of the LensletProfileShape attribute.
	*
	* This field describes the shape of the profile (e.g., concave vs. convex) of the individual Lenslets that compose this Micro Lens Array.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setLensletProfileShape(const Inscoper::NBO::LensShapeType_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the LensletProfileShape attribute.
	*
	* This field describes the shape of the profile (e.g., concave vs. convex) of the individual Lenslets that compose this Micro Lens Array.
	*
	* \return The value of the attribute
	*/
	LensShapeType_TypePtr getLensletProfileShape() const;

	/*!
	* \brief Resets the LensletProfileShape attribute to an unset state.
	*
	* This field describes the shape of the profile (e.g., concave vs. convex) of the individual Lenslets that compose this Micro Lens Array.
	*/
	void resetLensletProfileShape();

	/*!
	* \brief Checks whether the optional LensletProfileShape attribute is present.
	*
	* This field describes the shape of the profile (e.g., concave vs. convex) of the individual Lenslets that compose this Micro Lens Array.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasLensletProfileShape() const;

	/*!
	* \brief Sets the value of the Coating attribute.
	*
	* An optical Coating consists of one or more thin layers of material deposited on an optical component such as a Lens or Mirror, which alters the way in which the optic reflects and transmits light. This field records the thin-film material used to coat the non linear crystal and reduce surface reflection.
	*
	* \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.
	*
	* An optical Coating consists of one or more thin layers of material deposited on an optical component such as a Lens or Mirror, which alters the way in which the optic reflects and transmits light. This field records the thin-film material used to coat the non linear crystal and reduce surface reflection.
	*
	* \return The value of the attribute
	*/
	std::string getCoating() const;

	/*!
	* \brief Resets the Coating attribute to an unset state.
	*
	* An optical Coating consists of one or more thin layers of material deposited on an optical component such as a Lens or Mirror, which alters the way in which the optic reflects and transmits light. This field records the thin-film material used to coat the non linear crystal and reduce surface reflection.
	*/
	void resetCoating();

	/*!
	* \brief Checks whether the Coating attribute is present.
	*
	* An optical Coating consists of one or more thin layers of material deposited on an optical component such as a Lens or Mirror, which alters the way in which the optic reflects and transmits light. This field records the thin-film material used to coat the non linear crystal and reduce surface reflection.
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasCoating() const;

	/*!
	* \brief Returns the allowed values for this attribut.
	*
	* An optical Coating consists of one or more thin layers of material deposited on an optical component such as a Lens or Mirror, which alters the way in which the optic reflects and transmits light. This field records the thin-film material used to coat the non linear crystal and reduce surface reflection.
	*
	* \return The list of allowed values
	*/
	static const std::set<std::string>& getCoatingAllowedValues();

	/*!
	* \brief Sets the value of the Reflectance attribute.
	*
	* This field records the maximum amount of light this Micro Lens Array is capable of reflecting. It is represented as a fractional value from 0.0 to 1.0.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setReflectance(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the Reflectance attribute.
	*
	* This field records the maximum amount of light this Micro Lens Array is capable of reflecting. It is represented as a fractional value from 0.0 to 1.0.
	*
	* \return The value of the attribute
	*/
	float getReflectance() const;

	/*!
	* \brief Resets the Reflectance attribute to an unset state.
	*
	* This field records the maximum amount of light this Micro Lens Array is capable of reflecting. It is represented as a fractional value from 0.0 to 1.0.
	*/
	void resetReflectance();

	/*!
	* \brief Checks whether the Reflectance attribute is present.
	*
	* This field records the maximum amount of light this Micro Lens Array is capable of reflecting. It is represented as a fractional value from 0.0 to 1.0.
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasReflectance() const;

	/*!
	* \brief Sets the value of the SustrateMaterial attribute.
	*
	* This field records the chemical composition or designation of the substrate of this Micro Lens Array. The substrate is typically composed of a glass material with low autofluorescence, such as UV-grade fused silica.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setSustrateMaterial(const Inscoper::NBO::OpticalMaterialName_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the SustrateMaterial attribute.
	*
	* This field records the chemical composition or designation of the substrate of this Micro Lens Array. The substrate is typically composed of a glass material with low autofluorescence, such as UV-grade fused silica.
	*
	* \return The value of the attribute
	*/
	OpticalMaterialName_TypePtr getSustrateMaterial() const;

	/*!
	* \brief Resets the SustrateMaterial attribute to an unset state.
	*
	* This field records the chemical composition or designation of the substrate of this Micro Lens Array. The substrate is typically composed of a glass material with low autofluorescence, such as UV-grade fused silica.
	*/
	void resetSustrateMaterial();

	/*!
	* \brief Checks whether the optional SustrateMaterial attribute is present.
	*
	* This field records the chemical composition or designation of the substrate of this Micro Lens Array. The substrate is typically composed of a glass material with low autofluorescence, such as UV-grade fused silica.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasSustrateMaterial() const;

	/*!
	* \brief Sets the value of the FrontFocalLength attribute.
	*
	* This field records the distance (f) measured along the optical axis from the front principal plane of this Micro Lens Array to the front focal plane (F).
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setFrontFocalLength(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the FrontFocalLength attribute.
	*
	* This field records the distance (f) measured along the optical axis from the front principal plane of this Micro Lens Array to the front focal plane (F).
	*
	* \return The value of the attribute
	*/
	float getFrontFocalLength() const;

	/*!
	* \brief Resets the FrontFocalLength attribute to an unset state.
	*
	* This field records the distance (f) measured along the optical axis from the front principal plane of this Micro Lens Array to the front focal plane (F).
	*/
	void resetFrontFocalLength();

	/*!
	* \brief Checks whether the FrontFocalLength attribute is present.
	*
	* This field records the distance (f) measured along the optical axis from the front principal plane of this Micro Lens Array to the front focal plane (F).
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasFrontFocalLength() const;

	/*!
	* \brief Sets the value of the BackFocalLength attribute.
	*
	* This field records the distance (f') measured along the optical axis from the rear principal plane of this Micro Lens Array to the rear focal plane (F').
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setBackFocalLength(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the BackFocalLength attribute.
	*
	* This field records the distance (f') measured along the optical axis from the rear principal plane of this Micro Lens Array to the rear focal plane (F').
	*
	* \return The value of the attribute
	*/
	float getBackFocalLength() const;

	/*!
	* \brief Resets the BackFocalLength attribute to an unset state.
	*
	* This field records the distance (f') measured along the optical axis from the rear principal plane of this Micro Lens Array to the rear focal plane (F').
	*/
	void resetBackFocalLength();

	/*!
	* \brief Checks whether the BackFocalLength attribute is present.
	*
	* This field records the distance (f') measured along the optical axis from the rear principal plane of this Micro Lens Array to the rear focal plane (F').
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasBackFocalLength() const;

	/*!
	* \brief Sets the value of the OpticalDistanceUnit attribute.
	*
	* Use this unit for both Focal Length fields.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setOpticalDistanceUnit(const Inscoper::NBO::UnitsLength_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the OpticalDistanceUnit attribute.
	*
	* Use this unit for both Focal Length fields.
	*
	* \return The value of the attribute
	*/
	UnitsLength_TypePtr getOpticalDistanceUnit() const;

	/*!
	* \brief Resets the OpticalDistanceUnit attribute to an unset state.
	*
	* Use this unit for both Focal Length fields.
	*/
	void resetOpticalDistanceUnit();

	/*!
	* \brief Checks whether the optional OpticalDistanceUnit attribute is present.
	*
	* Use this unit for both Focal Length fields.
	*
	* \return true if the optional attribute has been set, false otherwise
	*/
	bool hasOpticalDistanceUnit() const;

	/*!
	* \brief Sets the value of the AnnotationRef element.
	*
	* 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 setAnnotationRef(const Inscoper::NBO::AnnotationRefPtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the AnnotationRef element.
	*
	* No description available in the XSD standard.
	*
	* \return The value of the element
	*/
	Inscoper::NBO::AnnotationRefPtr getAnnotationRef() const
;
	/*!
	* \brief Resets the AnnotationRef element to an unset state.
	*
	* No description available in the XSD standard.
	*/
	void resetAnnotationRef();

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

	/*!
	* \brief Sets the list of WavelengthRange elements.
	*
	* No description available in the XSD standard.
	*
	* \param value The new list of WavelengthRange elements
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setWavelengthRange_List(const std::vector<Inscoper::NBO::WavelengthRangePtr>& value, bool validate = true);

	/*!
	* \brief Returns the list of WavelengthRange elements.
	*
	* No description available in the XSD standard.
	*
	* \return The list of WavelengthRange elements
	*/
	std::vector<Inscoper::NBO::WavelengthRangePtr> getWavelengthRange_List() const;

	/*!
	* \brief Adds a new WavelengthRange element to this object.
	*
	* No description available in the XSD standard.
	*
	* \param value The element to add
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void addToWavelengthRange_List(const Inscoper::NBO::WavelengthRangePtr& value, bool validate = true);

	/*!
	* \brief Clear the list of WavelengthRange.
	*
	* No description available in the XSD standard.
	*/
	void clearWavelengthRange_List();


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

	ElectroOpticalDeviceID_TypePtr ID = nullptr; // Required attribute
	Denomination_TypePtr Name = nullptr; // Optional attribute
    std::optional<float> LensletDiameter; // Optional attribute
	UnitsLength_TypePtr LensletDiameterUnit = nullptr; // Optional attribute
    std::optional<float> LensletPitch; // Optional attribute
	UnitsLength_TypePtr LensletPitchUnit = nullptr; // Optional attribute
    std::optional<std::string> LensletArrangement; // Optional attribute
    static const std::set<std::string> LensletArrangementAllowedValues;
	LensletShape_TypePtr LensletShape = nullptr; // Optional attribute
	LensShapeType_TypePtr LensletProfileShape = nullptr; // Optional attribute
    std::optional<std::string> Coating; // Optional attribute
    static const std::set<std::string> CoatingAllowedValues;
    std::optional<float> Reflectance; // Required attribute
	OpticalMaterialName_TypePtr SustrateMaterial = nullptr; // Optional attribute
    std::optional<float> FrontFocalLength; // Optional attribute
    std::optional<float> BackFocalLength; // Optional attribute
	UnitsLength_TypePtr OpticalDistanceUnit = nullptr; // Optional attribute
    Inscoper::NBO::AnnotationRefPtr AnnotationRef = nullptr;
    std::vector<Inscoper::NBO::WavelengthRangePtr> WavelengthRange_List;
};

/*! Shared pointer for MicrolensArray*/
typedef std::shared_ptr<MicrolensArray> MicrolensArrayPtr;

} // namespace Inscoper::NBO

#endif // MICROLENSARRAY_HPP_INCLUDED