SheafSystem  0.0.0.0
name_multimap.h
Go to the documentation of this file.
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
20 
21 #ifndef NAME_MULTIMAP_H
22 #define NAME_MULTIMAP_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef ANY_H
29 #include "SheafSystem/any.h"
30 #endif
31 
32 #ifndef BLOCK_H
33 #include "SheafSystem/block.h"
34 #endif
35 
36 #ifndef STD_IOSTREAM_H
37 #include "SheafSystem/std_iostream.h"
38 #endif
39 
40 #ifndef STD_LIST_H
41 #include "SheafSystem/std_list.h"
42 #endif
43 
44 #ifndef STD_MAP_H
45 #include "SheafSystem/std_map.h"
46 #endif
47 
48 #ifndef STD_STRING_H
49 #include "SheafSystem/std_string.h"
50 #endif
51 
52 namespace sheaf
53 {
54 
55 class poset;
56 class name_multimap;
57 class scoped_index;
58 
63 class SHEAF_DLL_SPEC name_multimap : public any
64 {
65  friend SHEAF_DLL_SPEC size_t deep_size(const name_multimap& xp, bool xinclude_shallow);
66 
67  // ===========================================================
69  // ===========================================================
71 
72 public:
73 
78 
82  typedef std::pair<index_type, std::string> entry_type;
83 
87  typedef std::list<std::string> name_list_type;
88 
92  typedef name_list_type::iterator name_iterator;
93 
97  typedef name_list_type::const_iterator const_name_iterator;
98 
102  typedef std::map<index_type, name_list_type >::iterator iterator;
103 
107  typedef std::map<index_type, name_list_type >::const_iterator const_iterator;
108 
112  name_multimap();
113 
117  name_multimap(const name_multimap& xother);
118 
122  name_multimap(const std::string xnames[], size_type xnames_ub);
123 
127  virtual ~name_multimap();
128 
132  std::string name(index_type xindex) const;
133 
137  std::string name(index_type xindex, int xi) const;
138 
142  const name_list_type& all_names(index_type xindex) const;
143 
147  void all_names(index_type xindex, block<std::string>& xresult) const;
148 
152  index_type index(const std::string& xname) const;
153 
158  void put_entry(const entry_type& xentry, bool xunique);
159 
164  void put_entry(index_type xindex, const std::string& xname, bool xunique);
165 
169  bool contains_name(const std::string& xname) const;
170 
174  bool contains_index(index_type xindex) const;
175 
179  bool contains_entry(const entry_type& xentry) const;
180 
184  bool contains_entry(index_type xindex, const std::string& xname) const;
185 
189  void delete_index(index_type xindex);
190 
194  void delete_name(const std::string& xname);
195 
199  void clear();
200 
204  bool empty() const;
205 
209  const_iterator begin() const;
210 
214  const_iterator end() const;
215 
219  int ct() const;
220 
225  void print() const;
226 
231  void print(std::ostream& xos, const name_multimap& xm) const;
232 
236  size_type name_ct(const index_type& xindex) const;
237 
238 private:
239 
243  typedef std::map<std::string, index_type> name_to_index_map_type;
244 
248  name_to_index_map_type _name_to_index_map;
249 
253  typedef std::map< index_type, std::list<std::string> > index_to_name_map_type;
254 
258  index_to_name_map_type _index_to_name_map;
259 
261 
262 
263  // ===========================================================
265  // ===========================================================
267 
268 public:
269 
275  virtual name_multimap* clone() const;
276 
280  virtual bool invariant() const;
281 
285  virtual bool is_ancestor_of(const any* other) const;
286 
290  bool operator==(const name_multimap& xother);
291 
295  name_multimap& operator=(const name_multimap& xother);
296 
297 protected:
298 
299 private:
300 
302 };
303 
304 
305 // ===========================================================
306 // NON-MEMBER FUNCTIONS
307 // ===========================================================
308 
312 SHEAF_DLL_SPEC
313 std::ostream&
314 operator<<(std::ostream& xos, const name_multimap& xm);
315 
320 SHEAF_DLL_SPEC
321 size_t
322 deep_size(const name_multimap& xp, bool xinclude_shallow);
323 
324 } // namespace sheaf
325 
326 #endif // ifndef NAME_MULTIMAP_H
327 
328 
329 
330 
331 
332 
name_list_type::iterator name_iterator
The iterator type for names.
Definition: name_multimap.h:92
pod_index_type index_type
The type of the index in the map.
Definition: name_multimap.h:77
name_list_type::const_iterator const_name_iterator
The const iterator type for names.
Definition: name_multimap.h:97
std::list< std::string > name_list_type
The type of name list for this map.
Definition: name_multimap.h:87
std::map< index_type, name_list_type >::iterator iterator
The iterator type for this map.
A partial multi-valued relation with total injective inverse between names and indices of type index_...
Definition: name_multimap.h:63
Abstract base class with useful features for all objects.
Definition: any.h:39
std::pair< index_type, std::string > entry_type
The type of an entry in the map.
Definition: name_multimap.h:82
SHEAF_DLL_SPEC size_t deep_size(const dof_descriptor_array &xp, bool xinclude_shallow=true)
The deep size of the referenced object of type dof_descriptor_array.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
bool operator==(const singly_linked_list< T, Alloc > &lhs, const singly_linked_list< T, Alloc > &rhs)
Checks if the contents of lhs and rhs are equal, that is, whether lhs.size() == rhs.size() and each element in lhs compares equal with the element in rhs at the same position.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
Namespace for the sheaves component of the sheaf system.
std::map< index_type, name_list_type >::const_iterator const_iterator
The const iterator type for this map.