SheafSystem  0.0.0.0
index_space_handle.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 INDEX_SPACE_HANDLE_IMPL_H
22 #define INDEX_SPACE_HANDLE_IMPL_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef INDEX_SPACE_HANDLE_H
29 #include "SheafSystem/index_space_handle.h"
30 #endif
31 
32 #ifndef ASSERT_CONTRACT_H
33 #include "SheafSystem/assert_contract.h"
34 #endif
35 
36 // ===========================================================
37 // PRODUCT STRUCTURE FACET
38 // ===========================================================
39 
40 template<typename T>
41 const T&
44 {
45  // Preconditions:
46 
47  require(has_product_structure());
48  require(product_structure_conforms_to<T>());
49 
50  // Body:
51 
52  const T& result = reinterpret_cast<const T&>(product_structure());
53 
54  // Postconditions:
55 
56  ensure(is_basic_query);
57 
58  // Exit:
59 
60  return result;
61 }
62 
63 template<typename T>
64 T&
67 {
68  // Preconditions:
69 
70  require(has_product_structure());
71  require(product_structure_conforms_to<T>());
72 
73  // Body:
74 
75  T& result = reinterpret_cast<T&>(product_structure());
76 
77  // Postconditions:
78 
79  ensure(is_basic_query);
80 
81  // Exit:
82 
83  return result;
84 }
85 
86 template<typename T>
87 bool
90 {
91  // Preconditions:
92 
93  require(has_product_structure());
94 
95  // Body:
96 
97  bool result = (dynamic_cast<const T*>(&product_structure()) != 0);
98 
99  // Postconditions:
100 
101  ensure(is_basic_query);
102 
103  // Exit:
104 
105  return result;
106 }
107 
108 #endif // ifndef INDEX_SPACE_HANDLE_IMPL_H
virtual bool has_product_structure() const =0
True if this id space has a product structure.
virtual const abstract_product_structure & product_structure() const =0
The product structure for this id space (const version).
bool product_structure_conforms_to() const
True if the product structure for this id space conforms to type T.