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

#ifndef TANGO_CLIENT_DATAELEMENT_H
#define TANGO_CLIENT_DATAELEMENT_H

#include <string>
#include <vector>

namespace Tango
{

/**
 * Fundamental type for extracting data from a device pipe blob
 *
 * This is the fundamental type for extracting data from a device pipe blob
 *
 *
 * @headerfile tango.h
 * @ingroup Client
 */

template <typename T>
struct DataElement
{
    /**
     * Create a DataElement object.
     *
     * Create a DataElement object for device pipe blob extraction
     *
     * @param [in] name The data element name
     * @param [in] value The data element value
     */
    DataElement(const std::string &name, T value);
    /**
     * Create a DataElement object.
     *
     * Create a DataElement object for device pipe blob extraction
     *
     * @param [in] name The data element name
     */
    DataElement(const std::string &name);
    /**
     * Create a DataElement object.
     *
     * Create a DataElement object for device pipe blob extraction. Usefull for extraction into TANGO CORBA
     * sequence. See DevicePipeBlob extraction method
     *
     * @param [in] value The data element value
     */
    DataElement(T value);

    DataElement();

    std::string name; ///< The data element name
    T value;          ///< The data element value
};

template <typename T>
DataElement<T>::DataElement(const std::string &_na, T _val) :
    name(_na),
    value(_val)
{
}

template <typename T>
DataElement<T>::DataElement(const std::string &_na) :
    name(_na)
{
}

template <typename T>
DataElement<T>::DataElement(T _val) :
    value(_val)
{
}

template <typename T>
DataElement<T>::DataElement()
{
}

//
// For DataElement printing
//

template <typename T>
std::ostream &operator<<(std::ostream &, const DataElement<T> &);

template <typename T>
std::ostream &operator<<(std::ostream &, const DataElement<std::vector<T>> &);

template <typename T>
std::ostream &operator<<(std::ostream &, const DataElement<T *> &);

} // namespace Tango

#endif /* TANGO_CLIENT_DATAELEMENT_H */
