SheafSystem  0.0.0.0
index_traits.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 index_traits
19 
20 #ifndef INDEX_TRAITS_H
21 #define INDEX_TRAITS_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef STD_LIMITS_H
28 #include "SheafSystem/std_limits.h"
29 #endif
30 
31 namespace sheaf
32  {
33 
37 template <typename T>
38 struct SHEAF_DLL_SPEC index_traits
39 {
43  typedef T index_type;
44 
48  typedef T pod_type;
49 
53  static inline pod_type pod(const T& xindex)
54  {
55  return xindex;
56  };
57 
61  static inline void put_pod(T& xindex, pod_type& xpod)
62  {
63  xindex = xpod;
64  return;
65  };
66 
70  static inline T invalid()
71  {
73  };
74 
78  static inline bool is_valid(const T& xindex)
79  {
80  return xindex != invalid();
81  }
82 
86  static inline T zero()
87  {
88  return 0;
89  };
90 
94  static inline T one()
95  {
96  return 1;
97  };
98 
102  static inline bool is_positive(const T& xindex)
103  {
104  return xindex >= 0;
105  }
106 
110  static inline bool is_positive_definite(const T& xindex)
111  {
112  return xindex > 0;
113  }
114 
118  static inline T max()
119  {
120  return std::numeric_limits<T>::max() - 1;
121  };
122 
126  static inline T min()
127  {
129  };
130 };
131 
132 } // namespace sheaf
133 
134 #endif // ifndef INDEX_TRAITS_H
135 
136 
137 
138 
139 
140 
static T invalid()
The invalid index value.
Definition: index_traits.h:70
T pod_type
An integral type representing a relative index.
Definition: index_traits.h:48
static T max()
The maximum valid value.
Definition: index_traits.h:118
static bool is_positive(const T &xindex)
True if xindex is >= zero().
Definition: index_traits.h:102
Features describing T as an index type.
Definition: index_traits.h:38
T index_type
The index type.
Definition: index_traits.h:43
static bool is_positive_definite(const T &xindex)
True if xindex is > zero().
Definition: index_traits.h:110
static bool is_valid(const T &xindex)
True if xindex is valid.
Definition: index_traits.h:78
static pod_type pod(const T &xindex)
Converts an index type xindex to pod_type.
Definition: index_traits.h:53
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 void min(const vd &x0, vd_value_type &xresult, bool xauto_access)
Minimum component of x0, pre-allocated version.
Definition: vd.cc:2161
static T zero()
The additive identity.
Definition: index_traits.h:86
static T one()
The multiplicative identity.
Definition: index_traits.h:94
Namespace for the sheaves component of the sheaf system.
static T min()
The minimum valid value.
Definition: index_traits.h:126
static void put_pod(T &xindex, pod_type &xpod)
Sets the pod of index type xindex to xpod.
Definition: index_traits.h:61