1 /*
2  * Copyright (C) 2008 The Android Open Source Project
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 
17 #ifndef bts_MAP_SEQUENCE_EM_H
18 #define bts_MAP_SEQUENCE_EM_H
19 
20 /* ---- includes ----------------------------------------------------------- */
21 
22 #include "b_BasicEm/Context.h"
23 #include "b_BasicEm/Basic.h"
24 #include "b_BasicEm/Int32Arr.h"
25 #include "b_BasicEm/UInt16Arr.h"
26 #include "b_BasicEm/MemTbl.h"
27 #include "b_TensorEm/VectorMap.h"
28 
29 /* ---- related objects  --------------------------------------------------- */
30 
31 /* ---- typedefs ----------------------------------------------------------- */
32 
33 /* ---- constants ---------------------------------------------------------- */
34 
35 /** data format version number */
36 #define bts_MAP_SEQUENCE_VERSION 100
37 
38 /* ---- object definition -------------------------------------------------- */
39 
40 /** sequence of vector maps */
41 struct bts_MapSequence
42 {
43 	/* ---- public data ---------------------------------------------------- */
44 
45 	/** base element (must be first element) */
46 	struct bts_VectorMap baseE;
47 
48 	/* ---- private data --------------------------------------------------- */
49 
50 	/** internal vector */
51 	struct bts_Flt16Vec vecE;
52 
53 	/* ---- public data ---------------------------------------------------- */
54 
55 	/** map sequence size */
56 	uint32 sizeE;
57 
58 	/** preallocation size for internal vector */
59 	uint32 vecSizeE;
60 
61 	/** object buffer */
62 	struct bbs_UInt16Arr objBufE;
63 
64 	/** map pointer arrray */
65 	struct bts_VectorMap** ptrArrE;
66 
67 };
68 
69 /* ---- associated objects ------------------------------------------------- */
70 
71 /* ---- external functions ------------------------------------------------- */
72 
73 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
74 
75 /** initializes bts_MapSequence  */
76 void bts_MapSequence_init( struct bbs_Context* cpA,
77 					       struct bts_MapSequence* ptrA );
78 
79 /** resets bts_MapSequence  */
80 void bts_MapSequence_exit( struct bbs_Context* cpA,
81 					       struct bts_MapSequence* ptrA );
82 
83 /* ---- \ghd{ operators } -------------------------------------------------- */
84 
85 /** copy operator */
86 void bts_MapSequence_copy( struct bbs_Context* cpA,
87  					       struct bts_MapSequence* ptrA,
88 					       const struct bts_MapSequence* srcPtrA );
89 
90 /** equal operator */
91 flag bts_MapSequence_equal( struct bbs_Context* cpA,
92 						    const struct bts_MapSequence* ptrA,
93 						    const struct bts_MapSequence* srcPtrA );
94 
95 /* ---- \ghd{ query functions } -------------------------------------------- */
96 
97 /* ---- \ghd{ modify functions } ------------------------------------------- */
98 
99 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
100 
101 /** word size (16-bit) object needs when written to memory */
102 uint32 bts_MapSequence_memSize( struct bbs_Context* cpA,
103 						        const struct bts_MapSequence* ptrA );
104 
105 /** writes object to memory; returns number of words (16-bit) written */
106 uint32 bts_MapSequence_memWrite( struct bbs_Context* cpA,
107 							     const struct bts_MapSequence* ptrA, uint16* memPtrA );
108 
109 /** reads object from memory; returns number of words (16-bit) read */
110 uint32 bts_MapSequence_memRead( struct bbs_Context* cpA,
111 							    struct bts_MapSequence* ptrA,
112 							    const uint16* memPtrA,
113 							    struct bbs_MemTbl* mtpA );
114 
115 /* ---- \ghd{ exec functions } --------------------------------------------- */
116 
117 /** Vector map operation.
118  *  Maps vector inVec to outVec (overflow-safe)
119  *  Memory areas of vectors may not overlap
120  */
121 void bts_MapSequence_map( struct bbs_Context* cpA,
122 						  const struct bts_VectorMap* ptrA,
123 						  const struct bts_Flt16Vec* inVecPtrA,
124 						  struct bts_Flt16Vec* outVecPtrA );
125 
126 #endif /* bts_MAP_SEQUENCE_EM_H */
127 
128