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

#ifndef TANGO_SERVER_FWDATTRIBUTE_H
#define TANGO_SERVER_FWDATTRIBUTE_H

#include <tango/client/AttributeInfoEx.h>
#include <tango/common/defines.h>
#include <tango/server/WAttribute.h>

#ifdef _TG_WINDOWS_
  #include <sys/types.h>
#endif

#include <string>

namespace Tango
{

// NOLINTNEXTLINE(bugprone-tagged-union-member-count)
class FwdAttribute : public WAttribute
{
  public:
    FwdAttribute(std::vector<AttrProperty> &, Attr &, const std::string &, long);
    ~FwdAttribute() override;

    bool is_fwd_att() override
    {
        return true;
    }

    std::string &get_fwd_dev_name()
    {
        return fwd_dev_name;
    }

    std::string &get_fwd_att_name()
    {
        return fwd_att_name;
    }

    void set_att_config(const Tango::AttributeConfig_5 &);

    void set_att_config(const Tango::AttributeConfig_3 &) { }

    void set_att_config(AttributeInfoEx *);

    void upd_att_config_base(const char *);
    void upd_att_config(const Tango::AttributeConfig_5 &);
    void upd_att_config(const Tango::AttributeConfig_3 &);

    void upd_att_label(const char *);
    bool new_att_conf(const Tango::AttributeConfig_3 *, const Tango::AttributeConfig_5 *);

    Attr_Value &get_root_ptr()
    {
        return r_val;
    }

    template <typename T>
    void set_local_attribute(DeviceAttribute &, T *&);

    template <typename T>
    bool new_att_conf_base(const T &);

    DevAttrHistory_5 *read_root_att_history(long n);
    AttributeValueList_5 *write_read_root_att(AttributeValueList_4 &);

  protected:
    void convert_event_prop(const std::string &, double *);

    std::string fwd_dev_name; // Root dev name for fwd attribute
    std::string fwd_att_name; // Root att name for fwd attribute

    AttrQuality qual;
    Attr_Value r_val;
};

} // namespace Tango

#endif // TANGO_SERVER_FWDATTRIBUTE_H
