xref: /OK3568_Linux_fs/external/rockit/tgi/sdk/include/rt_metadata.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2018 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * author: Rimon.Xu@rock-chips.com
17  *   date: 20181205
18  */
19 
20 #ifndef INCLUDE_RT_BASE_RT_METADATA_H_
21 #define INCLUDE_RT_BASE_RT_METADATA_H_
22 
23 #include <stdint.h>
24 #include <map>
25 #include "rt_type.h"   // NOLINT
26 #include "rt_error.h"  // NOLINT
27 
28 class RtMetaData;
29 typedef RT_RET (*RTMetaValueFree)(void *);
30 
31 struct RTMetaDataContext;
32 
33 class RtMetaData {
34  public:
35     RtMetaData();
36     RtMetaData(const RtMetaData &from);
37     RtMetaData& operator = (const RtMetaData &);
38 
39     virtual ~RtMetaData();
40 
41     enum Type {
42         TYPE_NONE     = MKTAG('n', 'o', 'n', 'e'),
43         TYPE_C_STRING = MKTAG('c', 's', 't', 'r'),
44         TYPE_INT32    = MKTAG('i', 'n', '3', '2'),
45         TYPE_INT64    = MKTAG('i', 'n', '6', '4'),
46         TYPE_FLOAT    = MKTAG('f', 'l', 'o', 'a'),
47         TYPE_POINTER  = MKTAG('p', 'n', 't', 'r'),
48         TYPE_INT8     = MKTAG('i', 'n', '0', '8'),
49         TYPE_INT16    = MKTAG('i', 'n', '1', '6'),
50         TYPE_STRUCT   = MKTAG('s', 'r', 'u', 't')
51     };
52 
53     virtual void    clear();
54     virtual RT_BOOL remove(UINT64 key);
55 
56     virtual RT_BOOL setCString(UINT64 key, const char *value);
57     virtual RT_BOOL setInt32(UINT64 key, INT32 value);
58     virtual RT_BOOL setInt64(UINT64 key, INT64 value);
59     virtual RT_BOOL setFloat(UINT64 key, float value);
60     virtual RT_BOOL setPointer(UINT64 key, RT_PTR value, RTMetaValueFree freeFunc = RT_NULL);
61     virtual RT_BOOL setStructData(UINT64 key, const void *value, UINT32 size);
62 
63     virtual RT_BOOL findCString(UINT64 key, const char **value) const;
64     virtual RT_BOOL findInt32(UINT64 key, INT32 *value) const;
65     virtual RT_BOOL findInt64(UINT64 key, INT64 *value) const;
66     virtual RT_BOOL findFloat(UINT64 key, float *value) const;
67     virtual RT_BOOL findPointer(UINT64 key, RT_PTR *value) const;
68     virtual RT_BOOL findStructData(UINT64 key, const void **value, UINT32 size) const;
69 
70     virtual RT_BOOL setCString(const char* key, const char *value);
71     virtual RT_BOOL setInt32(const char* key, INT32 value);
72     virtual RT_BOOL setInt64(const char* key, INT64 value);
73     virtual RT_BOOL setFloat(const char* key, float value);
74     virtual RT_BOOL setPointer(const char* key, RT_PTR value, RTMetaValueFree freeFunc = RT_NULL);
75 
76     virtual RT_BOOL findCString(const char* key, const char **value) const;
77     virtual RT_BOOL findInt32(const char* key, INT32 *value) const;
78     virtual RT_BOOL findInt64(const char* key, INT64 *value) const;
79     virtual RT_BOOL findFloat(const char* key, float *value) const;
80     virtual RT_BOOL findPointer(const char* key, RT_PTR *value) const;
81 
82     virtual RT_BOOL setData(
83         UINT64 key, UINT32 type, const void *data, UINT32 size, RTMetaValueFree freeFunc = RT_NULL);
84 
85     virtual RT_BOOL findData(UINT64 key, UINT32 *type,
86                   const void **data, UINT32 *size) const;
87 
88     virtual RT_BOOL hasData(UINT64 key) const;
89     virtual RT_BOOL isEmpty();
90 
91     virtual void dumpToLog() const;
92 
93  private:
94     struct              typed_data;
95     std::map<UINT64, void *> mDataMaps;
96     RTMetaDataContext  *mCtx;
97 };
98 
99 extern "C" {
100 
101 void *createRockitMetaData();
102 void  destroyRockitMetaData(void **meta);
103 
104 }
105 
106 #endif  // INCLUDE_RT_BASE_RT_METADATA_H_
107 
108