Bayeux  3.4.1
Core Foundation library for SuperNEMO
address_set.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-02-08
4  * Last modified: 2010-02-08
5  *
6  * License:
7  *
8  * Description:
9  * Set of addresses from a geometry ID
10  *
11  */
12 
13 #ifndef GEOMTOOLS_ADDRESS_SET_H
14 #define GEOMTOOLS_ADDRESS_SET_H 1
15 
16 // Standard library:
17 #include <iostream>
18 #include <set>
19 
20 // Third party:
21 // - Boost:
22 #include <boost/cstdint.hpp>
23 
24 namespace geomtools {
25 
37  {
38 
39  public:
40 
42  enum mode_type
43  {
44  MODE_INVALID = -1,
45  MODE_NONE = 0,
46  MODE_ALL = 1,
47  MODE_RANGE = 2,
48  MODE_LIST = 3,
50  };
51 
52  private:
53 
55  void _reset_range_();
56 
58  void _reset_list_();
59 
60  public:
61 
63  bool is_valid() const;
64 
66  void invalidate();
67 
69  bool is_reverse() const;
70 
72  void set_reverse(bool = true);
73 
75  bool is_mode_none() const;
76 
78  bool is_mode_all() const;
79 
81  bool is_mode_range() const;
82 
84  bool is_mode_list() const;
85 
87  void set_mode_none();
88 
90  void set_mode_all();
91 
93  void set_mode_range();
94 
96  void set_range(uint32_t a_min, uint32_t a_max);
97 
99  void set_mode_range(uint32_t a_min, uint32_t a_max);
100 
102  void set_mode_list();
103 
105  void add_to_list(uint32_t a_value);
106 
108  bool match(uint32_t a_value) const;
109 
111  void reset();
112 
114  address_set();
115 
117  friend std::ostream & operator<<(std::ostream & a_out, const address_set & a_addset);
118 
120  friend std::istream & operator>>(std::istream & a_in, address_set & a_addset);
121 
122  private:
123 
124  mode_type _mode_;
125  uint32_t _range_min_;
126  uint32_t _range_max_;
127  std::set<uint32_t> _addresses_;
128  bool _reverse_;
129 
130  };
131 
132 } // end of namespace geomtools
133 
134 #endif // GEOMTOOLS_ADDRESS_SET_H
135 
136 /*
137 ** Local Variables: --
138 ** mode: c++ --
139 ** c-file-style: "gnu" --
140 ** tab-width: 2 --
141 ** End: --
142 */
A set of indexes representing subaddresses in a geometry ID (see geomtools::geom_id)
Definition: address_set.h:36
bool is_mode_list() const
Check if mode 'list' is used.
bool is_valid() const
Check the validity of the set.
void set_mode_all()
Set the mode 'all'.
friend std::ostream & operator<<(std::ostream &a_out, const address_set &a_addset)
Print operator.
mode_type
Mode to test the belonging of an address to the set.
Definition: address_set.h:42
Invalid mode.
Definition: address_set.h:45
void set_range(uint32_t a_min, uint32_t a_max)
Set the range ('range' mode only)
Definition: address_set.h:44
A candidate value is valid only if it lies in some specific range of values.
Definition: address_set.h:47
A candidate value is valid only if it belongs to a specific list of values.
Definition: address_set.h:48
bool match(uint32_t a_value) const
Check if a value matches the collection of addresses.
bool is_mode_none() const
Check if the mode is defined.
void reset()
Terminate.
address_set()
Constructor.
bool is_mode_range() const
Check if mode 'range' is used.
void set_mode_none()
Set the mode 'mode'.
bool is_reverse() const
Check the reverse flag.
void set_reverse(bool=true)
Set the reverse flag.
void invalidate()
Invalidate the set.
Definition: address_set.h:49
void set_mode_list()
Set the mode 'list'.
void set_mode_range()
Set the mode 'range'.
void add_to_list(uint32_t a_value)
Add an address to the list ('list' mode only)
bool is_mode_all() const
Check if the mode 'all' is activated.
All candidate values are valid.
Definition: address_set.h:46
friend std::istream & operator>>(std::istream &a_in, address_set &a_addset)
Reader operator.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39