SheafSystem  0.0.0.0
namespace_relative_subposet_index.h
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 
18 // Interface for class namespace_relative_subposet_index
19 
20 #ifndef NAMESPACE_RELATIVE_SUBPOSET_INDEX_H
21 #define NAMESPACE_RELATIVE_SUBPOSET_INDEX_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef ASSERT_CONTRACT_H
28 #include "SheafSystem/assert_contract.h"
29 #endif
30 
31 #ifndef SCOPED_INDEX
32 #include "SheafSystem/scoped_index.h"
33 #endif
34 
35 namespace sheaf
36 {
37 
41 struct SHEAF_DLL_SPEC namespace_relative_subposet_index
42 {
47 
52  {
53  // Scoped_index data members are invalid by default.
54 
55  // Postconditions:
56 
57  ensure(!is_valid());
58 
59  // Exit:
60 
61  return;
62  };
63 
64 
68  inline explicit namespace_relative_subposet_index(const index_space_handle& xid_space, const pod_type& xpod)
69  : poset_id(xid_space, xpod.poset_id),
70  subposet_id(xid_space, xpod.subposet_id)
71  {
72  // Postconditions:
73 
74  ensure((pod() == xpod) || !is_valid());
75 
76  // Exit:
77 
78  return;
79  };
80 
85 
90 
91 
92 
96  inline bool operator==(const namespace_relative_subposet_index& xother) const
97  {
98  bool result;
99 
100  // Preconditions:
101 
102  // Body:
103 
104  result = ((poset_id == xother.poset_id) && (subposet_id == xother.subposet_id));
105 
106  // Postconditions:
107 
108  ensure(result == ((poset_id == xother.poset_id) && (subposet_id == xother.subposet_id)));
109 
110  // Exit:
111 
112  return result;
113  };
114 
118  inline bool is_valid() const
119  {
120  bool result;
121 
122  // Preconditions:
123 
124  // Body:
125 
126  result = (poset_id.is_valid() && subposet_id.is_valid());
127 
128  // Postconditions:
129 
130  // Exit:
131 
132  return result;
133  };
134 
138  void invalidate()
139  {
140  // Preconditions:
141 
142  // Body:
143 
144  poset_id.invalidate();
145  subposet_id.invalidate();
146 
147  // Postconditions:
148 
149  ensure(!is_valid());
150 
151  // Exit:
152 
153  return;
154  };
155 
160  {
161  // Preconditions:
162 
163  // Body:
164 
165  // Default constructor makes invalid.
166 
167  static const namespace_relative_subposet_index result;
168 
169  // Postconditions:
170 
171  ensure(!result.is_valid());
172 
173  // Exit:
174 
175  return result;
176  };
177 
181  inline pod_type pod() const
182  {
183  pod_type result;
184  result.poset_id = poset_id.pod();
185  result.subposet_id = subposet_id.pod();
186 
187  return result;
188  };
189 
193  inline void put_pod(pod_type xpod)
194  {
195 
196  // Preconditions:
197 
198  // Body:
199 
200  poset_id.put_pod(xpod.poset_id);
201  subposet_id.put_pod(xpod.subposet_id);
202 
203  // Postconditions:
204 
205  ensure(pod() == xpod || !is_valid());
206 
207  // Exit:
208 
209  return;
210  };
211 } ;
212 
213 // ===========================================================
214 // NON-MEMBER FUNCTIONS
215 // ===========================================================
216 
220 SHEAF_DLL_SPEC
221 std::ostream&
222 operator<<(std::ostream& xos, const namespace_relative_subposet_index& xindex);
223 
224 
228 SHEAF_DLL_SPEC
229 std::istream&
230 operator>>(std::istream& xis, namespace_relative_subposet_index& xindex);
231 
232 } // namespace sheaf
233 
234 #endif // ifndef NAMESPACE_RELATIVE_SUBPOSET_INDEX_H
235 
236 
237 
238 
239 
240 
bool operator==(const namespace_relative_subposet_index &xother) const
Equality operator.
scoped_index poset_id
The index of the poset relative to the namespace.
bool is_valid() const
True if this is a valid id.
Definition: scoped_index.h:832
pod_type pod() const
The "plain old data" storage of this.
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
Definition: scoped_index.h:672
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
void invalidate()
Make this id invalid.
Definition: scoped_index.h:852
void put_pod(pod_type xpod)
Sets pod() to xpod.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
scoped_index subposet_id
The index of the subposet relative to the poset.
namespace_relative_subposet_index(const index_space_handle &xid_space, const pod_type &xpod)
Constructor from pod_type.
POD type associated with namespace_relative_subposet_index.
Definition: pod_types.h:111
namespace_relative_subposet_index_pod_type pod_type
The POD (plain old data) type associated this.
Index for identifying a subposet relative to a given name space.
SHEAF_DLL_SPEC std::istream & operator>>(std::istream &is, dof_tuple_type &xdt)
Extract dof_tuple_type xdt from istream& is.
bool is_valid() const
True if this is a valid id.
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.
static const namespace_relative_subposet_index & INVALID()
The invalid id.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
Definition: pod_types.cc:37
void put_pod(pod_type xpod)
Sets pod() to xpod.
Definition: scoped_index.h:680