SheafSystem  0.0.0.0
namespace_relative_member_index.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 // Implementation for class NAMESPACE_RELATIVE_MEMBER_INDEX
19 
20 // Most of the implementation is inline in namespace_relative_member_index.h
21 
22 #include "SheafSystem/namespace_relative_member_index.h"
23 
24 using namespace std;
25 
26 std::ostream&
27 sheaf::operator<<(std::ostream& xos, const namespace_relative_member_index& xindex)
28 {
29  // Preconditions:
30 
31  // Body:
32 
33  xos << xindex.poset_id << " " << xindex.member_id ;
34 
35  // Postconditions:
36 
37  // Exit:
38 
39  return xos;
40 }
41 
42 std::istream&
44 {
45  // Preconditions:
46 
47  // Body:
48 
49  scoped_index lposet_id, lmember_id;
50 
51  // Extract "poset_id member_id", checking each step so
52  // when we return the stream state properly represents any failure.
53  // In particular, the stream state should properly distinguish
54  // a syntax or conversion failure from an end-of-file.
55  //
56  // Note that skipws may or may not be set, so we explicitly
57  // skip white space to make sure it is dealt with properly.
58  //
59  // Also note that this operator does not modify xindex unless
60  // the extraction succeeeds.
61 
62  if((xis >> ws >> lposet_id) && (xis >> ws >> lmember_id))
63  {
64  // Converted poset and member id successfully; set result.
65 
66  xindex.poset_id = lposet_id;
67  xindex.member_id = lmember_id;
68  }
69  else
70  {
71  // Couldn't read poset and/or member id, set fail bit..
72 
73  xis.setstate(ios_base::failbit);
74  }
75 
76  // Postconditions:
77 
78  // Exit:
79 
80  return xis;
81 }
82 
Index for identifying a poset member relative to a given name space.
scoped_index poset_id
The index of the poset relative to the namespace.
STL namespace.
scoped_index member_id
The index of the member relative to the poset.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
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.