SheafSystem  0.0.0.0
stl_scoped_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 stl_scoped_index.
19 
20 #ifndef STL_SCOPED_INDEX_H
21 #define STL_SCOPED_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 
42 class SHEAF_DLL_SPEC lexographical_compare_policy
43 {
44  public:
45 
49  static bool less_than(const scoped_index& xindex1,
50  const scoped_index& xindex2);
51 
55  static bool equal(const scoped_index& xindex1,
56  const scoped_index& xindex2);
57 };
58 
63 class SHEAF_DLL_SPEC equivalence_compare_policy
64 {
65  public:
66 
70  static bool less_than(const scoped_index& xindex1,
71  const scoped_index& xindex2);
72 
76  static bool equal(const scoped_index& xindex1,
77  const scoped_index& xindex2);
78 };
79 
86 template <typename T = lexographical_compare_policy>
87 class SHEAF_DLL_SPEC stl_scoped_index
88 {
89  // ===========================================================
90  // STL_SCOPED_INDEX FACET
91  // ===========================================================
92 
93  public:
94 
98  typedef T compare_policy;
99 
103  stl_scoped_index(const scoped_index& xindex);
104 
109  ~stl_scoped_index();
110 
114  inline bool invariant() const
115  {
116  return _index.invariant();
117  };
118 
122  inline const scoped_index& index() const
123  {
124  return _index;
125  };
126 
130  operator scoped_index () const;
131 
135  bool operator<(const stl_scoped_index<T>& xother) const;
136 
140  bool operator==(const stl_scoped_index<T>& xother) const;
141 
142  private:
143 
147  scoped_index _index;
148 };
149 
150 } // namespace sheaf
151 
152 #endif // ifndef STL_SCOPED_INDEX_H
Wrapper for scoped_index used for standard template library tree containers (set, multiset...
A stl_scoped_index comparison policy for lexographical comparison.
A stl_scoped_index comparison policy for equivalence comparison.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
T compare_policy
The type of compare policy.
const scoped_index & index() const
scoped_index being wrapped.
bool invariant() const
Class invariant.
bool operator==(const singly_linked_list< T, Alloc > &lhs, const singly_linked_list< T, Alloc > &rhs)
Checks if the contents of lhs and rhs are equal, that is, whether lhs.size() == rhs.size() and each element in lhs compares equal with the element in rhs at the same position.
Namespace for the sheaves component of the sheaf system.