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

#ifndef TANGO_CLIENT_GROUPREPLYLIST_H
#define TANGO_CLIENT_GROUPREPLYLIST_H

#include <tango/client/GroupReply.h>

#include <vector>

namespace Tango
{

//=============================================================================
// class GroupReplyList : a simple list of GroupReply
//=============================================================================
/**
 * Group reply for a write_attribute execution
 *
 * This class inherits from @b vector<GroupReply> and therefore, each
 * device in the  group heierarchy has his own GroupReply object
 * which can be retrieved with the classical vector [] operator
 *
 *
 * @headerfile tango.h
 * @ingroup Grp
 */
class GroupReplyList : public std::vector<GroupReply>
{
    ///@privatesection
    typedef std::vector<GroupReply> Inherited;

    friend class Group;

  public:
    ///@privatesection
    //- ctor
    GroupReplyList();
    //- dtor
    virtual ~GroupReplyList();

    GroupReplyList(const GroupReplyList &);
    GroupReplyList &operator=(const GroupReplyList &);

    GroupReplyList(GroupReplyList &&);
    GroupReplyList &operator=(GroupReplyList &&);

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

    //- reset the error list
    /**
     * Reset the object
     *
     * This methods empty the inherited vector and reset the error flag
     */
    void reset();

    ///@privatesection
    //- push_back overload
    void push_back(const GroupReply &r);

  private:
    //- has_failed_m: true if at least one error occurred, false otherwise
    bool has_failed_m{false};
};

} // namespace Tango

#endif /* TANGO_CLIENT_GROUPREPLYLIST_H */
