SheafSystem  0.0.0.0
namespace_relative_member_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_member_index
19 
20 #ifndef NAMESPACE_RELATIVE_MEMBER_INDEX_H
21 #define NAMESPACE_RELATIVE_MEMBER_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_H
32 #include "SheafSystem/scoped_index.h"
33 #endif
34 
35 namespace sheaf
36 {
37 
41 struct SHEAF_DLL_SPEC namespace_relative_member_index
42 {
43 
48 
53  {
54  // Scoped_index data members are invalid by default.
55 
56  // Postconditions:
57 
58  ensure(!is_valid());
59 
60  // Exit:
61 
62  return;
63  };
64 
65 
69  inline explicit namespace_relative_member_index(const index_space_handle& xid_space, const pod_type& xpod)
70  : poset_id(xid_space, xpod.poset_id),
71  member_id(xid_space, xpod.member_id)
72  {
73  // Postconditions:
74 
75  ensure((pod() == xpod) || !is_valid());
76 
77  // Exit:
78 
79  return;
80  };
81 
86 
91 
95  inline bool operator==(const namespace_relative_member_index& xother) const
96  {
97  bool result;
98 
99  // Preconditions:
100 
101  // Body:
102 
103  result = ((poset_id == xother.poset_id) && (member_id == xother.member_id));
104 
105  // Postconditions:
106 
107  ensure(result == ((poset_id == xother.poset_id) && (member_id == xother.member_id)));
108 
109  // Exit:
110 
111  return result;
112  };
113 
117  inline bool is_valid() const
118  {
119  bool result;
120 
121  // Preconditions:
122 
123  // Body:
124 
125  result = (poset_id.is_valid() && member_id.is_valid());
126 
127  // Postconditions:
128 
129  // Exit:
130 
131  return result;
132  };
133 
137  void invalidate()
138  {
139  // Preconditions:
140 
141  // Body:
142 
143  poset_id.invalidate();
144  member_id.invalidate();
145 
146  // Postconditions:
147 
148  ensure(!is_valid());
149 
150  // Exit:
151 
152  return;
153  };
154 
159  {
160  // Preconditions:
161 
162  // Body:
163 
164  // Default constructor ensures invalid.
165 
166  static const namespace_relative_member_index result;
167 
168  // Postconditions:
169 
170  ensure(!result.is_valid());
171 
172  // Exit:
173 
174  return result;
175  };
176 
180  inline pod_type pod() const
181  {
182  pod_type result;
183  result.poset_id = poset_id.pod();
184  result.member_id = member_id.pod();
185 
186  return result;
187  };
188 
192  inline void put_pod(pod_type xpod)
193  {
194 
195  // Preconditions:
196 
197  // Body:
198 
199  poset_id.put_pod(xpod.poset_id);
200  member_id.put_pod(xpod.member_id);
201 
202  // Postconditions:
203 
204  ensure(pod() == xpod || !is_valid());
205 
206  // Exit:
207 
208  return;
209  };
210 
211 
212 } ;
213 
214 // ===========================================================
215 // NON-MEMBER FUNCTIONS
216 // ===========================================================
217 
221 SHEAF_DLL_SPEC
222 std::ostream&
223 operator<<(std::ostream& xos, const namespace_relative_member_index& xindex);
224 
228 SHEAF_DLL_SPEC
229 std::istream&
230 operator>>(std::istream& xis, namespace_relative_member_index& xindex);
231 
232 
233 } // namespace sheaf
234 
235 
236 #endif // ifndef NAMESPACE_RELATIVE_MEMBER_INDEX_H
237 
238 
239 
240 
241 
242 
bool operator==(const namespace_relative_member_index &xother) const
Equality operator.
Index for identifying a poset member relative to a given name space.
bool is_valid() const
True if this is a valid id.
Definition: scoped_index.h:832
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
Definition: scoped_index.h:672
scoped_index poset_id
The index of the poset relative to the namespace.
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
scoped_index member_id
The index of the member relative to the poset.
namespace_relative_member_index(const index_space_handle &xid_space, const pod_type &xpod)
Constructor from pod_type.
pod_type pod() const
The "plain old data" storage of this.
static const namespace_relative_member_index & INVALID()
The invalid id.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
bool is_valid() const
True if this is a valid id.
POD type for namespace_relative_member_index.
Definition: pod_types.h:79
void put_pod(pod_type xpod)
Sets pod() to xpod.
SHEAF_DLL_SPEC std::istream & operator>>(std::istream &is, dof_tuple_type &xdt)
Extract dof_tuple_type xdt from istream& is.
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.
namespace_relative_member_index_pod_type pod_type
The POD (plain old data) type associated this.
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