• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef HI_GV_DDB_H
17 #define HI_GV_DDB_H
18 
19 #include "hi_type.h"
20 #include "hi_gv_adm.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /* Insert position */
27 typedef enum {
28     DDB_INSERT_PRE = 0,
29     /*  Insert before,   */
30     DDB_INSERT_NEXT,
31     /*  Insert after,   */
32     DDB_INSERT_BUTT
33 } HIGV_DDBINSERT_E;
34 
35 /*
36  * brief Create a DDB.
37  * param[in] fieldCount Field count.
38  * param[in] fieldAttr Field attribute.
39  * param[out] ddbHandle    DDB handle.
40  * retval ::HI_SUCCESS
41  * retval ::HI_ERR_COMM_INVAL
42  */
43 HI_S32 HI_GV_DDB_Create(HI_U32 fieldCount, const HIGV_FIELDATTR_S *fieldAttr, HIGV_HANDLE *ddbHandle);
44 
45 /*
46  * brief Destroy a DDB.
47  * param[in] ddbHandle DDB handle.
48  * retval ::HI_SUCCESS
49  * retval ::HI_ERR_COMM_LOST
50  */
51 HI_S32 HI_GV_DDB_Destroy(HIGV_HANDLE ddbHandle);
52 
53 /*
54  * brief Insert a recoder to the databuffer.
55  * param[in] ddbHandle DDB handle.
56  * param[in] row row position.
57  * param[in] data The pointer of recoder.
58  * param[in] insert The position of insert.
59  * retval ::HI_SUCCESS
60  * retval ::HI_ERR_COMM_LOST
61  * retval ::HI_ERR_DDB_NULLPTR
62  * retval ::HI_ERR_DDB_INVAIDPARA
63  */
64 HI_S32 HI_GV_DDB_Insert(HIGV_HANDLE ddbHandle, HI_U32 row, const HIGV_DBROW_S *data, HIGV_DDBINSERT_E insert);
65 
66 /*
67  * brief Modify a recoder of data buffer.
68  * param[in] ddbHandle DDB handle.
69  * param[in] row row index.
70  * param[in] pdata Recoder data.
71  * retval ::HI_SUCCESS
72  * retval ::HI_ERR_COMM_LOST
73  * retval ::HI_ERR_DDB_NULLPTR
74  * retval ::HI_ERR_DDB_OUTOFRANGE
75  */
76 HI_S32 HI_GV_DDB_Modify(HIGV_HANDLE ddbHandle, HI_U32 row, const HIGV_DBROW_S *data);
77 
78 /*
79  * brief Add a recoder to the tail of data buffer.
80  * param[in] DDB handle.
81  * param[in] data Recoder data.
82  * retval ::HI_SUCCESS
83  * retval ::HI_ERR_COMM_LOST
84  * retval ::HI_ERR_DDB_NULLPTR
85  * retval ::HI_ERR_DDB_BUFFSMALL
86  */
87 HI_S32 HI_GV_DDB_Append(HIGV_HANDLE ddbHandle, const HIGV_DBROW_S *data);
88 
89 /*
90  * brief Clear the recoder in the data buffer.
91  * param[in] ddbHandle DDB handle.
92  * retval ::HI_SUCCESS
93  * retval ::HI_ERR_COMM_LOST
94  */
95 HI_S32 HI_GV_DDB_Clear(HIGV_HANDLE ddbHandle);
96 
97 /*
98  * brief Delete a recoder by key.
99  * param[in] ddbHandle DDB handle.
100  * param[in] row row index.
101  * retval ::HI_SUCCESS
102  * retval ::HI_ERR_COMM_LOST
103  * retval ::HI_ERR_DDB_OUTOFRANGE
104  */
105 HI_S32 HI_GV_DDB_Del(HIGV_HANDLE ddbHandle, HI_U32 row);
106 
107 /*
108  * brief Get the recoder by row number.
109  * param[in] ddbHandle DDB handle.
110  * param[in] row The row of recoder.
111  * param[out] data Recoder data.
112  * retval ::HI_SUCCESS
113  * retval ::HI_ERR_COMM_LOST
114  * retval ::HI_ERR_DDB_NULLPTR
115  * retval ::HI_ERR_DDB_OUTOFRANGE
116  */
117 HI_S32 HI_GV_DDB_GetRow(HIGV_HANDLE ddbHandle, HI_U32 row, HIGV_DBROW_S *data);
118 
119 /*
120  * brief Get n rows form the DDB.
121  * param[in] ddbHandle DDB handle.ݻ
122  * param[in] row  row index.
123  * param[in] num  row number.
124  * param[out] data    Data cache.
125  * param[out] rowNum  row number.
126  * retval ::HI_SUCCESS
127  * retval ::HI_ERR_COMM_LOST
128  * retval ::HI_ERR_DDB_NULLPTR
129  * retval ::HI_ERR_DDB_OUTOFRANGE
130  * retval ::HI_ERR_DDB_INVAIDPARA
131  */
132 HI_S32 HI_GV_DDB_GetRows(HIGV_HANDLE ddbHandle, HI_U32 row, HI_U32 num, const HI_VOID *data, HI_U32 *rowNum);
133 
134 /*
135  * brief Get the column index of data.
136  * param[in]  ddbHandle DDB handle.
137  * param[in]  row row index.
138  * param[in]  col Column index.
139  * param[out] fieldData
140  * param[in]  len Buffer size.
141  * retval ::HI_SUCCESS
142  * retval ::HI_ERR_COMM_LOST
143  * retval ::HI_ERR_DDB_NULLPTR
144  * retval ::HI_ERR_DDB_OUTOFRANGE
145  * retval ::HI_ERR_DDB_BUFFSMALL
146  */
147 HI_S32 HI_GV_DDB_GetCellData(HIGV_HANDLE ddbHandle, HI_U32 row, HI_U32 col, HI_VOID *fieldData, HI_U32 len);
148 
149 /*
150  * brief Set the column index of data.
151  * param[in]  ddbHandle DDB handle.
152  * param[in]  row row index.
153  * param[in]  col Column index.
154  * param[in]  fieldData
155  * param[in]  len Buffer size.
156  * retval ::HI_SUCCESS
157  * retval ::HI_ERR_COMM_LOST
158  * retval ::HI_ERR_DDB_NULLPTR
159  * retval ::HI_ERR_DDB_OUTOFRANGE
160  * retval ::HI_ERR_DDB_OUTOFRANGE
161  */
162 HI_S32 HI_GV_DDB_SetCellData(HIGV_HANDLE ddbHandle, HI_U32 row, HI_U32 col, const HI_VOID *fieldData, HI_U32 len);
163 
164 /*
165  * brief Get the total row number.
166  * param[in] ddbHandle DDB handle.
167  * param[out] rowCount row count.
168  * retval ::HI_SUCCESS
169  * retval ::HI_ERR_COMM_LOST
170  * retval ::HI_ERR_DDB_NULLPTR
171  */
172 HI_S32 HI_GV_DDB_GetRowCount(HIGV_HANDLE ddbHandle, HI_U32 *rowCount);
173 
174 /*
175  * brief Register the function when the data change.
176  * param[in] ddbHandle DDB handle.
177  * param[in] admHandle The object which notify.
178  * retval ::HI_SUCCESS
179  * retval ::HI_ERR_COMM_LOST
180  */
181 HI_S32 HI_GV_DDB_RegisterDataChange(HIGV_HANDLE ddbHandle, HIGV_HANDLE admHandle);
182 
183 /*
184  * brief Unregister the function when data change.
185  * param[in] ddbHandle DDB handle.
186  * param[in] admHandle The object which notify.
187  * retval ::HI_SUCCESS
188  * retval ::HI_ERR_COMM_LOST
189  */
190 HI_S32 HI_GV_DDB_UnRegisterDataChange(HIGV_HANDLE ddbHandle, HIGV_HANDLE admHandle);
191 
192 /*
193  * brief Register callback when data change.
194  * param[in] ddbHandle  DDB handle.
195  * param[in] enable Enable flag.
196  * retval ::HI_SUCCESS
197  * retval ::HI_ERR_COMM_LOST
198  */
199 HI_S32 HI_GV_DDB_EnableDataChange(HIGV_HANDLE ddbHandle, HI_BOOL enable);
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 #endif /* HI_GV_DDB_H */
205