SheafSystem  0.0.0.0
pod_types.cc
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 // Definitions for pod_types facet of namespace sheaf.
19 
20 #include "SheafSystem/pod_types.h"
21 
22 #include "SheafSystem/std_limits.h"
23 
24 using namespace std;
25 
26 // =============================================================================
27 // POD TYPES FACET
28 // =============================================================================
29 
32 {
34 }
35 
36 bool
38 {
39  return xpod_index != invalid_pod_index();
40 }
41 
44 {
46 }
47 
50 {
52 }
53 
56 {
58  result.poset_id = invalid_pod_index();
59  result.member_id = invalid_pod_index();
60  return result;
61 }
62 
63 
64 
65 bool
66 sheaf::namespace_relative_member_index_pod_type::
67 operator==(const namespace_relative_member_index_pod_type& xother) const
68 {
69  return (poset_id == xother.poset_id) && (member_id == xother.member_id);
70 };
71 
72 bool
73 sheaf::namespace_relative_member_index_pod_type::
74 is_valid()
75 {
76  return (sheaf::is_valid(poset_id) && sheaf::is_valid(member_id));
77 }
78 
81 {
83  result.poset_id = invalid_pod_index();
84  result.subposet_id = invalid_pod_index();
85  return result;
86 }
87 
88 
89 
90 bool
91 sheaf::namespace_relative_subposet_index_pod_type::
92 operator==(const sheaf::namespace_relative_subposet_index_pod_type& xother) const
93 {
94  return (poset_id == xother.poset_id) && (subposet_id == xother.subposet_id);
95 };
96 
97 bool
98 sheaf::namespace_relative_subposet_index_pod_type::
99 is_valid()
100 {
101  return (sheaf::is_valid(poset_id) && sheaf::is_valid(subposet_id));
102 }
103 
104 std::ostream&
106 {
107  xos << xpod.poset_id << " " << xpod.member_id ;
108  return xos;
109 }
110 
111 std::istream&
113 {
114  // Preconditions:
115 
116  // Body:
117 
118  pod_index_type lposet_id, lmember_id;
119 
120  // Extract "poset_id member_id", checking each step so
121  // when we return the stream state properly represents any failure.
122  // In particular, the stream state should properly distinguish
123  // a syntax or conversion failure from an end-of-file.
124  //
125  // Note that skipws may or may not be set, so we explicitly
126  // skip white space to make sure it is dealt with properly.
127  //
128  // Also note that this operator does not modify xindex unless
129  // the extraction succeeeds.
130 
131  if((xis >> ws >> lposet_id) && (xis >> ws >> lmember_id))
132  {
133  // Converted poset and member id successfully; set result.
134 
135  xpod.poset_id = lposet_id;
136  xpod.member_id = lmember_id;
137  }
138  else
139  {
140  // Couldn't read poset and/or member id, set fail bit..
141 
142  xis.setstate(ios_base::failbit);
143  }
144 
145  // Postconditions:
146 
147  // Exit:
148 
149  return xis;
150 }
151 
152 std::ostream&
154 {
155  xos << xpod.poset_id << " " << xpod.subposet_id ;
156  return xos;
157 }
158 
159 std::istream&
161 {
162  // Preconditions:
163 
164  // Body:
165 
166  pod_index_type lposet_id;
167  pod_index_type lsubposet_id;
168 
169  // Extract "poset_id subposet_id", checking each step so
170  // when we return the stream state properly represents any failure.
171  // In particular, the stream state should properly distinguish
172  // a syntax or conversion failure from an end-of-file.
173  //
174  // Note that skipws may or may not be set, so we explicitly
175  // skip white space to make sure it is dealt with properly.
176  //
177  // Also note that this operator does not modify xindex unless
178  // the extraction succeeeds.
179 
180  if((xis >> ws >> lposet_id) && (xis >> ws >> lsubposet_id))
181  {
182  // Converted poset and member id successfully; set result.
183 
184  xpod.poset_id = lposet_id;
185  xpod.subposet_id = lsubposet_id;
186  }
187  else
188  {
189  // Couldn't read poset and/or member id, set fail bit..
190 
191  xis.setstate(ios_base::failbit);
192  }
193 
194  // Postconditions:
195 
196  // Exit:
197 
198  return xis;
199 }
STL namespace.
SHEAF_DLL_SPEC namespace_relative_member_index_pod_type invalid_namespace_relative_member_index_pod()
The invalid namespace_relative_member_index_pod_type value.
Definition: pod_types.cc:55
SHEAF_DLL_SPEC namespace_relative_subposet_index_pod_type invalid_namespace_relative_subposet_index_pod()
The invalid namespace_relative_subposet_index_pod_type value.
Definition: pod_types.cc:80
SHEAF_DLL_SPEC pod_index_type max_pod_index()
The maximum pod index value.
Definition: pod_types.cc:43
POD type associated with namespace_relative_subposet_index.
Definition: pod_types.h:111
POD type for namespace_relative_member_index.
Definition: pod_types.h:79
SHEAF_DLL_SPEC void max(const vd &x0, vd_value_type &xresult, bool xauto_access)
Maximum component of x0, pre-allocated version.
Definition: vd.cc:2097
SHEAF_DLL_SPEC pod_index_type min_pod_index()
The minimum pod index value.
Definition: pod_types.cc:49
SHEAF_DLL_SPEC void min(const vd &x0, vd_value_type &xresult, bool xauto_access)
Minimum component of x0, pre-allocated version.
Definition: vd.cc:2161
SHEAF_DLL_SPEC std::istream & operator>>(std::istream &is, dof_tuple_type &xdt)
Extract dof_tuple_type xdt from istream& is.
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.
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
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
Definition: pod_types.cc:31