/*
 * SPDX-FileCopyrightText: 2004 Copyright contributors to the cppTango project
 *
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#ifndef TANGO_SERVER_USERDEFAULTATTRPROP_H
#define TANGO_SERVER_USERDEFAULTATTRPROP_H

#include <tango/common/tango_const.h>
#include <tango/server/MultiClassAttribute.h>

#include <memory>
#include <string>
#include <vector>

namespace Tango
{

/**
 * User class to set attribute default properties.
 *
 * This class is used to set attribute default properties. Three levels of
 * attributes properties setting are implemented within Tango. The highest
 * property setting level is the database. Then the user default (set using
 * this UserDefaultAttrProp class) and finally a Tango library default
 * value
 *
 *
 * @headerfile tango.h
 * @ingroup Server
 */

class UserDefaultAttrProp
{
  public:
    /**@name Constructor
     * Only one constructor is defined for this class */
    //@{
    /**
     * Constructs a newly allocated UserDefaultAttrProp object.
     */
    UserDefaultAttrProp() :
        ext(nullptr)
    {
    }

    //@}

    /**@name Set default property methods */
    //@{
    /**
     * Set default label property
     *
     * @param    def_label    The user default label property
     */
    void set_label(const char *def_label)
    {
        label = def_label;
    }

    /**
     * Set default description property
     *
     * @param    def_desc    The user default description property
     */
    void set_description(const char *def_desc)
    {
        description = def_desc;
    }

    /**
     * Set default unit property
     *
     * @param    def_unit    The user default unit property
     */
    void set_unit(const char *def_unit)
    {
        unit = def_unit;
    }

    /**
     * Set default standard unit property
     *
     * @param    def_std_unit    The user default standard unit property
     */
    void set_standard_unit(const char *def_std_unit)
    {
        standard_unit = def_std_unit;
    }

    /**
     * Set default display unit property
     *
     * @param    def_disp_unit    The user default display unit property
     */
    void set_display_unit(const char *def_disp_unit)
    {
        display_unit = def_disp_unit;
    }

    /**
     * Set default format property
     *
     * @param    def_format    The user default format property
     */
    void set_format(const char *def_format)
    {
        format = def_format;
    }

    /**
     * Set default min_value property
     *
     * @param    def_min_value    The user default min_value property
     */
    void set_min_value(const char *def_min_value)
    {
        min_value = def_min_value;
    }

    /**
     * Set default max_value property
     *
     * @param    def_max_value    The user default max_value property
     */
    void set_max_value(const char *def_max_value)
    {
        max_value = def_max_value;
    }

    /**
     * Set default min_alarm property
     *
     * @param    def_min_alarm    The user default min_alarm property
     */
    void set_min_alarm(const char *def_min_alarm)
    {
        min_alarm = def_min_alarm;
    }

    /**
     * Set default max_alarm property
     *
     * @param    def_max_alarm    The user default max_alarm property
     */
    void set_max_alarm(const char *def_max_alarm)
    {
        max_alarm = def_max_alarm;
    }

    /**
     * Set default min_warning property
     *
     * @param    def_min_warning    The user default min_warning property
     */
    void set_min_warning(const char *def_min_warning)
    {
        min_warning = def_min_warning;
    }

    /**
     * Set default max_warning property
     *
     * @param    def_max_warning    The user default max_warning property
     */
    void set_max_warning(const char *def_max_warning)
    {
        max_warning = def_max_warning;
    }

    /**
     * Set default RDS alarm delta_t property
     *
     * @param    def_delta_t    The user default RDS alarm delta_t property
     */
    void set_delta_t(const char *def_delta_t)
    {
        delta_t = def_delta_t;
    }

    /**
     * Set default RDS alarm delta_val property
     *
     * @param    def_delta_val    The user default RDS alarm delta_val property
     */
    void set_delta_val(const char *def_delta_val)
    {
        delta_val = def_delta_val;
    }

    /**
     * Set default change event abs_change property
     *
     * @param    def_abs_change    The user default change event abs_change property
     */
    void set_event_abs_change(const char *def_abs_change)
    {
        abs_change = def_abs_change;
    }

    /**
     * Set default change event rel_change property
     *
     * @param    def_rel_change    The user default change event rel_change property
     */
    void set_event_rel_change(const char *def_rel_change)
    {
        rel_change = def_rel_change;
    }

    /**
     * Set default periodic event period property
     *
     * @param    def_period    The user default periodic event period property
     */
    void set_event_period(const char *def_period)
    {
        period = def_period;
    }

    /**
     * Set default archive event abs_change property
     *
     * @param    def_archive_abs_change    The user default archive event abs_change property
     */
    void set_archive_event_abs_change(const char *def_archive_abs_change)
    {
        archive_abs_change = def_archive_abs_change;
    }

    /**
     * Set default archive event rel_change property
     *
     * @param    def_archive_rel_change    The user default archive event rel_change property
     */
    void set_archive_event_rel_change(const char *def_archive_rel_change)
    {
        archive_rel_change = def_archive_rel_change;
    }

    /**
     * Set default archive event period property
     *
     * @param    def_archive_period    The user default archive event period property
     */
    void set_archive_event_period(const char *def_archive_period)
    {
        archive_period = def_archive_period;
    }

    /**
     * Set default enumeration labels
     *
     * @param    def_enum_labels    The enumeration labels
     */
    void set_enum_labels(const std::vector<std::string> &def_enum_labels)
    {
        enum_labels.clear();

        for(size_t i = 0; i < def_enum_labels.size(); ++i)
        {
            enum_labels += def_enum_labels[i];
            if(i + 1 < def_enum_labels.size())
            {
                enum_labels += ',';
            }
        }
    }

    //@}

    /// @privatesection
    ~UserDefaultAttrProp() { }

    void set_abs_change(const char *def_abs_change)
    {
        set_event_abs_change(def_abs_change);
    }

    void set_rel_change(const char *def_rel_change)
    {
        set_event_rel_change(def_rel_change);
    }

    void set_period(const char *def_period)
    {
        set_event_period(def_period);
    }

    void set_archive_abs_change(const char *def_archive_abs_change)
    {
        set_archive_event_abs_change(def_archive_abs_change);
    }

    void set_archive_rel_change(const char *def_archive_rel_change)
    {
        set_archive_event_rel_change(def_archive_rel_change);
    }

    void set_archive_period(const char *def_archive_period)
    {
        set_archive_event_period(def_archive_period);
    }

    std::string label;
    std::string description;
    std::string unit;
    std::string standard_unit;
    std::string display_unit;
    std::string format;
    std::string min_value;
    std::string max_value;
    std::string min_alarm;
    std::string max_alarm;
    std::string min_warning;
    std::string max_warning;
    std::string delta_val;
    std::string delta_t;
    std::string abs_change;
    std::string rel_change;
    std::string period;
    std::string archive_abs_change;
    std::string archive_rel_change;
    std::string archive_period;
    std::string enum_labels;

  private:
    class UserDefaultAttrPropExt
    {
    };

    std::unique_ptr<UserDefaultAttrPropExt> ext; // Class extension
};

} // namespace Tango

#endif // TANGO_SERVER_USERDEFAULTATTRPROP_H
