Bitstream Interpretation Library (BIL)  0.1
V5FrameAddress.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 #ifndef BIL_V5FRAMEADDRESS_HPP
8 #define BIL_V5FRAMEADDRESS_HPP
9 
10 #include <boost/cstdint.hpp>
14 
15 
16 namespace bil {
17 
29  public:
30 
31  /**********************************************************************/
32  /* CONSTRUCTION / DESTRUCTION */
33  /**********************************************************************/
34 
39 
44  explicit V5FrameAddress(const V5AddressLayout* layout);
45 
46 
47  /**********************************************************************/
48  /* CONFIGURATION WITH ADDRESS LAYOUT */
49  /**********************************************************************/
50 
61  void addressLayout(const V5AddressLayout* layout);
62 
67  const V5AddressLayout* addressLayout() const;
68 
69 
70  /**********************************************************************/
71  /* BLOCK */
72  /**********************************************************************/
73 
75  static const unsigned BLOCK_MAX = 7;
76 
83 
88  V5CfgBlock::block_t block() const;
89 
90 
91  /**********************************************************************/
92  /* LOWER/UPPER HALF */
93  /**********************************************************************/
94 
99  void lowerHalf(bool lower);
100 
105  bool lowerHalf() const;
106 
107 
108  /**********************************************************************/
109  /* ROW INDEX */
110  /**********************************************************************/
111 
113  static const unsigned ROWINDEX_MAX = V5AddressLayout::ROWCOUNT_MAX - 1;
114 
120  void rowIndex(unsigned char ri);
121 
126  unsigned char rowIndex() const;
127 
128 
129  /**********************************************************************/
130  /* COLUMN INDEX */
131  /**********************************************************************/
132 
135 
141  void columnIndex(unsigned char ci);
142 
147  unsigned char columnIndex() const;
148 
149 
150  /**********************************************************************/
151  /* FRAME INDEX */
152  /**********************************************************************/
153 
155  static const unsigned FRAMEINDEX_MAX = 127;
156 
162  void frameIndex(unsigned char fi);
163 
168  unsigned char frameIndex() const;
169 
170 
171  /**********************************************************************/
172  /* ADDRESS ITERATION */
173  /**********************************************************************/
174 
180  void first();
181 
188  void last();
189 
197  bool next();
198 
199 
200  /**********************************************************************/
201  /* VALIDITY */
202  /**********************************************************************/
203 
211  bool isValid() const;
212 
213 
214  /**********************************************************************/
215  /* ADDRESS TARGET COLUMN TYPE */
216  /**********************************************************************/
217 
224 
225 
226  /**********************************************************************/
227  /* RAW ADDRESS */
228  /**********************************************************************/
229 
234  void rawAddress(boost::uint32_t ra);
235 
240  boost::uint32_t rawAddress() const;
241 
242 
243  private:
244 
245  friend bool operator== (const V5FrameAddress& fa1, const V5FrameAddress& fa2);
246  friend bool operator< (const V5FrameAddress& fa1, const V5FrameAddress& fa2);
247 
248 
249  const V5AddressLayout* m_addressLayout;
250 
251  V5CfgBlock::block_t m_block;
252  bool m_lowerHalf;
253  unsigned char m_rowIndex;
254  unsigned char m_columnIndex;
255  unsigned char m_frameIndex;
256 
257  };
258 
259 
261  inline bool operator== (const V5FrameAddress& fa1, const V5FrameAddress& fa2)
262  {
263  if (fa1.m_block != fa2.m_block) return false;
264  if (fa1.m_lowerHalf != fa2.m_lowerHalf) return false;
265  if (fa1.m_rowIndex != fa2.m_rowIndex) return false;
266  if (fa1.m_columnIndex != fa2.m_columnIndex) return false;
267  return fa1.m_frameIndex == fa2.m_frameIndex;
268  }
269 
271  inline bool operator!= (const V5FrameAddress& fa1, const V5FrameAddress& fa2)
272  {
273  return !(operator== (fa1, fa2));
274  }
275 
276 
278  inline bool operator< (const V5FrameAddress& fa1, const V5FrameAddress& fa2)
279  {
280  if (fa1.m_block != fa2.m_block) return fa1.m_block < fa2.m_block;
281  if (fa1.m_lowerHalf != fa2.m_lowerHalf) return fa2.m_lowerHalf;
282  if (fa1.m_rowIndex != fa2.m_rowIndex) return fa1.m_rowIndex < fa2.m_rowIndex;
283  if (fa1.m_columnIndex != fa2.m_columnIndex) return fa1.m_columnIndex < fa2.m_columnIndex;
284  return fa1.m_frameIndex < fa2.m_frameIndex;
285  }
286 
288  inline bool operator> (const V5FrameAddress& fa1, const V5FrameAddress& fa2)
289  {
290  return (operator< (fa2, fa1));
291  }
292 
294  inline bool operator<= (const V5FrameAddress& fa1, const V5FrameAddress& fa2)
295  {
296  return !(operator> (fa1, fa2));
297  }
298 
300  inline bool operator>= (const V5FrameAddress& fa1, const V5FrameAddress& fa2)
301  {
302  return !(operator< (fa1, fa2));
303  }
304 
305 }
306 
307 #endif