/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/


/*-----------------------------------------------------------------------------*/
/*! @file u_edb_eng.h 
 * $RCSfile: ,v $
 * $Revision: #1 $
 * $Date: 2015/05/29 $
 * $Author: brianpc.huang $

 *
 *  @par Description:
 *         This contains Event database library macros, definitons, structures,
 *         and API's, which are shared with other modules, and customized engines.
 *---------------------------------------------------------------------------*/

#ifndef _U_EDB_ENG_H_
#define _U_EDB_ENG_H_

/*----------------------------------------------------------------------------*/
/*! @addtogroup groupMW_EDB
 *  @{
 */
/*----------------------------------------------------------------------------*/


/*-----------------------------------------------------------------------------
  include files
  ----------------------------------------------------------------------------*/
#include "u_edb.h"

/*-----------------------------------------------------------------------------
  macros, defines, typedefs, enums
  ----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*! @brief  edb create object function

 *  @param  [in] h_edb_eng              - handle of edb engine
 *  @param  [in] pt_edb_cmd            - edb command
 *  @param  [out] ppv_eng_obj_data  - pointer of edb engine obj data
 *  @param  [out] pe_cond               - pointer of edb engine condition
 *  
 *  @note   EDB Engine should implement such function pointer and register to edb
 *  @see
 *  @return		INT32
 *  @retval		EDBR_OK           - Success
 */
/*----------------------------------------------------------------------------*/
typedef INT32 (*x_edb_eng_create_fct) (
        HANDLE_T            h_edb_eng,
        EDB_COMMAND_T*      pt_edb_cmd,
        VOID**              ppv_eng_obj_data,
        EDB_COND_T*         pe_cond);

/*----------------------------------------------------------------------------*/
/*! @brief  edb delete object function

 *  @param  [in] pv_eng_obj_data  - engine object to delete
 *  
 *  @note   EDB Engine should implement such function pointer and register to edb
 *  @see
 *  @return		INT32
 *  @retval		EDBR_OK           - Success
 */
/*----------------------------------------------------------------------------*/
typedef INT32 (*x_edb_eng_delete_fct) (
        VOID*               pv_eng_obj_data);

/*----------------------------------------------------------------------------*/
/*! @brief  edb get object information length function

 *  @param  [in] h_edb_eng                 - handle of edb engine
 *  @param  [in] e_key_type                - event type to query
 *  @param  [in] pv_key_info               - pointer event key information
 *  @param  [out] pz_event_info_len     - pointer of event info length
 *  @param  [out] pe_cond                  - pointer of edb condition
 *  
 *  @note   EDB Engine should implement such function pointer and register to edb
 *  @see
 *  @return		INT32
 *  @retval		EDBR_OK           - Success
 */
/*----------------------------------------------------------------------------*/
typedef INT32 (*x_edb_eng_get_event_info_len_fct) (
        HANDLE_T            h_edb_eng,
        EDB_KEY_TYPE_T      e_key_type,
        VOID*               pv_key_info,
        SIZE_T*             pz_event_info_len,
        EDB_COND_T*         pe_cond);

/*----------------------------------------------------------------------------*/
/*! @brief  edb get object information function

 *  @param  [in] h_edb_eng                - handle of edb engine
 *  @param  [in] e_key_type               - event type to query
 *  @param  [in] pv_key_info              - pointer event key information
 *  @param  [in] pz_event_info_len      - pointer of event info length
 *  @param  [out] pz_event_info_len     - pointer of event info length
 *  @param  [out] pv_event_info         - pointer of event info information
 *  @param  [out] pe_cond               - pointer of edb engine condition
 *  
 *  @note   EDB Engine should implement such function pointer and register to edb
 *  @see
 *  @return		INT32
 *  @retval		EDBR_OK           - Success
 */
/*----------------------------------------------------------------------------*/
typedef INT32 (*x_edb_eng_get_event_info_fct) (
        HANDLE_T            h_edb_eng,
        EDB_KEY_TYPE_T      e_key_type,
        VOID*               pv_key_info,
        SIZE_T*             pz_event_info_len,
        VOID*               pv_event_info,
        EDB_COND_T*       pe_cond);

/*----------------------------------------------------------------------------*/
/*! @brief  edb task function
 *  
 *  @note   EDB Engine should implement such function pointer and register to edb
 *  @see
 *  @return		INT32
 *  @retval		EDBR_OK           - Success
 */
/*----------------------------------------------------------------------------*/
typedef INT32 (*x_edb_eng_task_fct) ( VOID );

/*----------------------------------------------------------------------------*/
/*! @brief  edb set function

 *  @param  [in] pt_set_cmd         - pointer to the set command
 *  
 *  @note   EDB Engine should implement such function pointer and register to edb
 *  @see
 *  @return		INT32
 *  @retval		EDBR_OK           - Success
 */
/*----------------------------------------------------------------------------*/
typedef INT32 (*x_edb_eng_set_fct) (
        HANDLE_T            h_edb_eng,
        EDB_COMMAND_T*      pt_set_cmd);

/*----------------------------------------------------------------------------*/
/*! @brief  edb get function

 *  @param  [in] pt_get_cmd         - pointer to the get command
 *  
 *  @note   EDB Engine should implement such function pointer and register to edb
 *  @see
 *  @return		INT32
 *  @retval		EDBR_OK           - Success
 */
/*----------------------------------------------------------------------------*/
typedef INT32 (*x_edb_eng_get_fct) (
        HANDLE_T            h_edb_eng,
        EDB_COMMAND_T*      pt_get_cmd);


/*------------------------------------------------------------------*/
/*! @struct EDB_ENG_FCT_TBL_T
 *  @brief  Structure for the EDB engine function table

 *  @code
 * typedef struct _EDB_ENG_FCT_TBL_T
 * {
 *     x_edb_create_event_obj_fct        pf_create_event_obj;
 *     x_edb_delete_event_obj_fct        pf_delete_event_obj;
 *     x_edb_get_event_obj_info_len_fct  pf_get_event_obj_info_len;
 *     x_edb_get_event_obj_info_fct      pf_get_event_obj_info;
 *     x_edb_engine_task_fct             pf_engine_task;
 *     x_edb_set_fct                     pf_set;
 *     x_edb_get_fct                     pf_get;
 * } EDB_ENG_FCT_TBL_T;
 *  @endcode

 *  @li@c   pf_create_event_obj         - edb create fucntion pointer
 *  @li@c   pf_delete_event_obj         - edb delete fucntion pointer     
 *  @li@c   pf_get_event_obj_info_len   - edb get info length fucntion pointer
 *  @li@c   pf_get_event_obj_info       - edb get info fucntion pointer
 *  @li@c   pf_engine_task              - edb task fucntion pointer
 *  @li@c   pf_set                      - edb set fucntion pointer                  
 *  @li@c   pf_get                      - edb get fucntion pointer                  
 */
/*------------------------------------------------------------------*/
/* Structure for the EDB engine function table*/
typedef struct _EDB_ENG_FCT_TBL_T
{
    x_edb_eng_create_fct                   pf_create_eng_obj;
    x_edb_eng_delete_fct                   pf_delete_eng_obj;
    x_edb_eng_get_event_info_len_fct       pf_get_event_info_len;
    x_edb_eng_get_event_info_fct           pf_get_event_info;
    x_edb_eng_task_fct                     pf_engine_task;
    x_edb_eng_set_fct                      pf_set;
    x_edb_eng_get_fct                      pf_get;
} EDB_ENG_FCT_TBL_T;

/*
   EDB_ENG_CTRL_T is the structure of nodes in the engine list.
   */ 
typedef struct _EDB_ENG_T
{
    DLIST_ENTRY_T(_EDB_ENG_T)        t_link;
    BRDCST_TYPE_T                    e_brdcst_type;
    EDB_ENG_FCT_TBL_T                t_edb_fct_tbl;
} EDB_ENG_T;

typedef DLIST_T(_EDB_ENG_T)     EDB_ENG_LIST_T;


/*typedef DLIST_T(_EDB_REQUEST_BASE_CTRL_T)    EDB_REQUEST_BASE_CTRL_LIST_T;*/



typedef struct _EDB_ENG_DATA_KEY_T
{
    BRDCST_TYPE_T                    e_brdcst_type;
    UINT16                           ui2_svl_id;
} EDB_ENG_DATA_KEY_T;


typedef DLIST_T(_EDB_ENG_CTRL_ENTRY_T)   EDB_ENG_CTRL_LIST_T;    

/*----------------------------------------------------------------------------*/
/*! @} */                                             /* end of groupMW_EDB */
/*----------------------------------------------------------------------------*/


#endif /* _U_EDB_ENG_H_ */
