Proto  3.2
Proto_CInterval.H
Go to the documentation of this file.
1 #pragma once
2 #ifndef _PROTO_INTERVAL_
3 #define _PROTO_INTERVAL_
4 
5 namespace Proto {
6 
7  /// Component-Space Interval
8  /**
9  Defines a subspace of tensor components.
10  Used chiefly for copying and and linearized buffer IO.
11  Usually the user will not need to explicitly create a CInterval.
12  See the documentation for BoxData::copyTo for an example.
13  */
14  class CInterval
15  {
16  public:
17  /// Bounds Constructor
18  /**
19  Builds the interval:
20  {{a_c0, a_c1},{a_d0, a_d1},{a_e0, a_e1}}
21  */
22  inline CInterval(
23  unsigned int a_c0, unsigned int a_c1,
24  unsigned int a_d0 = 0, unsigned int a_d1 = 0,
25  unsigned int a_e0 = 0, unsigned int a_e1 = 0);
26 
27  /// List Constructor
28  /**
29  Build a CInterval using initializer list syntax.
30 
31  Example:
32  @code
33  CInterval I0{{c0, c1},{d0, d1},{e0, e1}};
34  // OR
35  CInterval I1({{c0, c1},{d0, d1},{e0, e1}});
36  // Or, for a single component index:
37  CInterval I2{c0, c1};
38  // OR
39  CInterval I3({c0, c1});
40  @endcode
41  */
42  inline CInterval(std::initializer_list<std::initializer_list<unsigned int>> a_lst);
43 
44  /// Equality
45  /**
46  */
47  inline bool operator==(CInterval& a_rhs);
48 
49  /// Lower Bound
50  /**
51  Retrieve the lower bound along the given component axis
52 
53  \param a_comp A component axis in [0,3)
54  */
55  inline unsigned int low(unsigned int a_comp) const;
56 
57  /// Upper Bound
58  /**
59  Retrieve the upper bound component
60  for component axis <code> a_comp </code>
61 
62  \param a_comp A component axis in [0,3)
63  */
64  inline unsigned int high(unsigned int a_comp) const;
65 
66  /// Contains Query
67  /**
68  Query if <code>*this</code> contains <code>index</code>
69  of component <code>comp</code>
70 
71  \param a_index An index
72  \param a_comp A component axis in [0,3)
73  */
74  inline bool contains(unsigned int a_index, unsigned int a_comp) const;
75 
76  /// Size Query
77  /**
78  Returns the number of components in <code> *this </code>
79  along the component axis <code> a_comp </code>
80 
81  \param a_comp A component axis in [0,3)
82  */
83  inline unsigned int size(unsigned int a_comp) const;
84 
85  /// Print
86  inline void print() const;
87 
88  private:
89  unsigned int m_comps[3][2]; ///< bounds of the interval
90  };
91 
92  /// CInterval IOStream Operator
93  inline std::ostream& operator<<(std::ostream& a_os, const CInterval& a_int);
94 
95 } // end namespace Proto
96 #endif // end include guard
unsigned int size(unsigned int a_comp) const
Size Query.
void print() const
Print.
CInterval(unsigned int a_c0, unsigned int a_c1, unsigned int a_d0=0, unsigned int a_d1=0, unsigned int a_e0=0, unsigned int a_e1=0)
Bounds Constructor.
bool contains(unsigned int a_index, unsigned int a_comp) const
Contains Query.
Component-Space Interval.
Definition: Proto_CInterval.H:14
bool operator==(CInterval &a_rhs)
Equality.
Definition: Proto_Array.H:17
std::ostream & operator<<(std::ostream &stream, const Array< T, N > &arr)
Ostream operator.
unsigned int high(unsigned int a_comp) const
Upper Bound.
unsigned int m_comps[3][2]
bounds of the interval
Definition: Proto_CInterval.H:89
unsigned int low(unsigned int a_comp) const
Lower Bound.