1 | /* |
2 | * Pack_stat.hpp |
3 | * |
4 | * Created on: Jul 17, 2015 |
5 | * Author: i-bird |
6 | */ |
7 | |
8 | #ifndef SRC_PACK_STAT_HPP_ |
9 | #define SRC_PACK_STAT_HPP_ |
10 | |
11 | /*! \brief Unpacking status object |
12 | * |
13 | * |
14 | */ |
15 | class Unpack_stat |
16 | { |
17 | //! offset |
18 | size_t cnt; |
19 | |
20 | public: |
21 | |
22 | inline Unpack_stat() |
23 | :cnt(0) |
24 | {} |
25 | |
26 | /*! \brief Increment the offset pointer by off |
27 | * |
28 | * \param off |
29 | * |
30 | */ |
31 | inline void addOffset(size_t off) |
32 | { |
33 | cnt += off; |
34 | } |
35 | |
36 | /*! \brief Return the actual counter |
37 | * |
38 | * \return the counter |
39 | * |
40 | */ |
41 | inline size_t getOffset() |
42 | { |
43 | return cnt; |
44 | } |
45 | |
46 | /*! \brief set the actual counter |
47 | * |
48 | * |
49 | */ |
50 | inline void setOffset(size_t c) |
51 | { |
52 | cnt = c; |
53 | } |
54 | }; |
55 | |
56 | /*! \brief Packing status object |
57 | * |
58 | * |
59 | */ |
60 | class Pack_stat |
61 | { |
62 | //! marker used to remember some position |
63 | size_t p_mark; |
64 | |
65 | //! packing offset |
66 | size_t un_ele; |
67 | |
68 | public: |
69 | |
70 | |
71 | inline Pack_stat() |
72 | :p_mark(0),un_ele(0) |
73 | {} |
74 | |
75 | /*! \brief Increment the request pointer |
76 | * |
77 | * |
78 | */ |
79 | inline void incReq() |
80 | { |
81 | un_ele++; |
82 | } |
83 | |
84 | /*! \brief return the actual request for packing |
85 | * |
86 | * \return the actual request for packing |
87 | * |
88 | */ |
89 | inline size_t reqPack() |
90 | { |
91 | return un_ele; |
92 | } |
93 | |
94 | /*! \brief Mark |
95 | * |
96 | * |
97 | * |
98 | */ |
99 | inline void mark() |
100 | { |
101 | p_mark = un_ele; |
102 | } |
103 | |
104 | /*! \brief Return the mark |
105 | * |
106 | * \return the mark |
107 | * |
108 | */ |
109 | inline size_t getMark() |
110 | { |
111 | return p_mark; |
112 | } |
113 | }; |
114 | |
115 | #endif /* SRC_PACK_STAT_HPP_ */ |
116 | |