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

#ifndef TANGO_SERVER_BLACKBOXELT_H
#define TANGO_SERVER_BLACKBOXELT_H

#include <tango/common/defines.h>
#include <tango/common/tango_const.h>
#include <tango/server/client_addr.h>

#ifdef _TG_WINDOWS_
  #include <winsock2.h>
#endif

#include <chrono>
#include <ctime>
#include <ostream>
#include <string>
#include <vector>

namespace Tango
{

//==================================================================================================================
//
//            The BlackBoxElt class
//
// description :
//        Class to store all the necessary information which will be stored and returned to client on request
//
//==================================================================================================================

#define DEFAULT_ATTR_NB 10

enum BlackBoxElt_ReqType
{
    Req_Unknown,
    Req_Operation,
    Req_Attribute
};

enum BlackBoxElt_AttrType
{
    Attr_Unknown,
    Attr_Name,
    Attr_Description,
    Attr_State,
    Attr_Status,
    Attr_AdmName
};

enum BlackBoxElt_OpType
{
    Op_Unknown,
    Op_Command_inout,
    Op_BlackBox,
    Op_Ping,
    Op_Info,
    Op_Command_list,
    Op_Command,
    Op_Get_Attr_Config,
    Op_Set_Attr_Config,
    Op_Read_Attr,
    Op_Write_Attr,
    Op_Command_inout_2,
    Op_Command_list_2,
    Op_Command_2,
    Op_Get_Attr_Config_2,
    Op_Read_Attr_2,
    Op_Command_inout_history_2,
    Op_Read_Attr_history_2,
    Op_Read_Attr_3,
    Op_Write_Attr_3,
    Op_Read_Attr_history_3,
    Op_Info_3,
    Op_Get_Attr_Config_3,
    Op_Set_Attr_Config_3,
    Op_Read_Attr_history_4,
    Op_Command_inout_history_4,
    Op_Command_inout_4,
    Op_Write_Attr_4,
    Op_Read_Attr_4,
    Op_Set_Attr_Config_4,
    Op_Write_Read_Attributes_4,
    Op_Get_Attr_Config_5,
    Op_Set_Attr_Config_5,
    Op_Read_Attr_5,
    Op_Write_Read_Attributes_5,
    Op_Read_Attr_history_5,
    Op_Get_Pipe_Config_5,
    Op_Set_Pipe_Config_5,
    Op_Read_Pipe_5,
    Op_Write_Pipe_5,
    Op_Write_Read_Pipe_5,
    Op_Info_6
};

class BlackBoxElt
{
  public:
    BlackBoxElt();
    ~BlackBoxElt();

    BlackBoxElt_ReqType req_type;
    BlackBoxElt_AttrType attr_type;
    BlackBoxElt_OpType op_type;
    std::string cmd_name;
    std::vector<std::string> attr_names;
    std::chrono::system_clock::time_point when;
    char host_ip_str[IP_ADDR_BUFFER_SIZE];
    DevSource source;

    bool client_ident;
    LockerLanguage client_lang;
    TangoSys_Pid client_pid;
    std::string java_main_class;
};

inline bool operator<(const BlackBoxElt &, const BlackBoxElt &)
{
    return true;
}

inline bool operator==(const BlackBoxElt &, const BlackBoxElt &)
{
    return true;
}

} // namespace Tango

#endif // TANGO_SERVER_BLACKBOXELT_H
