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

#include <tango/server/ImageAttr.h>

#include <tango/server/Except.h>
#include <tango/server/Logging.h>
#include <tango/server/SpectrumAttr.h>

#include <bitset>

namespace Tango
{

//+-------------------------------------------------------------------------------------------------------------------
//
// method :
//        ImageAttr::ImageAttr
//
// description :
//        Constructor for the ImageAttr class. This constructor simply set the internal values
//
//-------------------------------------------------------------------------------------------------------------------

ImageAttr::ImageAttr(const char *att_name, long att_type, long x, long y) :
    SpectrumAttr(att_name, att_type, x),
    ext(nullptr)
{
    format = Tango::IMAGE;
    if(y <= 0)
    {
        TANGO_LOG_DEBUG << "ImageAttr::ImageAttr throwing exception" << std::endl;
        TangoSys_OMemStream o;

        o << "Attribute : " << name << ": ";
        o << " Maximum y dim. wrongly defined" << std::ends;
        TANGO_THROW_EXCEPTION(API_AttrWrongDefined, o.str());
    }
    max_y = y;
}

ImageAttr::ImageAttr(const char *att_name, long att_type, Tango::AttrWriteType w_type, long x, long y) :
    SpectrumAttr(att_name, att_type, w_type, x),
    ext(nullptr)
{
    format = Tango::IMAGE;
    if(y <= 0)
    {
        TANGO_LOG_DEBUG << "ImageAttr::ImageAttr throwing exception" << std::endl;
        TangoSys_OMemStream o;

        o << "Attribute : " << name << ": ";
        o << " Maximum y dim. wrongly defined" << std::ends;
        TANGO_THROW_EXCEPTION(API_AttrWrongDefined, o.str());
    }
    max_y = y;
}

ImageAttr::ImageAttr(const char *att_name, long att_type, long x, long y, DispLevel level) :
    SpectrumAttr(att_name, att_type, x, level),
    ext(nullptr)
{
    format = Tango::IMAGE;
    if(y <= 0)
    {
        TANGO_LOG_DEBUG << "ImageAttr::ImageAttr throwing exception" << std::endl;
        TangoSys_OMemStream o;

        o << "Attribute : " << name << ": ";
        o << " Maximum y dim. wrongly defined" << std::ends;
        TANGO_THROW_EXCEPTION(API_AttrWrongDefined, o.str());
    }
    max_y = y;
}

ImageAttr::ImageAttr(
    const char *att_name, long att_type, Tango::AttrWriteType w_type, long x, long y, DispLevel level) :
    SpectrumAttr(att_name, att_type, w_type, x, level),
    ext(nullptr)
{
    format = Tango::IMAGE;
    if(y <= 0)
    {
        TANGO_LOG_DEBUG << "ImageAttr::ImageAttr throwing exception" << std::endl;
        TangoSys_OMemStream o;

        o << "Attribute : " << name << ": ";
        o << " Maximum y dim. wrongly defined" << std::ends;
        TANGO_THROW_EXCEPTION(API_AttrWrongDefined, o.str());
    }
    max_y = y;
}

ImageAttr::ImageAttr(const ImageAttr &sou) :
    SpectrumAttr(sou)
{
    max_y = sou.max_y;
}

} // namespace Tango
