Verified Commit d9a0f05e authored by Sergi Rubio's avatar Sergi Rubio Committed by Thomas Ives
Browse files

src/server: rename blackbox files to BlackBox

parent a91bbcde
Loading
Loading
Loading
Loading
+85 −0
Original line number Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2004 Copyright contributors to the cppTango project
 *
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#ifndef TANGO_SERVER_BLACKBOX_H
#define TANGO_SERVER_BLACKBOX_H

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

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

#include <chrono>
#include <string>
#include <vector>

namespace Tango
{

//==================================================================================================================
//
//            The BlackBox class
//
// description :
//        Class to implement the black box itself. This is mainly a vector of BlackBoxElt managed as a circular vector
//
//===================================================================================================================

class BlackBox
{
  public:
    BlackBox();
    BlackBox(long);

    void insert_corba_attr(BlackBoxElt_AttrType);
    void insert_cmd(const char *, long vers = 1, DevSource = Tango::DEV);
    void insert_attr(const Tango::DevVarStringArray &, long vers = 1, DevSource = Tango::DEV);
    void insert_attr(const Tango::DevVarStringArray &, const ClntIdent &, long vers = 1, DevSource = Tango::DEV);
    void insert_attr(const char *, const ClntIdent &, long);
    void insert_attr(const Tango::AttributeValueList &, long vers = 1);
    void insert_attr(const Tango::AttributeValueList_4 &, const ClntIdent &, long vers);
    void insert_attr(const Tango::DevPipeData &, const ClntIdent &, long vers);
    void insert_wr_attr(const Tango::AttributeValueList_4 &,
                        const Tango::DevVarStringArray &,
                        const ClntIdent &,
                        long vers);
    void insert_op(BlackBoxElt_OpType);
    void insert_op(BlackBoxElt_OpType, const ClntIdent &);

    void insert_cmd_nl(const char *, long, DevSource);
    void insert_cmd_cl_ident(const char *, const ClntIdent &, long vers = 1, DevSource = Tango::DEV);
    void add_cl_ident(const ClntIdent &, client_addr *);
    void update_client_host(client_addr *);

    Tango::DevVarStringArray *read(long);

  private:
    void inc_indexes();
    void get_client_host();
    void build_info_as_str(long);
    std::string timestamp_unix_to_str(const std::chrono::system_clock::time_point &);
    void add_source(long);
    void insert_op_nl(BlackBoxElt_OpType);
    void insert_attr_nl(const Tango::AttributeValueList &, long);
    void insert_attr_nl_4(const Tango::AttributeValueList_4 &);
    void insert_attr_wr_nl(const Tango::AttributeValueList_4 &, const Tango::DevVarStringArray &, long);

    std::vector<BlackBoxElt> box;
    long insert_elt;
    long nb_elt;
    long max_elt;

    omni_mutex sync;

    std::string elt_str;
};

} // namespace Tango

#endif /* _BLACKBOX_ */
+134 −0
Original line number Diff line number Diff line
/*
 * 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/tango_const.h>
#include <tango/server/client_addr.h>
#include <tango/server/tango_config.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
+3 −1
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@ set(SERVER_HEADERS UserDefaultAttrProp.h
    attrprop_templ.h
    AutoTangoMonitor.h
    AttributeEventSubscriptionState.h
    blackbox.h
    client_addr.h
    BlackBoxElt.h
    BlackBox.h
    AttrProperty.h
    MultiClassAttribute.h
    classpipe.h
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
#include <tango/server/Attr.h>
#include <tango/server/Attribute.h>
#include <tango/server/AutoTangoMonitor.h>
#include <tango/server/blackbox.h>
#include <tango/server/BlackBox.h>
#include <tango/server/classpipe.h>
#include <tango/server/DeviceClass.h>
#include <tango/server/DeviceEventSubscriptionState.h>
+3 −175
Original line number Diff line number Diff line
@@ -4,25 +4,16 @@
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#ifndef TANGO_SERVER_BLACKBOX_H
#define TANGO_SERVER_BLACKBOX_H
#ifndef TANGO_SERVER_CLIENT_ADDR_H
#define TANGO_SERVER_CLIENT_ADDR_H

#include <tango/common/tango_const.h>
#include <tango/server/tango_config.h>

#include <omniORB4/callDescriptor.h>
#include <omniORB4/omniInterceptors.h>

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

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

namespace Tango
{

@@ -85,169 +76,6 @@ class client_addr : public omni_thread::value_t
    friend std::ostream &operator<<(std::ostream &o_str, const client_addr &ca);
};

//==================================================================================================================
//
//            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;
}

//==================================================================================================================
//
//            The BlackBox class
//
// description :
//        Class to implement the black box itself. This is mainly a vector of BlackBoxElt managed as a circular vector
//
//===================================================================================================================

class BlackBox
{
  public:
    BlackBox();
    BlackBox(long);

    void insert_corba_attr(BlackBoxElt_AttrType);
    void insert_cmd(const char *, long vers = 1, DevSource = Tango::DEV);
    void insert_attr(const Tango::DevVarStringArray &, long vers = 1, DevSource = Tango::DEV);
    void insert_attr(const Tango::DevVarStringArray &, const ClntIdent &, long vers = 1, DevSource = Tango::DEV);
    void insert_attr(const char *, const ClntIdent &, long);
    void insert_attr(const Tango::AttributeValueList &, long vers = 1);
    void insert_attr(const Tango::AttributeValueList_4 &, const ClntIdent &, long vers);
    void insert_attr(const Tango::DevPipeData &, const ClntIdent &, long vers);
    void insert_wr_attr(const Tango::AttributeValueList_4 &,
                        const Tango::DevVarStringArray &,
                        const ClntIdent &,
                        long vers);
    void insert_op(BlackBoxElt_OpType);
    void insert_op(BlackBoxElt_OpType, const ClntIdent &);

    void insert_cmd_nl(const char *, long, DevSource);
    void insert_cmd_cl_ident(const char *, const ClntIdent &, long vers = 1, DevSource = Tango::DEV);
    void add_cl_ident(const ClntIdent &, client_addr *);
    void update_client_host(client_addr *);

    Tango::DevVarStringArray *read(long);

  private:
    void inc_indexes();
    void get_client_host();
    void build_info_as_str(long);
    std::string timestamp_unix_to_str(const std::chrono::system_clock::time_point &);
    void add_source(long);
    void insert_op_nl(BlackBoxElt_OpType);
    void insert_attr_nl(const Tango::AttributeValueList &, long);
    void insert_attr_nl_4(const Tango::AttributeValueList_4 &);
    void insert_attr_wr_nl(const Tango::AttributeValueList_4 &, const Tango::DevVarStringArray &, long);

    std::vector<BlackBoxElt> box;
    long insert_elt;
    long nb_elt;
    long max_elt;

    omni_mutex sync;

    std::string elt_str;
};

} // namespace Tango

#endif /* _BLACKBOX_ */
#endif // TANGO_SERVER_CLIENT_ADDR_H
Loading