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

#include <tango/client/GroupCmdReplyList.h>

namespace Tango
{

//=============================================================================
// class GroupCmdReplyList
//=============================================================================
GroupCmdReplyList::GroupCmdReplyList() :
    std::vector<GroupCmdReply>(0)
{
    //-noop impl
}

GroupCmdReplyList::~GroupCmdReplyList() = default;

GroupCmdReplyList::GroupCmdReplyList(const GroupCmdReplyList &) = default;
GroupCmdReplyList &GroupCmdReplyList::operator=(const GroupCmdReplyList &) = default;

GroupCmdReplyList::GroupCmdReplyList(GroupCmdReplyList &&) = default;
GroupCmdReplyList &GroupCmdReplyList::operator=(GroupCmdReplyList &&) = default;

/**
 * Check if an error has occurred
 *
 * Returns a boolean set to true if the command executed on the group has failed
 * for any device member of the hierarchy. Otherwise, returns false
 *
 * @return The error flag
 */
bool GroupCmdReplyList::has_failed() const
{
    return has_failed_m;
}

//- reset the error list
/**
 * Reset the object
 *
 * This methods empty the inherited vector and reset the error flag
 */
void GroupCmdReplyList::reset()
{
    clear();
    has_failed_m = false;
}

//- push_back overload
void GroupCmdReplyList::push_back(const GroupCmdReply &cr)
{
    if(cr.has_failed())
    {
        has_failed_m = true;
    }
    Inherited::push_back(cr);
}

} // namespace Tango
