PolyBoRi
VariableBlock.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
14 //*****************************************************************************
15 
16 #ifndef polybori_factories_VariableBlock_h_
17 #define polybori_factories_VariableBlock_h_
18 
19 // include basic definitions
20 #include <polybori/pbori_defs.h>
22 
24 
26 
27 };
28 
36  protected VariableFactory{
37 
39  typedef VariableBlock self;
40 
41 public:
44 
47 
49  VariableBlock(idx_type size, idx_type start_index, idx_type offset,
50  bool reverse, const ring_type& ring):
51  base(ring),
52  m_start_index(start_index),
53  m_last (start_index + size - 1), m_offset(offset), m_reverse(reverse) { }
54 
56  VariableBlock(const self& rhs):
57  base(rhs),
58  m_start_index(rhs.m_start_index),
59  m_last(rhs.m_last), m_offset(rhs.m_offset), m_reverse(rhs.m_reverse) { }
60 
63 
66  if PBORI_UNLIKELY( (i > m_last) || (i < m_start_index) ){
67  throw VariableIndexException();
68  }
69  return
70  base::operator()(m_offset + (m_reverse? m_last - i: i - m_start_index));
71  }
72 
73 protected:
77  const bool m_reverse;
78 };
79 
81 
82 #endif /* polybori_factories_VariableBlock_h_*/