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

#ifndef TANGO_CLIENT_ASYNCHREQUEST_H
#define TANGO_CLIENT_ASYNCHREQUEST_H

#include <tango/server/Except.h>

#include <map>
#include <string>
#include <vector>

namespace Tango
{

//=============================================================================
// class AsynchRequest : an asynch. request holder for groups
//-----------------------------------------------------------------------------
class AsynchRequest
{
    //- An asynch. request repository is maintained by each GroupDeviceElement
    // NOLINTNEXTLINE(cppcoreguidelines-virtual-class-destructor)
    friend class GroupDeviceElement;

  public:
    //- ctor
    AsynchRequest(long _rid, const std::string &_obj_name, bool ge_enabled = true);

    //- ctor
    AsynchRequest(long _rid, const std::vector<std::string> &_obj_names, bool ge_enabled = true);

    //- ctor
    AsynchRequest(long _rid, const std::string &_obj_name, const DevFailed &_df);

    //- ctor
    AsynchRequest(long _rid, const std::vector<std::string> &_obj_names, const DevFailed &_df);

    //- dtor
    virtual ~AsynchRequest();

    AsynchRequest(const AsynchRequest &);
    AsynchRequest &operator=(const AsynchRequest &);

    AsynchRequest(AsynchRequest &&);
    AsynchRequest &operator=(AsynchRequest &&);

    //- group_element_enabled accessor
    bool group_element_enabled() const;

  private:
    //- request ID
    long rq_id;
    //- name of requested objects (command or attribute)
    std::vector<std::string> obj_names;
    //- DevFailed containing potential error
    DevFailed rq_ex;
    //- true is the associated group member is enabled, false otherwise
    bool group_element_enabled_m;
};

//-----------------------------------------------------------------------------
//- asynch. request repository
typedef std::map<long, AsynchRequest> AsynchRequestRep;
//- asynch. request repository iterator
typedef AsynchRequestRep::iterator AsynchRequestRepIterator;
//- asynch. request repository value
typedef AsynchRequestRep::value_type AsynchRequestRepValue;

} // namespace Tango

#endif /* TANGO_CLIENT_ASYNCHREQUEST_H */
