SheafSystem  0.0.0.0
stl_scoped_index.impl.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 STL_SCOPED_INDEX_IMPL_H
22 #define STL_SCOPED_INDEX_IMPL_H
23 
24 #ifndef STL_SCOPED_INDEX_H
25 #include "SheafSystem/stl_scoped_index.h"
26 #endif
27 
28 #ifndef ASSERT_CONTRACT_H
29 #include "SheafSystem/assert_contract.h"
30 #endif
31 
32 using namespace sheaf;
33 
34 // ===========================================================
35 // STL_SCOPED_INDEX
36 // ===========================================================
37 
38 template<typename T>
41 {
42  // Preconditions:
43 
44  // Body:
45 
46  _index = xindex;
47 
48  // Postconditions:
49 
50  ensure(invariant());
51  ensure(index() == xindex);
52 
53  // Exit:
54 
55  return;
56 }
57 
58 template<typename T>
61 {
62  // Nothing to do.
63 }
64 
65 template<typename T>
67 operator scoped_index () const
68 {
69  return _index;
70 }
71 
72 template<typename T>
73 bool
75 operator<(const stl_scoped_index<T>& xother) const
76 {
77  // Preconditions:
78 
79  // Body:
80 
81  bool result = compare_policy::less_than(_index, xother.index());
82 
83  // Postconditions:
84 
85  ensure(result == (compare_policy::less_than(index(), xother.index())));
86 
87  // Exit:
88 
89  return result;
90 }
91 
92 template<typename T>
93 bool
95 operator==(const stl_scoped_index<T>& xother) const
96 {
97  // Preconditions:
98 
99  // Body:
100 
101  bool result = compare_policy::equal(_index, xother.index());
102 
103  // Postconditions:
104 
105  ensure(result == (compare_policy::equal(index(), xother.index())));
106 
107  // Exit:
108 
109  return result;
110 }
111 
112 #endif // ifndef STL_SCOPED_INDEX_IMPL_H
Wrapper for scoped_index used for standard template library tree containers (set, multiset...
~stl_scoped_index()
Destructor. Not virtual; this can not be a base class.
stl_scoped_index(const scoped_index &xindex)
Creates a wrapper of scoped_index, xindex.
bool operator==(const stl_scoped_index< T > &xother) const
True if this is equivalent to xother.
bool operator<(const stl_scoped_index< T > &xother) const
True if this is less than xother.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
const scoped_index & index() const
scoped_index being wrapped.
Namespace for the sheaves component of the sheaf system.