SheafSystem  0.0.0.0
binary_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 // Interface for class binary_index
18 
19 #ifndef BINARY_INDEX_H
20 #define BINARY_INDEX_H
21 
22 #ifndef SHEAF_DLL_SPEC_H
23 #include "SheafSystem/sheaf_dll_spec.h"
24 #endif
25 
26 #ifndef UNARY_INDEX_H
27 #include "SheafSystem/unary_index.h"
28 #endif
29 
30 #ifndef STD_IOSTREAM_H
31 #include "SheafSystem/std_iostream.h"
32 #endif
33 
34 #ifndef ASSERT_CONTRACT_H
35 #include "SheafSystem/assert_contract.h"
36 #endif
37 
38 namespace fiber_bundle
39 {
40 
44 class SHEAF_DLL_SPEC binary_index
45 {
46 public:
47 
51  unary_index i;
52 
56  unary_index j;
57 
62  {
63  // Preconditions:
64 
65  // Body:
66 
67  i = 0;
68  j = 0;
69 
70  // Postconditions:
71 
72  ensure(i == 0);
73  ensure(j == 0);
74 
75  // Exit:
76 
77  return;
78  };
79 
83  binary_index(unary_index xi, unary_index xj)
84  {
85  // Preconditions:
86 
87  // Body:
88 
89  i = xi;
90  j = xj;
91 
92  // Postconditions:
93 
94  ensure(i == xi);
95  ensure(j == xj);
96 
97  // Exit:
98 
99  return;
100  };
101 
102  //
103  // Copy constructor not defined;
104  // uses default memberwise initialization
105  //
106 
107  //
108  // Assignment operator not defined;
109  // uses default memberwise assignment.
110  //
111 
112  //
113  // Destructor not defined;
114  // uses default memberwise destruction.
115  //
116 
120  binary_index operator+(const binary_index& xother) const
121  {
122  // Preconditions:
123 
124  // Body:
125 
126  binary_index result(i+xother.i, j+xother.j);
127 
128  // Postconditions:
129 
130  ensure(result.i = i + xother.i);
131  ensure(result.j = j + xother.j);
132 
133  // Exit:
134 
135  return result;
136  };
137 
142  {
143  // Preconditions:
144 
145  // Body:
146 
147  define_old_variable(unary_index old_i = i);
148  define_old_variable(unary_index old_j = j);
149 
150  i += xother.i;
151  j += xother.j;
152 
153  // Postconditions:
154 
155  ensure(i = old_i + xother.i);
156  ensure(j = old_j + xother.j);
157 
158  // Exit:
159 
160  return *this;
161  };
162 };
163 
164 // NON-MEMBER FUNCTIONS
165 
166 #ifndef DOXYGEN_1_5_4_SKIP_UNKNOWN
167 
171 SHEAF_DLL_SPEC
172 std::ostream& operator<<(std::ostream& os, const binary_index& xbi);
173 
174 #endif // ifndef DOXYGEN_1_5_4_SKIP_UNKNOWN
175 
176 } // namespace fiber_bundle
177 
178 
179 #endif // ifndef BINARY_INDEX_H
A pair of indices (i,j).
Definition: binary_index.h:44
binary_index operator+(const binary_index &xother) const
Sum.
Definition: binary_index.h:120
binary_index(unary_index xi, unary_index xj)
Creates an instance with i == xi, j == xj.
Definition: binary_index.h:83
unary_index i
The first index.
Definition: binary_index.h:51
unary_index j
The second index.
Definition: binary_index.h:56
binary_index & operator+=(const binary_index &xother)
Self-allocated sum.
Definition: binary_index.h:141
Namespace for the fiber_bundles component of the sheaf system.
binary_index()
Default Constructor; creates an instance with i == j == 0;.
Definition: binary_index.h:61
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const binary_index &xbi)
Insert binary_index& xbi into ostream& os.
Definition: binary_index.cc:35