SheafSystem  0.0.0.0
ternary_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 ternary_index
19 
20 #ifndef TERNARY_INDEX_H
21 #define TERNARY_INDEX_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef UNARY_INDEX_H
28 #include "SheafSystem/unary_index.h"
29 #endif
30 
31 #ifndef STD_IOSTREAM_H
32 #include "SheafSystem/std_iostream.h"
33 #endif
34 
35 #ifndef ASSERT_CONTRACT_H
36 #include "SheafSystem/assert_contract.h"
37 #endif
38 
39 namespace fiber_bundle
40 {
41 
45 class SHEAF_DLL_SPEC ternary_index
46 {
47 public:
48 
52  unary_index i;
53 
57  unary_index j;
58 
62  unary_index k;
63 
68  {
69  // Preconditions:
70 
71  // Body:
72 
73  i = 0;
74  j = 0;
75  k = 0;
76 
77  // Postconditions:
78 
79  ensure(i == 0);
80  ensure(j == 0);
81  ensure(k == 0);
82 
83  // Exit:
84 
85  return;
86  };
87 
91  ternary_index(unary_index xi, unary_index xj, unary_index xk)
92  {
93  // Preconditions:
94 
95  // Body:
96 
97  i = xi;
98  j = xj;
99  k = xk;
100 
101  // Postconditions:
102 
103  ensure(i == xi);
104  ensure(j == xj);
105  ensure(k == xk);
106 
107  // Exit:
108 
109  return;
110  };
111 
112  //
113  // Copy constructor not defined;
114  // uses default memberwise initialization
115  //
116 
117  //
118  // Assignment operator not defined;
119  // uses default memberwise assignment.
120  //
121 
122  //
123  // Destructor not defined;
124  // uses default memberwise destruction.
125  //
126 
130  ternary_index operator+(const ternary_index& xother) const
131  {
132  // Preconditions:
133 
134  // Body:
135 
136  ternary_index result(i+xother.i, j+xother.j, k+xother.k);
137 
138  // Postconditions:
139 
140  ensure(result.i = i + xother.i);
141  ensure(result.j = j + xother.j);
142  ensure(result.k = k + xother.k);
143 
144  // Exit:
145 
146  return result;
147  };
148 
153  {
154  // Preconditions:
155 
156  // Body:
157 
158  define_old_variable(unary_index old_i = i);
159  define_old_variable(unary_index old_j = j);
160  define_old_variable(unary_index old_k = k);
161 
162  i += xother.i;
163  j += xother.j;
164  k += xother.k;
165 
166  // Postconditions:
167 
168  ensure(i = old_i + xother.i);
169  ensure(j = old_j + xother.j);
170  ensure(k = old_k + xother.k);
171 
172  // Exit:
173 
174  return *this;
175  };
176 };
177 
178 // NON-MEMBER FUNCTIONS
179 
180 #ifndef DOXYGEN_1_5_4_SKIP_UNKNOWN
181 
185 SHEAF_DLL_SPEC std::ostream & operator << (std::ostream& os, const ternary_index& xbi);
186 
187 #endif // ifndef DOXYGEN_1_5_4_SKIP_UNKNOWN
188 
189 } // namespace fiber_bundle
190 
191 
192 #endif // ifndef TERNARY_INDEX_H
A triple of indices (i,j, k).
Definition: ternary_index.h:45
unary_index j
The second index.
Definition: ternary_index.h:57
unary_index i
The first index.
Definition: ternary_index.h:52
ternary_index(unary_index xi, unary_index xj, unary_index xk)
Creates an instance with i == xi, j == xj, k == xk.
Definition: ternary_index.h:91
ternary_index()
Default Constructor; creates an instance with i == j == k == 0;.
Definition: ternary_index.h:67
ternary_index & operator+=(const ternary_index &xother)
Self-allocated sum.
unary_index k
The third index.
Definition: ternary_index.h:62
ternary_index operator+(const ternary_index &xother) const
Sum.
Namespace for the fiber_bundles component of the sheaf system.
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