Init basesystem source codes.
[staging/basesystem.git] / nsframework / framework_unified / client / include / native_service / ns_rcs_data_handler.hpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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 /**
18  * @file
19  * @brief \~english This file contains declaration of CPassThruInDataHandler class
20  *
21  */
22 /** @addtogroup BaseSystem
23  *  @{
24  */
25 /** @addtogroup native_service
26  *  @ingroup BaseSystem
27  *  @{
28  */
29 /** @addtogroup framework_unified
30  *  @ingroup native_service
31  *  @{
32  */
33 /** @addtogroup nsrcs
34  *  @ingroup framework_unified
35  *  @{
36  */
37
38 // todo: move this file to the rcs interface folder
39
40 #ifndef _NS_RCS_DATA_HANDLER_H__  // NOLINT  (build/header_guard)
41 #define _NS_RCS_DATA_HANDLER_H__
42
43 #include <native_service/frameworkunified_types.h>
44 #include <native_service/ns_endianess.h>
45 #include <vector>
46
47 #ifdef AGL_STUB
48 #include <cstring>
49 #endif
50
51 typedef UI_8 NSRCS_BOOL;
52
53 #define SIZE_OF_PASSTHRU_DATATYPE_IDENTIFIER 1
54 #define SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER 3
55 #define PASSTHRU_DATA_HEADER_LEN 8
56
57
58 // not valid for buffer or array
59 // \return - 0 - invalid type id
60 /*UI_16 GetLengthOfBasicType(UI_8 f_ui8TypeId)
61 {
62
63   UI_16 l_ui16LengthOfBasicType = 0;
64   switch(f_ui8TypeId)
65   {
66   case 0x01:  l_ui16LengthOfBasicType = 2; break;  // eBool
67   case 0x02:  l_ui16LengthOfBasicType = 1; break;  // eUint8
68   case 0x03:  l_ui16LengthOfBasicType = 2; break;  // eUint16
69   case 0x04:  l_ui16LengthOfBasicType = 4; break;  // eUint32
70   case 0x05:  l_ui16LengthOfBasicType = 8; break;  // eUint64
71   case 0x06:  l_ui16LengthOfBasicType = 1; break;  // eSint8
72   case 0x07:  l_ui16LengthOfBasicType = 2; break;  // eSint16
73   case 0x08:  l_ui16LengthOfBasicType = 4; break;  // eSint32
74   case 0x09:  l_ui16LengthOfBasicType = 8; break;  // eSint64
75   case 0x0A:  l_ui16LengthOfBasicType = 8; break;  // eReal
76   default: break;
77   }
78   return l_ui16LengthOfBasicType;
79 }*/
80
81 /////////////////////////////////////////
82 /// Class: CPassThruInDataHandler
83 /////////////////////////////////////////
84 /**
85  * @class CPassThruInDataHandler
86  * \~english @brief Data Handler
87  * \~english @par   Brief Introduction
88  *        Class to get/set function to do input data handler
89  *
90  */
91 class CPassThruInDataHandler {
92  public:
93   /////////////////////////////////////////////////////////////////////////////////////
94   /// \ingroup CPassThruInDataHandler
95   /// \~english @par Summary
96   ///       Constructor of CPassThruInDataHandler class.
97   /// \~english @param None
98   /// \~english @retval None
99   /// \~english @par Preconditions
100   ///       - None.
101   /// \~english @par Change of the internal state
102   ///       - The internal state is not changed.
103   /// \~english @par Causes of failures
104   ///       None
105   /// \~english @par Classification
106   ///       Public
107   /// \~english @par Type
108   ///       None
109   /// \~english @par Detail
110   ///       To generate a CPassThruInDataHandler class. \n
111   ///       Member variables (m_ui8Data, m_ui16TotalLength, m_ui16ParamCount, m_pui8CurOffset, m_ui16RemainingLength) to
112   ///       be initialized. \n
113   /// \~english @see  ~CPassThruInDataHandler
114   ////////////////////////////////////////////////////////////////////////////////////
115   CPassThruInDataHandler(UI_8 *f_pui8Data, UI_16 f_ui16Length, UI_16 f_ui16ParamCount)
116     : m_ui8Data(f_pui8Data),
117       m_ui16TotalLength(f_ui16Length),
118       m_ui16ParamCount(f_ui16ParamCount),
119       m_pui8CurOffset(f_pui8Data),
120       m_ui16RemainingLength(f_ui16Length) {
121
122   }
123
124   /////////////////////////////////////////////////////////////////////////////////////
125   /// \ingroup ~CPassThruInDataHandler
126   /// \~english @par Summary
127   ///       Destructor of CPassThruInDataHandler class.
128   /// \~english @param None
129   /// \~english @retval None
130   /// \~english @par Preconditions
131   ///       - None.
132   /// \~english @par Change of the internal state
133   ///       - The internal state is not changed.
134   /// \~english @par Causes of failures
135   ///       None
136   /// \~english @par Classification
137   ///       Public
138   /// \~english @par Type
139   ///       None
140   /// \~english @par Detail
141   ///       To delete a CPassThruInDataHandler class. \n
142   /// \~english @see  CPassThruInDataHandler
143   ////////////////////////////////////////////////////////////////////////////////////
144   ~CPassThruInDataHandler() {
145     m_ui8Data = NULL;  // Do not delete. Because, not allocated in this class
146   }
147
148   //////////////////////////////////////////////////////////////////////////////////////////////
149   /// \ingroup GetBool
150   /// \~english @par Brief
151   ///     This function is used to convert value to type NSRCS_BOOL
152   /// \~english @param [out] f_rcsboolOutValue
153   ///     NSRCS_BOOL & - the given type of covert result
154   /// \~english @retval EFrameworkunifiedStatus
155   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
156   /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
157   /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
158   /// \~english @par Prerequisite
159   ///      - None
160   /// \~english @par Change of internal state
161   ///      - None
162   /// \~english @par Conditions of processing failure
163   ///      - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
164   ///      - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
165   /// \~english @par Classification
166   ///       Public
167   /// \~english @par Type
168   ///       Sync Only
169   /// \~english @par Detail
170   ///       Convert member data to the type NSRCS_BOOL(f_rcsboolOutValue).
171   ///       Return the value(type EFrameworkunifiedStatus) indicate the operation result.
172   /// \~english @see none
173   ////////////////////////////////////////////////////////////////////////////////////////////////
174   EFrameworkunifiedStatus GetBool(NSRCS_BOOL &f_rcsboolOutValue) {
175     return GetValue<NSRCS_BOOL>(f_rcsboolOutValue);
176   }
177
178   //////////////////////////////////////////////////////////////////////////////////////////////
179   /// \ingroup GetUI8
180   /// \~english @par Brief
181   ///     This function is used to convert value to type UI_8
182   /// \~english @param [out] f_rcsboolOutValue
183   ///     UI_8 & - the given type of covert result
184   /// \~english @retval EFrameworkunifiedStatus
185   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
186   /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
187   /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
188   /// \~english @par Prerequisite
189   ///      - None
190   /// \~english @par Change of internal state
191   ///      - None
192   /// \~english @par Conditions of processing failure
193   ///      - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
194   ///      - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
195   /// \~english @par Classification
196   ///       Public
197   /// \~english @par Type
198   ///       Sync Only
199   /// \~english @par Detail
200   ///       Convert member data to the type UI_8(f_ui8OutValue).
201   ///       Return the value(type EFrameworkunifiedStatus) indicate the operation result.
202   /// \~english @see none
203   ////////////////////////////////////////////////////////////////////////////////////////////////
204   EFrameworkunifiedStatus GetUI8(UI_8 &f_ui8OutValue) {
205     return GetValue<UI_8>(f_ui8OutValue);
206   }
207
208   //////////////////////////////////////////////////////////////////////////////////////////////
209   /// \ingroup GetUI16
210   /// \~english @par Brief
211   ///     This function is used to convert value to type UI_16
212   /// \~english @param [out] f_rcsboolOutValue
213   ///     UI_16 & - the given type of covert result
214   /// \~english @retval EFrameworkunifiedStatus
215   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
216   /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
217   /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
218   /// \~english @par Prerequisite
219   ///      - None
220   /// \~english @par Change of internal state
221   ///      - None
222   /// \~english @par Conditions of processing failure
223   ///      - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
224   ///      - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
225   /// \~english @par Classification
226   ///       Public
227   /// \~english @par Type
228   ///       Sync Only
229   /// \~english @par Detail
230   ///       Convert member data to the type UI_16(f_ui16OutValue).
231   ///       Return the value(type EFrameworkunifiedStatus) indicate the operation result.
232   /// \~english @see none
233   ////////////////////////////////////////////////////////////////////////////////////////////////
234   EFrameworkunifiedStatus GetUI16(UI_16 &f_ui16OutValue) {
235     EFrameworkunifiedStatus l_eStatus = GetValue<UI_16>(f_ui16OutValue);
236     f_ui16OutValue = ConvertEndian_UI16(f_ui16OutValue);
237     return l_eStatus;
238   }
239
240   //////////////////////////////////////////////////////////////////////////////////////////////
241   /// \ingroup GetUI32
242   /// \~english @par Brief
243   ///     This function is used to convert value to type UI_32
244   /// \~english @param [out] f_rcsboolOutValue
245   ///     UI_32 & - the given type of covert result
246   /// \~english @retval EFrameworkunifiedStatus
247   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
248   /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
249   /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
250   /// \~english @par Prerequisite
251   ///      - None
252   /// \~english @par Change of internal state
253   ///      - None
254   /// \~english @par Conditions of processing failure
255   ///      - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
256   ///      - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
257   /// \~english @par Classification
258   ///       Public
259   /// \~english @par Type
260   ///       Sync Only
261   /// \~english @par Detail
262   ///       Convert member data to the type UI_32(f_ui32OutValue).
263   ///       Return the value(type EFrameworkunifiedStatus) indicate the operation result.
264   /// \~english @see none
265   ////////////////////////////////////////////////////////////////////////////////////////////////
266   EFrameworkunifiedStatus GetUI32(UI_32 &f_ui32OutValue) {
267     EFrameworkunifiedStatus l_eStatus = GetValue<UI_32>(f_ui32OutValue);
268     f_ui32OutValue = ConvertEndian_UI32(f_ui32OutValue);
269     return l_eStatus;
270   }
271
272   //////////////////////////////////////////////////////////////////////////////////////////////
273   /// \ingroup GetUI64
274   /// \~english @par Brief
275   ///     This function is used to convert value to type UI_64
276   /// \~english @param [out] f_rcsboolOutValue
277   ///     UI_64 & - the given type of covert result
278   /// \~english @retval EFrameworkunifiedStatus
279   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
280   /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
281   /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
282   /// \~english @par Prerequisite
283   ///      - None
284   /// \~english @par Change of internal state
285   ///      - None
286   /// \~english @par Conditions of processing failure
287   ///      - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
288   ///      - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
289   /// \~english @par Classification
290   ///       Public
291   /// \~english @par Type
292   ///       Sync Only
293   /// \~english @par Detail
294   ///       Convert member data to the type UI_64(f_ui64OutValue).
295   ///       Return the value(type EFrameworkunifiedStatus) indicate the operation result.
296   /// \~english @see none
297   ////////////////////////////////////////////////////////////////////////////////////////////////
298   EFrameworkunifiedStatus GetUI64(UI_64 &f_ui64OutValue) {
299     EFrameworkunifiedStatus l_eStatus = GetValue<UI_64>(f_ui64OutValue);
300     f_ui64OutValue = ConvertEndian_UI64(f_ui64OutValue);
301     return l_eStatus;
302   }
303
304   //////////////////////////////////////////////////////////////////////////////////////////////
305   /// \ingroup GetSI8
306   /// \~english @par Brief
307   ///     This function is used to convert value to type SI_8
308   /// \~english @param [out] f_rcsboolOutValue
309   ///     SI_8 & - the given type of covert result
310   /// \~english @retval EFrameworkunifiedStatus
311   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
312   /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
313   /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
314   /// \~english @par Prerequisite
315   ///      - None
316   /// \~english @par Change of internal state
317   ///      - None
318   /// \~english @par Conditions of processing failure
319   ///      - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
320   ///      - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
321   /// \~english @par Classification
322   ///       Public
323   /// \~english @par Type
324   ///       Sync Only
325   /// \~english @par Detail
326   ///       Convert member data to the type SI_8(f_si8OutValue).
327   ///       Return the value(type EFrameworkunifiedStatus) indicate the operation result.
328   /// \~english @see none
329   ////////////////////////////////////////////////////////////////////////////////////////////////
330   EFrameworkunifiedStatus GetSI8(SI_8 &f_si8OutValue) {
331     return GetValue<SI_8>(f_si8OutValue);
332   }
333
334   //////////////////////////////////////////////////////////////////////////////////////////////
335   /// \ingroup GetSI16
336   /// \~english @par Brief
337   ///     This function is used to convert value to type SI_16
338   /// \~english @param [out] f_rcsboolOutValue
339   ///     SI_16 & - the given type of covert result
340   /// \~english @retval EFrameworkunifiedStatus
341   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
342   /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
343   /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
344   /// \~english @par Prerequisite
345   ///      - None
346   /// \~english @par Change of internal state
347   ///      - None
348   /// \~english @par Conditions of processing failure
349   ///      - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
350   ///      - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
351   /// \~english @par Classification
352   ///       Public
353   /// \~english @par Type
354   ///       Sync Only
355   /// \~english @par Detail
356   ///       Convert member data to the type SI_16(f_si16OutValue).
357   ///       Return the value(type EFrameworkunifiedStatus) indicate the operation result.
358   /// \~english @see none
359   ////////////////////////////////////////////////////////////////////////////////////////////////
360   EFrameworkunifiedStatus GetSI16(SI_16 &f_si16OutValue) {
361     EFrameworkunifiedStatus l_eStatus = GetValue<SI_16>(f_si16OutValue);
362     f_si16OutValue = ConvertEndian_SI16(f_si16OutValue);
363     return l_eStatus;
364   }
365
366   //////////////////////////////////////////////////////////////////////////////////////////////
367   /// \ingroup GetSI32
368   /// \~english @par Brief
369   ///     This function is used to convert value to type SI_32
370   /// \~english @param [out] f_rcsboolOutValue
371   ///     SI_32 & - the given type of covert result
372   /// \~english @retval EFrameworkunifiedStatus
373   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
374   /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
375   /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
376   /// \~english @par Prerequisite
377   ///      - None
378   /// \~english @par Change of internal state
379   ///      - None
380   /// \~english @par Conditions of processing failure
381   ///      - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
382   ///      - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
383   /// \~english @par Classification
384   ///       Public
385   /// \~english @par Type
386   ///       Sync Only
387   /// \~english @par Detail
388   ///       Convert member data to the type SI_32(f_si32OutValue).
389   ///       Return the value(type EFrameworkunifiedStatus) indicate the operation result.
390   /// \~english @see none
391   ////////////////////////////////////////////////////////////////////////////////////////////////
392   EFrameworkunifiedStatus GetSI32(SI_32 &f_si32OutValue) {
393     EFrameworkunifiedStatus l_eStatus = GetValue<SI_32>(f_si32OutValue);
394     f_si32OutValue = ConvertEndian_SI32(f_si32OutValue);
395     return l_eStatus;
396   }
397
398   //////////////////////////////////////////////////////////////////////////////////////////////
399   /// \ingroup GetSI64
400   /// \~english @par Brief
401   ///     This function is used to convert value to type SI_64
402   /// \~english @param [out] f_rcsboolOutValue
403   ///     SI_64 & - the given type of covert result
404   /// \~english @retval EFrameworkunifiedStatus
405   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
406   /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
407   /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
408   /// \~english @par Prerequisite
409   ///      - None
410   /// \~english @par Change of internal state
411   ///      - None
412   /// \~english @par Conditions of processing failure
413   ///      - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
414   ///      - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
415   /// \~english @par Classification
416   ///       Public
417   /// \~english @par Type
418   ///       Sync Only
419   /// \~english @par Detail
420   ///       Convert member data to the type SI_64(f_si64OutValue).
421   ///       Return the value(type EFrameworkunifiedStatus) indicate the operation result.
422   /// \~english @see none
423   ////////////////////////////////////////////////////////////////////////////////////////////////
424   EFrameworkunifiedStatus GetSI64(SI_64 &f_si64OutValue) {
425     EFrameworkunifiedStatus l_eStatus = GetValue<SI_64>(f_si64OutValue);
426     f_si64OutValue = ConvertEndian_SI64(f_si64OutValue);
427     return l_eStatus;
428   }
429
430   //////////////////////////////////////////////////////////////////////////////////////////////
431   /// \ingroup GetBuffer
432   /// \~english @par Brief
433   ///     This function is used to get the buffer and its size.
434   /// \~english @param [out] f_pui8Buffer
435   ///     UI_8 *& - buffer address
436   /// \~english @param [out] f_ui16BufLength
437   ///     UI_16 - buffer size
438   /// \~english @retval EFrameworkunifiedStatus
439   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
440   /// \~english @retval eFrameworkunifiedStatusInvldID - invalid data type id passed
441   /// \~english @retval eFrameworkunifiedStatusFail - no sufficient data is available
442   /// \~english @par Prerequisite
443   ///      - None
444   /// \~english @par Change of internal state
445   ///      - None
446   /// \~english @par Conditions of processing failure
447   ///      - Data of value(m_ui16RemainingLength) is invalid(outrange of the size
448   ///      SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER) [eFrameworkunifiedStatusInvldParam]
449   ///      - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
450   ///      - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
451   /// \~english @par Classification
452   ///       Public
453   /// \~english @par Type
454   ///       Sync Only
455   /// \~english @par Detail
456   ///       Get buffer address(f_pui8Buffer) and its size.
457   ///       Return the value(type EFrameworkunifiedStatus) indicate the operation result.
458   /// \~english @see none
459   ////////////////////////////////////////////////////////////////////////////////////////////////
460   EFrameworkunifiedStatus GetBuffer(UI_8 *&f_pui8Buffer, UI_16 &f_ui16BufLength) {
461     EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
462     if (f_pui8Buffer == NULL) {
463       FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "f_pui8Buffer is NULL");
464       return eFrameworkunifiedStatusNullPointer;
465     }
466     if (m_pui8CurOffset == NULL) {
467       FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "m_pui8CurOffsetis NULL");
468       return eFrameworkunifiedStatusNullPointer;
469     }
470     if (m_ui16RemainingLength >= SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER) {
471       if (0xB == *m_pui8CurOffset) {  // check if the corresponding data is of type buffer
472         m_pui8CurOffset++;
473         f_ui16BufLength = *(static_cast<UI_16 *>(static_cast<PVOID>(m_pui8CurOffset)));
474         f_ui16BufLength = ConvertEndian_UI16(f_ui16BufLength);
475         m_pui8CurOffset += sizeof(UI_16);
476         m_ui16RemainingLength = static_cast<UI_16>(m_ui16RemainingLength - SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER);
477
478         if (m_ui16RemainingLength >= f_ui16BufLength) {
479           f_pui8Buffer = m_pui8CurOffset;
480           m_pui8CurOffset += f_ui16BufLength;
481           m_ui16RemainingLength = static_cast<UI_16>(m_ui16RemainingLength - f_ui16BufLength);
482         } else {
483           l_eStatus = eFrameworkunifiedStatusFail;
484         }
485       } else {
486         l_eStatus = eFrameworkunifiedStatusInvldID;
487       }
488     } else {
489       l_eStatus = eFrameworkunifiedStatusFail;
490     }
491     return l_eStatus;
492   }
493
494   //////////////////////////////////////////////////////////////////////////////////////////////
495   /// \ingroup GetArrayCount
496   /// \~english @par Brief
497   ///     This function is used to get the buffer and its size.
498   /// \~english @param [out] f_ui16NoOfArrayElements
499   ///     UI_16 - buffer size
500   /// \~english @retval EFrameworkunifiedStatus
501   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
502   /// \~english @retval eFrameworkunifiedStatusInvldID - If no array id found at the current location
503   /// \~english @retval eFrameworkunifiedStatusFail - no sufficient buffer to read the data
504   /// \~english @par Prerequisite
505   ///      - None
506   /// \~english @par Change of internal state
507   ///      - None
508   /// \~english @par Conditions of processing failure
509   ///      - Data of value(m_ui16RemainingLength) is invalid(outrange of the size
510   ///      SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER) [eFrameworkunifiedStatusInvldParam]
511   ///      - Data of value(m_pui8CurOffset) is invalid [eFrameworkunifiedStatusInvldParam]
512   ///      - Covert value(m_pui8CurOffset) failed [eFrameworkunifiedStatusFail]
513   /// \~english @par Classification
514   ///       Public
515   /// \~english @par Type
516   ///       Sync Only
517   /// \~english @par Detail
518   ///       Get buffer address(f_pui8Buffer) and its size.
519   ///       Return the value(type EFrameworkunifiedStatus) indicate the operation result.
520   /// \~english @see none
521   ////////////////////////////////////////////////////////////////////////////////////////////////
522   EFrameworkunifiedStatus GetArrayCount(UI_16 &f_ui16NoOfArrayElements) {
523     EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
524     if (m_pui8CurOffset == NULL) {
525       FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "m_pui8CurOffsetis NULL");
526       return eFrameworkunifiedStatusNullPointer;
527     }
528     if (m_ui16RemainingLength >= SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER) {
529       if (0xC == *m_pui8CurOffset) {  // check if the corresponding data is of type array
530         m_pui8CurOffset++;
531         f_ui16NoOfArrayElements = *(static_cast<UI_16 *>(static_cast<PVOID>(m_pui8CurOffset)));
532         f_ui16NoOfArrayElements = ConvertEndian_UI16(f_ui16NoOfArrayElements);
533         m_pui8CurOffset += sizeof(UI_16);
534         m_ui16RemainingLength = static_cast<UI_16>(m_ui16RemainingLength - SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER);
535       } else {
536         l_eStatus = eFrameworkunifiedStatusInvldID;
537       }
538     } else {
539       l_eStatus = eFrameworkunifiedStatusFail;
540     }
541     return l_eStatus;
542   }
543
544   UI_16 GetDataLength() {
545     return m_ui16TotalLength;
546   }
547
548  private:
549   // template <class DataType>
550   // EFrameworkunifiedStatus GetValue(DataType& f_dtOutValue);
551
552
553   /*
554    *  \return -
555    *  eFrameworkunifiedStatusFail - no sufficient data is available
556    *  eFrameworkunifiedStatusOK - data retrieved
557    *  eFrameworkunifiedStatusInvldID - invalid data type id passed
558    */
559   template <class DataType>
560   EFrameworkunifiedStatus GetValue(DataType &l_dtOutValue) {
561     if (m_pui8CurOffset == NULL) {
562       FRAMWEORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "m_pui8CurOffsetis NULL");
563       return eFrameworkunifiedStatusNullPointer;
564     }
565     EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
566     if (m_ui16RemainingLength >= (sizeof(DataType) + SIZE_OF_PASSTHRU_DATATYPE_IDENTIFIER)) {
567       if ((0x1 <= *m_pui8CurOffset) && (*m_pui8CurOffset <= 0x9))  // Get value is applicable only for basic types,
568         // not for buffer and array
569       {
570         m_pui8CurOffset++;
571         l_dtOutValue = *(static_cast<DataType *>(static_cast<PVOID>(m_pui8CurOffset)));
572         m_ui16RemainingLength = static_cast<UI_16>(m_ui16RemainingLength - sizeof(DataType));
573         m_pui8CurOffset += sizeof(DataType);
574       } else {
575         l_eStatus = eFrameworkunifiedStatusInvldID;
576       }
577     } else {
578       l_eStatus = eFrameworkunifiedStatusFail;
579     }
580     return l_eStatus;
581   }
582
583   UI_8 *m_ui8Data;
584   UI_16 m_ui16TotalLength;  // total data length
585   UI_16 m_ui16ParamCount;
586
587   UI_8 *m_pui8CurOffset;
588   UI_16 m_ui16RemainingLength;  // remaining data length. Not yet parsed
589 };
590
591 /////////////////////////////////////////
592 //// CPassThruOutDataHandler
593 /////////////////////////////////////////
594 /**
595  * @class CPassThruOutDataHandler
596  * \~english @brief Data Handler
597  * \~english @par   Brief Introduction
598  *        Class to get/set function to do output data handler
599  *
600  */
601 class CPassThruOutDataHandler {
602  public:
603   /////////////////////////////////////////////////////////////////////////////////////
604   /// \ingroup CPassThruOutDataHandler
605   /// \~english @par Summary
606   ///       Constructor of CPassThruOutDataHandler class.
607   /// \~english @param None
608   /// \~english @retval None
609   /// \~english @par Preconditions
610   ///       - None.
611   /// \~english @par Change of the internal state
612   ///       - The internal state is not changed.
613   /// \~english @par Causes of failures
614   ///       None
615   /// \~english @par Classification
616   ///       Public
617   /// \~english @par Type
618   ///       None
619   /// \~english @par Detail
620   ///       To generate a CPassThruOutDataHandler class. \n
621   ///       Member variables (m_ui16TotalLength, m_ui16ParamCount, m_ui16CurOffset, m_ui16CurrentArrCount,
622   ///       m_bArrayTypeSet, m_ui8LastArrDataType) to be initialized. \n
623   /// \~english @see  ~CPassThruOutDataHandler
624   ////////////////////////////////////////////////////////////////////////////////////
625   CPassThruOutDataHandler(UI_8 f_ui8ClientId, UI_8 f_ui8PluginId, UI_32 f_ui32CommandId)
626     : m_ui16TotalLength(PASSTHRU_DATA_HEADER_LEN),
627       m_ui16ParamCount(0),
628       m_ui16CurOffset(0),
629       m_ui16CurrentArrCount(0),
630       m_bArrayTypeSet(FALSE),
631       m_ui8LastArrDataType(0) {  // default data type eNull
632     m_vui8Data.resize(PASSTHRU_DATA_HEADER_LEN);
633     // TODO: check error condition for resize operation
634     // TODO: try if &m_vui8Data[m_ui16CurOffset] directly works without casting
635     *static_cast<UI_8 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = f_ui8ClientId;
636     m_ui16CurOffset++;
637     *static_cast<UI_8 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = f_ui8PluginId;
638     m_ui16CurOffset++;
639     *static_cast<UI_32 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = ConvertEndian_UI32(f_ui32CommandId);
640     m_ui16CurOffset = static_cast<UI_16>(m_ui16CurOffset + sizeof(UI_32));
641     *static_cast<UI_16 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = 0;  // initialize param count
642     m_ui16ParamCount = m_ui16CurOffset;
643     m_ui16CurOffset = static_cast<UI_16>(m_ui16CurOffset + sizeof(UI_16));
644     m_ui8ClientId = f_ui8ClientId;
645   }
646
647   /////////////////////////////////////////////////////////////////////////////////////
648   /// \ingroup ~CPassThruOutDataHandler
649   /// \~english @par Summary
650   ///       Destructor of CPassThruOutDataHandler class.
651   /// \~english @param None
652   /// \~english @retval None
653   /// \~english @par Preconditions
654   ///       - None.
655   /// \~english @par Change of internal state
656   ///       - The internal state is not changed.
657   /// \~english @par Change of the internal state
658   ///       - The internal state is not changed.
659   /// \~english @par Causes of failures
660   ///       None
661   /// \~english @par Classification
662   ///       Public
663   /// \~english @par Type
664   ///       None
665   /// \~english @par Detail
666   ///       To delete a CPassThruOutDataHandler class. \n
667   /// \~english @see  CPassThruOutDataHandler
668   ////////////////////////////////////////////////////////////////////////////////////
669   ~CPassThruOutDataHandler() {
670     m_vui8Data.clear();
671   }
672
673   //////////////////////////////////////////////////////////////////////////////////////////////
674   /// \ingroup GetClientID
675   /// \~english @par Brief
676   ///     This function is used to get clinet id.
677   /// \~english @param none
678   /// \~english @retval
679   ///     UI_8 - client id
680   /// \~english @par Prerequisite
681   ///      - None
682   /// \~english @par Change of internal state
683   ///      - None
684   /// \~english @par Conditions of processing failure
685   ///      - none
686   /// \~english @par Classification
687   ///       Public
688   /// \~english @par Type
689   ///       Sync Only
690   /// \~english @par Detail
691   ///       Return the value(m_ui8ClientId).
692   /// \~english @see none
693   ////////////////////////////////////////////////////////////////////////////////////////////////
694   UI_8 GetClientID() {
695     return m_ui8ClientId;
696   }
697
698   //////////////////////////////////////////////////////////////////////////////////////////////
699   /// \ingroup GetData
700   /// \~english @par Brief
701   ///     This function is used to get m_vui8Data data address.
702   /// \~english @param none
703   /// \~english @retval
704   ///     UI_8 * - m_vui8Data data address
705   /// \~english @par Prerequisite
706   ///      - None
707   /// \~english @par Change of internal state
708   ///      - None
709   /// \~english @par Conditions of processing failure
710   ///      - none
711   /// \~english @par Classification
712   ///       Public
713   /// \~english @par Type
714   ///       Sync Only
715   /// \~english @par Detail
716   ///       Return m_vui8Data data address.
717   /// \~english @see none
718   ////////////////////////////////////////////////////////////////////////////////////////////////
719   UI_8 *GetData() {
720     return static_cast<UI_8 *>(static_cast<PVOID>(&m_vui8Data[0]));
721   }
722
723   //////////////////////////////////////////////////////////////////////////////////////////////
724   /// \ingroup GetLength
725   /// \~english @par Brief
726   ///     This function is used to get m_ui16CurOffset value.
727   /// \~english @param none
728   /// \~english @retval
729   ///     UI_16 - m_ui16CurOffset value
730   /// \~english @par Prerequisite
731   ///      - None
732   /// \~english @par Change of internal state
733   ///      - None
734   /// \~english @par Conditions of processing failure
735   ///      - none
736   /// \~english @par Classification
737   ///       Public
738   /// \~english @par Type
739   ///       Sync Only
740   /// \~english @par Detail
741   ///       Return m_ui16CurOffset value.
742   /// \~english @see none
743   ////////////////////////////////////////////////////////////////////////////////////////////////
744   UI_16 GetLength() {
745     return m_ui16CurOffset;
746   }
747
748   //////////////////////////////////////////////////////////////////////////////////////////////
749   /// \ingroup SetBool
750   /// \~english @par Brief
751   ///     This function is used to set NSRCS_BOOL type value.
752   /// \~english @param[in] f_rcsboolValue
753   ///        NSRCS_BOOL - new NSRCS_BOOL value
754   /// \~english @retval EFrameworkunifiedStatus
755   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
756   /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
757   /// \~english @par Prerequisite
758   ///      - None
759   /// \~english @par Change of internal state
760   ///      - None
761   /// \~english @par Conditions of processing failure
762   ///      - none
763   /// \~english @par Classification
764   ///       Public
765   /// \~english @par Type
766   ///       Sync Only
767   /// \~english @par Detail
768   ///       Set NSRCS_BOOL type value.
769   /// \~english @see none
770   ////////////////////////////////////////////////////////////////////////////////////////////////
771   EFrameworkunifiedStatus SetBool(NSRCS_BOOL &f_rcsboolValue) {
772     return SetValue<NSRCS_BOOL>(f_rcsboolValue, 0x1);
773   }
774
775   //////////////////////////////////////////////////////////////////////////////////////////////
776   /// \ingroup SetUI8
777   /// \~english @par Brief
778   ///     This function is used to set UI_8 type value.
779   /// \~english @param[in] f_ui8Value
780   ///        UI_8 - new UI_8 value
781   /// \~english @retval EFrameworkunifiedStatus
782   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
783   /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
784   /// \~english @par Prerequisite
785   ///      - None
786   /// \~english @par Change of internal state
787   ///      - None
788   /// \~english @par Conditions of processing failure
789   ///      - none
790   /// \~english @par Classification
791   ///       Public
792   /// \~english @par Type
793   ///       Sync Only
794   /// \~english @par Detail
795   ///       Set UI_8 type value.
796   /// \~english @see none
797   ////////////////////////////////////////////////////////////////////////////////////////////////
798   EFrameworkunifiedStatus SetUI8(UI_8 f_ui8Value) {
799     return SetValue<UI_8>(f_ui8Value, 0x2);
800   }
801
802   //////////////////////////////////////////////////////////////////////////////////////////////
803   /// \ingroup SetUI16
804   /// \~english @par Brief
805   ///     This function is used to set UI_16 type value.
806   /// \~english @param[in] f_ui16Value
807   ///        UI_16 - new UI_16 value
808   /// \~english @retval EFrameworkunifiedStatus
809   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
810   /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
811   /// \~english @par Prerequisite
812   ///      - None
813   /// \~english @par Change of internal state
814   ///      - None
815   /// \~english @par Conditions of processing failure
816   ///      - none
817   /// \~english @par Classification
818   ///       Public
819   /// \~english @par Type
820   ///       Sync Only
821   /// \~english @par Detail
822   ///       Set UI_16 type value.
823   /// \~english @see none
824   ////////////////////////////////////////////////////////////////////////////////////////////////
825   EFrameworkunifiedStatus SetUI16(UI_16 f_ui16Value) {
826     return SetValue<UI_16>(ConvertEndian_UI16(f_ui16Value), 0x3);
827   }
828
829   //////////////////////////////////////////////////////////////////////////////////////////////
830   /// \ingroup SetUI32
831   /// \~english @par Brief
832   ///     This function is used to set UI_32 type value.
833   /// \~english @param[in] f_ui32Value
834   ///        UI_32 - new UI_32 value
835   /// \~english @retval EFrameworkunifiedStatus
836   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
837   /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
838   /// \~english @par Prerequisite
839   ///      - None
840   /// \~english @par Change of internal state
841   ///      - None
842   /// \~english @par Conditions of processing failure
843   ///      - none
844   /// \~english @par Classification
845   ///       Public
846   /// \~english @par Type
847   ///       Sync Only
848   /// \~english @par Detail
849   ///       Set UI_32 type value.
850   /// \~english @see none
851   ////////////////////////////////////////////////////////////////////////////////////////////////
852   EFrameworkunifiedStatus SetUI32(UI_32 f_ui32Value) {
853     return SetValue<UI_32>(ConvertEndian_UI32(f_ui32Value), 0x4);
854   }
855
856   //////////////////////////////////////////////////////////////////////////////////////////////
857   /// \ingroup SetUI64
858   /// \~english @par Brief
859   ///     This function is used to set UI_64 type value.
860   /// \~english @param[in] f_ui64Value
861   ///        UI_64 - new UI_64 value
862   /// \~english @retval EFrameworkunifiedStatus
863   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
864   /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
865   /// \~english @par Prerequisite
866   ///      - None
867   /// \~english @par Change of internal state
868   ///      - None
869   /// \~english @par Conditions of processing failure
870   ///      - none
871   /// \~english @par Classification
872   ///       Public
873   /// \~english @par Type
874   ///       Sync Only
875   /// \~english @par Detail
876   ///       Set UI_64 type value.
877   /// \~english @see none
878   ////////////////////////////////////////////////////////////////////////////////////////////////
879   EFrameworkunifiedStatus SetUI64(UI_64 f_ui64Value) {
880     return SetValue<UI_64>(ConvertEndian_UI64(f_ui64Value), 0x5);
881   }
882
883   //////////////////////////////////////////////////////////////////////////////////////////////
884   /// \ingroup SetSI8
885   /// \~english @par Brief
886   ///     This function is used to set SI_8 type value.
887   /// \~english @param[in] f_si8Value
888   ///        SI_8 - new SI_8 value
889   /// \~english @retval EFrameworkunifiedStatus
890   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
891   /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
892   /// \~english @par Prerequisite
893   ///      - None
894   /// \~english @par Change of internal state
895   ///      - None
896   /// \~english @par Conditions of processing failure
897   ///      - none
898   /// \~english @par Classification
899   ///       Public
900   /// \~english @par Type
901   ///       Sync Only
902   /// \~english @par Detail
903   ///       Set SI_8 type value.
904   /// \~english @see none
905   ////////////////////////////////////////////////////////////////////////////////////////////////
906   EFrameworkunifiedStatus SetSI8(SI_8 f_si8Value) {
907     return SetValue<SI_8>(f_si8Value, 0x6);
908   }
909
910   //////////////////////////////////////////////////////////////////////////////////////////////
911   /// \ingroup SetSI16
912   /// \~english @par Brief
913   ///     This function is used to set SI_16 type value.
914   /// \~english @param[in] f_si16Value
915   ///        SI_16 - new SI_16 value
916   /// \~english @retval EFrameworkunifiedStatus
917   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
918   /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
919   /// \~english @par Prerequisite
920   ///      - None
921   /// \~english @par Change of internal state
922   ///      - None
923   /// \~english @par Conditions of processing failure
924   ///      - none
925   /// \~english @par Classification
926   ///       Public
927   /// \~english @par Type
928   ///       Sync Only
929   /// \~english @par Detail
930   ///       Set SI_16 type value.
931   /// \~english @see none
932   ////////////////////////////////////////////////////////////////////////////////////////////////
933   EFrameworkunifiedStatus SetSI16(SI_16 f_si16Value) {
934     return SetValue<SI_16>(ConvertEndian_SI16(f_si16Value), 0x7);
935   }
936
937   //////////////////////////////////////////////////////////////////////////////////////////////
938   /// \ingroup SetSI32
939   /// \~english @par Brief
940   ///     This function is used to set SI_32 type value.
941   /// \~english @param[in] f_si32Value
942   ///        SI_32 - new SI_32 value
943   /// \~english @retval EFrameworkunifiedStatus
944   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
945   /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
946   /// \~english @par Prerequisite
947   ///      - None
948   /// \~english @par Change of internal state
949   ///      - None
950   /// \~english @par Conditions of processing failure
951   ///      - none
952   /// \~english @par Classification
953   ///       Public
954   /// \~english @par Type
955   ///       Sync Only
956   /// \~english @par Detail
957   ///       Set SI_32 type value.
958   /// \~english @see none
959   ////////////////////////////////////////////////////////////////////////////////////////////////
960   EFrameworkunifiedStatus SetSI32(SI_32 f_si32Value) {
961     return SetValue<SI_32>(ConvertEndian_SI32(f_si32Value), 0x8);
962   }
963
964   //////////////////////////////////////////////////////////////////////////////////////////////
965   /// \ingroup SetSI64
966   /// \~english @par Brief
967   ///     This function is used to set SI_64 type value.
968   /// \~english @param[in] f_si64Value
969   ///        SI_64 - new SI_64 value
970   /// \~english @retval EFrameworkunifiedStatus
971   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
972   /// \~english @retval eFrameworkunifiedStatusInvldID - set array element of different type
973   /// \~english @par Prerequisite
974   ///      - None
975   /// \~english @par Change of internal state
976   ///      - None
977   /// \~english @par Conditions of processing failure
978   ///      - none
979   /// \~english @par Classification
980   ///       Public
981   /// \~english @par Type
982   ///       Sync Only
983   /// \~english @par Detail
984   ///       Set SI_64 type value.
985   /// \~english @see none
986   ////////////////////////////////////////////////////////////////////////////////////////////////
987   EFrameworkunifiedStatus SetSI64(SI_64 f_si64Value) {
988     return SetValue<SI_64>(ConvertEndian_SI64(f_si64Value), 0x9);
989   }
990
991
992   //////////////////////////////////////////////////////////////////////////////////////////////
993   /// \ingroup SetBuffer
994   /// \~english @par Brief
995   ///     This function is used to set buffer and size.
996   /// \~english @param[in] f_pui8Buffer
997   ///        UI_8* - buffer address
998   /// \~english @param[in] f_ui16BufLength
999   ///        UI_16 - buffer size
1000   /// \~english @retval EFrameworkunifiedStatus
1001   /// \~english @retval eFrameworkunifiedStatusOK - data retrieved
1002   /// \~english @retval eFrameworkunifiedStatusInvldID - data member(m_ui8LastArrDataType) is invalid value
1003   /// \~english @par Prerequisite
1004   ///      - None
1005   /// \~english @par Change of internal state
1006   ///      - None
1007   /// \~english @par Conditions of processing failure
1008   ///      - none
1009   /// \~english @par Classification
1010   ///       Public
1011   /// \~english @par Type
1012   ///       Sync Only
1013   /// \~english @par Detail
1014   ///       Set buffer and size.
1015   /// \~english @see none 
1016   ////////////////////////////////////////////////////////////////////////////////////////////////
1017   EFrameworkunifiedStatus SetBuffer(UI_8 *f_pui8Buffer, UI_16 f_ui16BufLength) {
1018     EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1019     // TODO: add error check for resize operation
1020     if (f_pui8Buffer == NULL) {
1021       FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __func__, "f_pui8Buffer is NULL");
1022       return eFrameworkunifiedStatusNullPointer;
1023     }
1024     m_ui16TotalLength = static_cast<UI_16>(m_ui16TotalLength + f_ui16BufLength + SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER);
1025     m_vui8Data.resize(m_ui16TotalLength);
1026     *static_cast<UI_8 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = 0xB;
1027     m_ui16CurOffset++;
1028     *static_cast<UI_16 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = ConvertEndian_UI16(f_ui16BufLength);
1029     m_ui16CurOffset = static_cast<UI_16>(m_ui16CurOffset + sizeof(UI_16));
1030     std::memcpy(&m_vui8Data[m_ui16CurOffset], f_pui8Buffer, f_ui16BufLength);
1031     m_ui16CurOffset = static_cast<UI_16>(m_ui16CurOffset + f_ui16BufLength);
1032
1033     if (!m_bArrayTypeSet) {
1034 //      *static_cast<UI_16*>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount])) =
1035 //          (*static_cast<UI_16*>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount]))) + 1;
1036       UpdateParamCount();
1037     } else {
1038       // setting array element
1039       m_ui16CurrentArrCount--;
1040
1041       if ((m_ui8LastArrDataType != 0) && (m_ui8LastArrDataType != 0xB)) {
1042         l_eStatus = eFrameworkunifiedStatusInvldID;
1043       } else {
1044         m_ui8LastArrDataType = 0xB;
1045         if (0 == m_ui16CurrentArrCount) {
1046           m_ui8LastArrDataType = 0;  // default data type eNull
1047           m_bArrayTypeSet = FALSE;
1048         }
1049       }
1050     }
1051     return l_eStatus;
1052   }
1053
1054   //////////////////////////////////////////////////////////////////////////////////////////////
1055   /// \ingroup SetArrayCount
1056   /// \~english @par Brief
1057   ///     This function is used to set ArrayCount.
1058   /// \~english @param f_ui16ArrayCount
1059   ///     UI_16 - ArrayCount
1060   /// \~english @retval none
1061   /// \~english @par Prerequisite
1062   ///      - None
1063   /// \~english @par Change of internal state
1064   ///      - None
1065   /// \~english @par Conditions of processing failure
1066   ///      - none
1067   /// \~english @par Classification
1068   ///       Public
1069   /// \~english @par Type
1070   ///       Sync Only
1071   /// \~english @par Detail
1072   ///       Set ArrayCount.
1073   /// \~english @see none
1074   ////////////////////////////////////////////////////////////////////////////////////////////////
1075   EFrameworkunifiedStatus SetArrayCount(UI_16 f_ui16ArrayCount) {
1076     EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1077     // TODO: add error check for resize operation
1078     m_ui16TotalLength = static_cast<UI_16>(m_ui16TotalLength + SIZE_OF_PASSTHRU_PARAM_BUFFERTYPE_HEADER);
1079     m_vui8Data.resize(m_ui16TotalLength);
1080     *static_cast<UI_8 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = 0xC;
1081     m_ui16CurOffset++;
1082     *static_cast<UI_16 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = ConvertEndian_UI16(f_ui16ArrayCount);
1083     m_ui16CurOffset = static_cast<UI_16>(m_ui16CurOffset + sizeof(UI_16));
1084
1085     m_ui16CurrentArrCount = f_ui16ArrayCount;
1086     m_bArrayTypeSet = TRUE;
1087 //    *static_cast<UI_16*>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount])) =
1088 //        (*static_cast<UI_16*>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount]))) + 1;
1089     UpdateParamCount();
1090
1091     // TODO: add error handling, if any other element is added before the array count reaches to f_ui16ArrayCount
1092     return l_eStatus;
1093   }
1094
1095  private:
1096   CPassThruOutDataHandler() {
1097
1098   }
1099
1100   // SetValue
1101   // \return - eFrameworkunifiedStatusInvldID - If setting array element of different type
1102   template <class DataType>
1103   EFrameworkunifiedStatus SetValue(DataType l_dtValue, UI_8  f_ui8DataType) {
1104     EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1105     // TODO: add error check for resize operation
1106
1107     m_ui16TotalLength = static_cast<UI_16>(m_ui16TotalLength + SIZE_OF_PASSTHRU_DATATYPE_IDENTIFIER + sizeof(DataType));
1108     m_vui8Data.resize(m_ui16TotalLength);
1109     *static_cast<UI_8 *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = f_ui8DataType;
1110     m_ui16CurOffset++;
1111     *static_cast<DataType *>(static_cast<PVOID>(&m_vui8Data[m_ui16CurOffset])) = l_dtValue;
1112     m_ui16CurOffset = static_cast<UI_16>(m_ui16CurOffset + sizeof(DataType));
1113
1114     if (!m_bArrayTypeSet) {
1115 //      *static_cast<UI_16*>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount])) =
1116 //          (*static_cast<UI_16*>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount]))) + 1;
1117       UpdateParamCount();
1118     } else {
1119       // setting array element
1120       m_ui16CurrentArrCount--;
1121
1122       if ((m_ui8LastArrDataType != 0) && (m_ui8LastArrDataType != f_ui8DataType)) {
1123         l_eStatus = eFrameworkunifiedStatusInvldID;
1124       } else {
1125         m_ui8LastArrDataType = f_ui8DataType;
1126         if (0 == m_ui16CurrentArrCount) {
1127           m_ui8LastArrDataType = 0;  // default data type eNull
1128           m_bArrayTypeSet = FALSE;
1129         }
1130       }
1131     }
1132     return l_eStatus;
1133   }
1134
1135   VOID UpdateParamCount() {
1136     UI_16 l_ui16ParamCount = static_cast<UI_16>(ConvertEndian_UI16(*static_cast<UI_16 *>(static_cast<PVOID>
1137                                                                                          (&m_vui8Data[m_ui16ParamCount]))) + 1);
1138     l_ui16ParamCount = ConvertEndian_UI16(l_ui16ParamCount);
1139     *static_cast<UI_16 *>(static_cast<PVOID>(&m_vui8Data[m_ui16ParamCount])) = l_ui16ParamCount;
1140   }
1141
1142   // UI_8* m_ui8Data;
1143   std::vector<UI_8> m_vui8Data;
1144   UI_16 m_ui16TotalLength;  // total data length
1145   UI_16 m_ui16ParamCount;
1146   UI_16 m_ui16CurOffset;
1147   UI_8  m_ui8ClientId;
1148
1149   // required for array data type
1150   UI_16 m_ui16CurrentArrCount;
1151   BOOL m_bArrayTypeSet;
1152   UI_8 m_ui8LastArrDataType;
1153 };
1154
1155 #endif  // _NS_RCS_DATA_HANDLER_H__  // NOLINT  (build/header_guard)
1156 /** @}*/
1157 /** @}*/
1158 /** @}*/
1159 /** @}*/