Bitstream Interpretation Library (BIL)  0.1
PIP.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 #ifndef BIL_PIP_HPP
8 #define BIL_PIP_HPP
9 
10 #include <vector>
11 #include <serialization/PIPBS.hpp>
13 
14 
15 namespace bil {
16 
29  class PIP {
30  public:
31 
32  /**********************************************************************/
33  /* CONSTRUCTION / DESTRUCTION */
34  /**********************************************************************/
35 
39  PIP();
40 
41 
42  /**********************************************************************/
43  /* START WIRE INDEX */
44  /**********************************************************************/
45 
50  void startWireIndex(unsigned short index);
51 
56  unsigned short startWireIndex() const;
57 
58 
59  /**********************************************************************/
60  /* END WIRE INDEX */
61  /**********************************************************************/
62 
67  void endWireIndex(unsigned short index);
68 
73  unsigned short endWireIndex() const;
74 
75 
76  /**********************************************************************/
77  /* DIRECTION */
78  /**********************************************************************/
79 
85 
91 
92 
93  /**********************************************************************/
94  /* MODIFICATORS */
95  /**********************************************************************/
96 
100  void clear();
101 
102 
103  private:
104 
105  friend bool operator== (const PIP& pip1, const PIP& pip2);
106  friend bool operator< (const PIP& pip1, const PIP& pip2);
107 
108  friend void writeBinary(const PIP& data, std::ostream& outputStream);
109  friend void readBinary(PIP& data, std::istream& inputStream);
110 
111  unsigned short m_startWireIndex;
112  unsigned short m_endWireIndex;
113  PIPDirection::direction_t m_direction;
114 
115  };
116 
117 
119  inline bool operator== (const PIP& pip1, const PIP& pip2)
120  {
121  if (pip1.m_startWireIndex != pip2.m_startWireIndex) return false;
122  if (pip1.m_endWireIndex != pip2.m_endWireIndex) return false;
123  return (pip1.m_direction == pip2.m_direction);
124  }
125 
127  inline bool operator!= (const PIP& pip1, const PIP& pip2)
128  {
129  return !(operator== (pip1, pip2));
130  }
131 
132 
134  inline bool operator< (const PIP& pip1, const PIP& pip2)
135  {
136  if (pip1.m_startWireIndex != pip2.m_startWireIndex)
137  return (pip1.m_startWireIndex < pip2.m_startWireIndex);
138  if (pip1.m_endWireIndex != pip2.m_endWireIndex)
139  return (pip1.m_endWireIndex < pip2.m_endWireIndex);
140  return (pip1.m_direction < pip2.m_direction);
141  }
142 
144  inline bool operator> (const PIP& pip1, const PIP& pip2)
145  {
146  return (operator< (pip2, pip1));
147  }
148 
150  inline bool operator<= (const PIP& pip1, const PIP& pip2)
151  {
152  return !(operator> (pip1, pip2));
153  }
154 
156  inline bool operator>= (const PIP& pip1, const PIP& pip2)
157  {
158  return !(operator< (pip1, pip2));
159  }
160 
161 
163  typedef std::vector<PIP> PIPs;
164 
165 }
166 
167 #endif