#include "../../Headers/GUI/ComponentData.h"
#include "../../Headers/ResourceManager.h"

/**
* Builds an empty component tile with an unknown type and disabled state.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*
* @code
*	ComponentData data;
* @endcode
*/
ComponentData::ComponentData()
{
	myComponentType = RumPi::EComponentType::E_Unknown;
	myName = wxString();
	myData = wxString();
	myIsEnabled = false;
}

/**
* Builds a component tile from its type (which selects the icon), name, initial data string, and enabled state.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*
* @code
*	ComponentData data(RumPi::EComponentType::E_LED, "Porch LED", "On", true);
* @endcode
*
* @param [in] componentType The component type; its icon is derived from this.
* @param [in] name          The component's unique instance name, shown as its label.
* @param [in] data          The initial data string to display.
* @param [in] isEnabled     Whether the component is currently enabled.
*/
ComponentData::ComponentData(const RumPi::EComponentType componentType, const wxString& name, const wxString& data, const bool isEnabled)
{
	myIcon = ResourceManager::GetComponentImage(componentType);
	myComponentType = componentType;
	myName = name;
	myData = data;
	myIsEnabled = isEnabled;
}

/**
* Gets the component's icon.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*
* @code
*	wxBitmapBundle icon = data.GetIcon();
* @endcode
*
* @return The component's icon.
*/
wxBitmapBundle ComponentData::GetIcon() const
{
	return myIcon;
}

/**
* Gets the component's type.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*
* @code
*	RumPi::EComponentType type = data.GetComponentType();
* @endcode
*
* @return The component's type.
*/
RumPi::EComponentType ComponentData::GetComponentType() const
{
	return myComponentType;
}

/**
* Gets the component's unique instance name.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*
* @code
*	wxString name = data.GetName();
* @endcode
*
* @return The component's name.
*/
const wxString& ComponentData::GetName() const
{
	return myName;
}

/**
* Gets the component's current data string.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*
* @code
*	wxString value = data.GetData();
* @endcode
*
* @return The component's data string.
*/
const wxString& ComponentData::GetData() const
{
	return myData;
}

/**
* Gets whether the component is currently enabled.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*
* @code
*	bool enabled = data.GetIsEnabled();
* @endcode
*
* @return True if the component is enabled.
*/
bool ComponentData::GetIsEnabled() const
{
	return myIsEnabled;
}

/**
* Sets the component's icon.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*
* @code
*	data.SetIcon(icon);
* @endcode
*
* @param [in] icon The icon to set.
*/
void ComponentData::SetIcon(const wxBitmapBundle& icon)
{
	myIcon = icon;
}

/**
* Sets the component's type.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*
* @code
*	data.SetComponentType(RumPi::EComponentType::E_LED);
* @endcode
*
* @param [in] componentType The component type to set.
*/
void ComponentData::SetComponentType(const RumPi::EComponentType componentType)
{
	myComponentType = componentType;
}

/**
* Sets the component's unique instance name.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*
* @code
*	data.SetName("Porch LED");
* @endcode
*
* @param [in] name The name to set.
*/
void ComponentData::SetName(const wxString& name)
{
	myName = name;
}

/**
* Sets the component's current data string.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*
* @code
*	data.SetData("On");
* @endcode
*
* @param [in] data The data string to set.
*/
void ComponentData::SetData(const wxString& data)
{
	myData = data;
}

/**
* Sets whether the component is currently enabled.
*
* @author Eddie O'Hagan
* @date 8/13/2026
*
* @code
*	data.SetIsEnabled(true);
* @endcode
*
* @param [in] isEnabled True if the component is enabled.
*/
void ComponentData::SetIsEnabled(const bool isEnabled)
{
	myIsEnabled = isEnabled;
}
