#ifndef PINHOLE_HPP_INCLUDED
#define PINHOLE_HPP_INCLUDED

#include <iostream>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <vector>
#include <NBO/NBO/OpticalAperture_Type.h>
#include <NBO/NBO/PinholeShapeList_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 Pinhole.
*
* A pin-like aperture positioned axially to the Light Path, which can act as a spatial filter for a beam of light to clean up the output of lasers and / or to suppress out-of-focus light in a confocal Microscope. Specifically, in Confocal Microscopy, such Pinholes are diaphragm typically situated in a plane conjugate with the object, and they restrict the area in the object plane that is illuminated and/or from which light is collected.
*/
class NBO_EXPORT Pinhole : public OpticalAperture_Type {

public:
	
	Pinhole();
	~Pinhole();

	/*!
	* \brief Cast a NBOBaseClass to a Pinhole.
	*
	* \param base The base class to cast
	* \return The casted element, or nullptr if the cast fails
	*/
	static std::shared_ptr<Pinhole> 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 MaxDiameter attribute.
	*
	* This field records the maximum physical diameter of this Pinhole.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setMaxDiameter(const float& value, bool validate = true);

	/*!
	* \brief Returns the value of the MaxDiameter attribute.
	*
	* This field records the maximum physical diameter of this Pinhole.
	*
	* \return The value of the attribute
	*/
	float getMaxDiameter() const;

	/*!
	* \brief Resets the MaxDiameter attribute to an unset state.
	*
	* This field records the maximum physical diameter of this Pinhole.
	*/
	void resetMaxDiameter();

	/*!
	* \brief Checks whether the MaxDiameter attribute is present.
	*
	* This field records the maximum physical diameter of this Pinhole.
	*
	* \return true if the attribute has been set, false otherwise
	*/
	bool hasMaxDiameter() const;

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

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

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

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

	/*!
	* \brief Sets the value of the Shape attribute.
	*
	* This field records the Shape of this Pinhole.
	*
	* \param value The value to set
	* \param validate If true, validates constraints on value. Default is true.
	*/
	void setShape(const Inscoper::NBO::PinholeShapeList_TypePtr& value, bool validate = true);

	/*!
	* \brief Returns the value of the Shape attribute.
	*
	* This field records the Shape of this Pinhole.
	*
	* \return The value of the attribute
	*/
	PinholeShapeList_TypePtr getShape() const;

	/*!
	* \brief Resets the Shape attribute to an unset state.
	*
	* This field records the Shape of this Pinhole.
	*/
	void resetShape();

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


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

    std::optional<float> MaxDiameter; // Required attribute
	UnitsLength_TypePtr MaxDiameterUnit = nullptr; // Optional attribute
	PinholeShapeList_TypePtr Shape = nullptr; // Optional attribute
};

/*! Shared pointer for Pinhole*/
typedef std::shared_ptr<Pinhole> PinholePtr;

} // namespace Inscoper::NBO

#endif // PINHOLE_HPP_INCLUDED