casadi 3.6.4__cp35-none-manylinux1_i686.whl → 3.6.6__cp35-none-manylinux1_i686.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. casadi/_casadi.so +0 -0
  2. casadi/casadi.py +984 -500
  3. casadi/cbc +0 -0
  4. casadi/clp +0 -0
  5. casadi/cmake/casadi-config-version.cmake +1 -1
  6. casadi/include/casadi/casadi.i +33 -15
  7. casadi/include/casadi/casadi_c.h +2 -0
  8. casadi/include/casadi/config.h +8 -8
  9. casadi/include/casadi/core/casadi_common.hpp +1 -0
  10. casadi/include/casadi/core/casadi_misc.hpp +13 -0
  11. casadi/include/casadi/core/casadi_types.hpp +3 -2
  12. casadi/include/casadi/core/code_generator.hpp +59 -2
  13. casadi/include/casadi/core/core.hpp +1 -0
  14. casadi/include/casadi/core/generic_expression.hpp +1 -1
  15. casadi/include/casadi/core/generic_type.hpp +25 -1
  16. casadi/include/casadi/core/global_options.hpp +2 -0
  17. casadi/include/casadi/core/matrix_decl.hpp +15 -0
  18. casadi/include/casadi/core/mx.hpp +13 -3
  19. casadi/include/casadi/core/optistack.hpp +23 -0
  20. casadi/include/casadi/core/runtime/casadi_nlp.hpp +133 -6
  21. casadi/include/casadi/core/runtime/casadi_ocp_block.hpp +55 -0
  22. casadi/include/casadi/core/runtime/casadi_oracle.hpp +44 -0
  23. casadi/include/casadi/core/runtime/casadi_oracle_callback.hpp +39 -0
  24. casadi/include/casadi/core/runtime/casadi_runtime.hpp +4 -1
  25. casadi/include/casadi/core/runtime/casadi_scaled_copy.hpp +31 -0
  26. casadi/include/casadi/core/runtime/casadi_sqpmethod.hpp +11 -1
  27. casadi/include/casadi/core/serializing_stream.hpp +2 -2
  28. casadi/include/casadi/core/sparsity.hpp +12 -3
  29. casadi/include/casadi/core/tools.hpp +67 -0
  30. casadi/include/casadi/doc.i +2283 -1491
  31. casadi/include/casadi/doc_merged.i +1522 -1065
  32. casadi/include/casadi/mem.h +1 -0
  33. casadi/include/coin-or/IpAlgBuilder.hpp +417 -0
  34. casadi/include/coin-or/IpAlgStrategy.hpp +201 -0
  35. casadi/include/coin-or/IpAlgTypes.hpp +64 -0
  36. casadi/include/coin-or/IpAugSystemSolver.hpp +212 -0
  37. casadi/include/coin-or/IpBlas.hpp +426 -0
  38. casadi/include/coin-or/IpCachedResults.hpp +897 -0
  39. casadi/include/coin-or/IpCompoundMatrix.hpp +423 -0
  40. casadi/include/coin-or/IpCompoundSymMatrix.hpp +348 -0
  41. casadi/include/coin-or/IpCompoundVector.hpp +395 -0
  42. casadi/include/coin-or/IpConvCheck.hpp +97 -0
  43. casadi/include/coin-or/IpDebug.hpp +167 -0
  44. casadi/include/coin-or/IpDenseVector.hpp +626 -0
  45. casadi/include/coin-or/IpDiagMatrix.hpp +158 -0
  46. casadi/include/coin-or/IpEqMultCalculator.hpp +76 -0
  47. casadi/include/coin-or/IpException.hpp +156 -0
  48. casadi/include/coin-or/IpExpansionMatrix.hpp +245 -0
  49. casadi/include/coin-or/IpGenTMatrix.hpp +290 -0
  50. casadi/include/coin-or/IpHessianUpdater.hpp +73 -0
  51. casadi/include/coin-or/IpIdentityMatrix.hpp +167 -0
  52. casadi/include/coin-or/IpIpoptAlg.hpp +257 -0
  53. casadi/include/coin-or/IpIpoptApplication.hpp +367 -0
  54. casadi/include/coin-or/IpIpoptCalculatedQuantities.hpp +1009 -0
  55. casadi/include/coin-or/IpIpoptData.hpp +966 -0
  56. casadi/include/coin-or/IpIpoptNLP.hpp +328 -0
  57. casadi/include/coin-or/IpIterateInitializer.hpp +68 -0
  58. casadi/include/coin-or/IpIteratesVector.hpp +840 -0
  59. casadi/include/coin-or/IpIterationOutput.hpp +78 -0
  60. casadi/include/coin-or/IpJournalist.hpp +573 -0
  61. casadi/include/coin-or/IpLapack.hpp +227 -0
  62. casadi/include/coin-or/IpLibraryLoader.hpp +76 -0
  63. casadi/include/coin-or/IpLineSearch.hpp +106 -0
  64. casadi/include/coin-or/IpLinearSolvers.h +46 -0
  65. casadi/include/coin-or/IpMatrix.hpp +434 -0
  66. casadi/include/coin-or/IpMuUpdate.hpp +77 -0
  67. casadi/include/coin-or/IpNLP.hpp +306 -0
  68. casadi/include/coin-or/IpNLPScaling.hpp +582 -0
  69. casadi/include/coin-or/IpObserver.hpp +422 -0
  70. casadi/include/coin-or/IpOptionsList.hpp +412 -0
  71. casadi/include/coin-or/IpOrigIpoptNLP.hpp +603 -0
  72. casadi/include/coin-or/IpPDSystemSolver.hpp +137 -0
  73. casadi/include/coin-or/IpReferenced.hpp +262 -0
  74. casadi/include/coin-or/IpRegOptions.hpp +1152 -0
  75. casadi/include/coin-or/IpReturnCodes.h +23 -0
  76. casadi/include/coin-or/IpReturnCodes.hpp +18 -0
  77. casadi/include/coin-or/IpReturnCodes.inc +71 -0
  78. casadi/include/coin-or/IpReturnCodes_inc.h +45 -0
  79. casadi/include/coin-or/IpScaledMatrix.hpp +291 -0
  80. casadi/include/coin-or/IpSearchDirCalculator.hpp +72 -0
  81. casadi/include/coin-or/IpSmartPtr.hpp +865 -0
  82. casadi/include/coin-or/IpSolveStatistics.hpp +210 -0
  83. casadi/include/coin-or/IpSparseSymLinearSolverInterface.hpp +260 -0
  84. casadi/include/coin-or/IpStdAugSystemSolver.cpp +555 -0
  85. casadi/include/coin-or/IpStdCInterface.h +428 -0
  86. casadi/include/coin-or/IpSumSymMatrix.hpp +186 -0
  87. casadi/include/coin-or/IpSymLinearSolver.hpp +141 -0
  88. casadi/include/coin-or/IpSymMatrix.hpp +167 -0
  89. casadi/include/coin-or/IpSymScaledMatrix.hpp +255 -0
  90. casadi/include/coin-or/IpSymTMatrix.hpp +275 -0
  91. casadi/include/coin-or/IpTNLP.hpp +820 -0
  92. casadi/include/coin-or/IpTNLPAdapter.hpp +648 -0
  93. casadi/include/coin-or/IpTNLPReducer.hpp +274 -0
  94. casadi/include/coin-or/IpTaggedObject.hpp +128 -0
  95. casadi/include/coin-or/IpTimedTask.hpp +218 -0
  96. casadi/include/coin-or/IpTimingStatistics.hpp +323 -0
  97. casadi/include/coin-or/IpTripletHelper.hpp +308 -0
  98. casadi/include/coin-or/IpTypes.h +81 -0
  99. casadi/include/coin-or/IpTypes.hpp +30 -0
  100. casadi/include/coin-or/IpUtils.hpp +166 -0
  101. casadi/include/coin-or/IpVector.hpp +892 -0
  102. casadi/include/coin-or/IpZeroSymMatrix.hpp +155 -0
  103. casadi/include/coin-or/IpoptConfig.h +45 -0
  104. casadi/include/coin-or/SensAlgorithm.hpp +114 -0
  105. casadi/include/coin-or/SensApplication.hpp +188 -0
  106. casadi/include/coin-or/SensBacksolver.hpp +36 -0
  107. casadi/include/coin-or/SensMeasurement.hpp +56 -0
  108. casadi/include/coin-or/SensPCalculator.hpp +137 -0
  109. casadi/include/coin-or/SensRegOp.hpp +21 -0
  110. casadi/include/coin-or/SensSchurData.hpp +182 -0
  111. casadi/include/coin-or/SensSchurDriver.hpp +118 -0
  112. casadi/include/coin-or/SensSimpleBacksolver.hpp +49 -0
  113. casadi/include/coin-or/SensStepCalc.hpp +85 -0
  114. casadi/include/coin-or/SensUtils.hpp +63 -0
  115. casadi/include/coin-or/metis/defs.h +161 -0
  116. casadi/include/coin-or/metis/macros.h +143 -0
  117. casadi/include/coin-or/metis/metis.h +37 -0
  118. casadi/include/coin-or/metis/proto.h +505 -0
  119. casadi/include/coin-or/metis/rename.h +418 -0
  120. casadi/include/coin-or/metis/struct.h +251 -0
  121. casadi/include/coin-or/mumps/dmumps_c.h +142 -0
  122. casadi/include/coin-or/mumps/mumps_c_types.h +72 -0
  123. casadi/include/coin-or/mumps/mumps_compat.h +27 -0
  124. casadi/include/coin-or/mumps/mumps_int_def.h +11 -0
  125. casadi/include/coin-or/mumps/mumps_mpi.h +67 -0
  126. casadi/include/daqp/api.h +46 -0
  127. casadi/include/daqp/auxiliary.h +29 -0
  128. casadi/include/daqp/bnb.h +32 -0
  129. casadi/include/daqp/codegen.h +18 -0
  130. casadi/include/daqp/constants.h +92 -0
  131. casadi/include/daqp/daqp.h +22 -0
  132. casadi/include/daqp/daqp_prox.h +18 -0
  133. casadi/include/daqp/factorization.h +18 -0
  134. casadi/include/daqp/types.h +161 -0
  135. casadi/include/daqp/utils.h +44 -0
  136. casadi/include/licenses/daqp-external/LICENSE +21 -0
  137. casadi/include/osqp/constants.h +2 -3
  138. casadi/include/osqp/version.h +9 -0
  139. casadi/lib/libtinyxml2.a +0 -0
  140. casadi/libCbc.so +0 -0
  141. casadi/libCbc.so.3 +0 -0
  142. casadi/libCbc.so.3.10.11 +0 -0
  143. casadi/libCbcSolver.so +0 -0
  144. casadi/libCbcSolver.so.3 +0 -0
  145. casadi/libCbcSolver.so.3.10.11 +0 -0
  146. casadi/libCgl.so +0 -0
  147. casadi/libCgl.so.1 +0 -0
  148. casadi/libCgl.so.1.10.8 +0 -0
  149. casadi/libClp.so +0 -0
  150. casadi/libClp.so.1 +0 -0
  151. casadi/libClp.so.1.14.9 +0 -0
  152. casadi/libClpSolver.so +0 -0
  153. casadi/libClpSolver.so.1 +0 -0
  154. casadi/libClpSolver.so.1.14.9 +0 -0
  155. casadi/libCoinUtils.so +0 -0
  156. casadi/libCoinUtils.so.3 +0 -0
  157. casadi/libCoinUtils.so.3.11.10 +0 -0
  158. casadi/libOsi.so +0 -0
  159. casadi/libOsi.so.1 +0 -0
  160. casadi/libOsi.so.1.13.9 +0 -0
  161. casadi/libOsiCbc.so +0 -0
  162. casadi/libOsiCbc.so.3 +0 -0
  163. casadi/libOsiCbc.so.3.10.11 +0 -0
  164. casadi/libOsiClp.so +0 -0
  165. casadi/libOsiClp.so.1 +0 -0
  166. casadi/libOsiClp.so.1.14.9 +0 -0
  167. casadi/libOsiCommonTests.so +0 -0
  168. casadi/libOsiCommonTests.so.1 +0 -0
  169. casadi/libOsiCommonTests.so.1.13.9 +0 -0
  170. casadi/libbonmin.so +0 -0
  171. casadi/libbonmin.so.4 +0 -0
  172. casadi/libbonmin.so.4.8.9 +0 -0
  173. casadi/libcasadi.so +0 -0
  174. casadi/libcasadi.so.3.7 +0 -0
  175. casadi/libcasadi_conic_cbc.so +0 -0
  176. casadi/libcasadi_conic_cbc.so.3.7 +0 -0
  177. casadi/libcasadi_conic_clp.so +0 -0
  178. casadi/libcasadi_conic_clp.so.3.7 +0 -0
  179. casadi/libcasadi_conic_daqp.so +0 -0
  180. casadi/libcasadi_conic_daqp.so.3.7 +0 -0
  181. casadi/libcasadi_conic_gurobi.so +0 -0
  182. casadi/libcasadi_conic_gurobi.so.3.7 +0 -0
  183. casadi/libcasadi_conic_ipqp.so +0 -0
  184. casadi/libcasadi_conic_ipqp.so.3.7 +0 -0
  185. casadi/libcasadi_conic_nlpsol.so +0 -0
  186. casadi/libcasadi_conic_nlpsol.so.3.7 +0 -0
  187. casadi/libcasadi_conic_osqp.so +0 -0
  188. casadi/libcasadi_conic_osqp.so.3.7 +0 -0
  189. casadi/libcasadi_conic_qpoases.so +0 -0
  190. casadi/libcasadi_conic_qpoases.so.3.7 +0 -0
  191. casadi/libcasadi_conic_qrqp.so +0 -0
  192. casadi/libcasadi_conic_qrqp.so.3.7 +0 -0
  193. casadi/libcasadi_conic_superscs.so +0 -0
  194. casadi/libcasadi_conic_superscs.so.3.7 +0 -0
  195. casadi/libcasadi_integrator_collocation.so +0 -0
  196. casadi/libcasadi_integrator_collocation.so.3.7 +0 -0
  197. casadi/libcasadi_integrator_cvodes.so +0 -0
  198. casadi/libcasadi_integrator_cvodes.so.3.7 +0 -0
  199. casadi/libcasadi_integrator_idas.so +0 -0
  200. casadi/libcasadi_integrator_idas.so.3.7 +0 -0
  201. casadi/libcasadi_integrator_rk.so +0 -0
  202. casadi/libcasadi_integrator_rk.so.3.7 +0 -0
  203. casadi/libcasadi_nlpsol_ampl.so +0 -0
  204. casadi/libcasadi_nlpsol_ampl.so.3.7 +0 -0
  205. casadi/libcasadi_nlpsol_blocksqp.so +0 -0
  206. casadi/libcasadi_nlpsol_blocksqp.so.3.7 +0 -0
  207. casadi/libcasadi_nlpsol_bonmin.so +0 -0
  208. casadi/libcasadi_nlpsol_bonmin.so.3.7 +0 -0
  209. casadi/libcasadi_nlpsol_feasiblesqpmethod.so +0 -0
  210. casadi/libcasadi_nlpsol_feasiblesqpmethod.so.3.7 +0 -0
  211. casadi/libcasadi_nlpsol_ipopt.so +0 -0
  212. casadi/libcasadi_nlpsol_ipopt.so.3.7 +0 -0
  213. casadi/libcasadi_nlpsol_knitro.so +0 -0
  214. casadi/libcasadi_nlpsol_knitro.so.3.7 +0 -0
  215. casadi/libcasadi_nlpsol_madnlp.so +0 -0
  216. casadi/libcasadi_nlpsol_madnlp.so.3.7 +0 -0
  217. casadi/libcasadi_nlpsol_qrsqp.so +0 -0
  218. casadi/libcasadi_nlpsol_qrsqp.so.3.7 +0 -0
  219. casadi/libcasadi_nlpsol_scpgen.so +0 -0
  220. casadi/libcasadi_nlpsol_scpgen.so.3.7 +0 -0
  221. casadi/libcasadi_nlpsol_snopt.so +0 -0
  222. casadi/libcasadi_nlpsol_snopt.so.3.7 +0 -0
  223. casadi/libcasadi_nlpsol_sqpmethod.so +0 -0
  224. casadi/libcasadi_nlpsol_sqpmethod.so.3.7 +0 -0
  225. casadi/libcasadi_nlpsol_worhp.so +0 -0
  226. casadi/libcasadi_nlpsol_worhp.so.3.7 +0 -0
  227. casadi/libcasadi_rootfinder_fast_newton.so +0 -0
  228. casadi/libcasadi_rootfinder_fast_newton.so.3.7 +0 -0
  229. casadi/libcasadi_rootfinder_kinsol.so +0 -0
  230. casadi/libcasadi_rootfinder_kinsol.so.3.7 +0 -0
  231. casadi/libcasadi_rootfinder_newton.so +0 -0
  232. casadi/libcasadi_rootfinder_newton.so.3.7 +0 -0
  233. casadi/libcasadi_rootfinder_nlpsol.so +0 -0
  234. casadi/libcasadi_rootfinder_nlpsol.so.3.7 +0 -0
  235. casadi/libcasadi_sundials_common.so +0 -0
  236. casadi/libcasadi_sundials_common.so.3.7 +0 -0
  237. casadi/libdaqp.so +0 -0
  238. casadi/libdaqpstat.a +0 -0
  239. casadi/libindirect.a +0 -0
  240. casadi/libipopt.so +0 -0
  241. casadi/libipopt.so.3 +0 -0
  242. casadi/libipopt.so.3.14.11 +0 -0
  243. casadi/liblinsys.a +0 -0
  244. casadi/libmatlab_ipc.so +0 -0
  245. casadi/libosqp.a +0 -0
  246. casadi/libosqp.so +0 -0
  247. casadi/libqdldl.a +0 -0
  248. casadi/libsipopt.so +0 -0
  249. casadi/libsipopt.so.3 +0 -0
  250. casadi/libsipopt.so.3.14.11 +0 -0
  251. casadi/libsuperscs.a +0 -0
  252. casadi/pkgconfig/casadi.pc +1 -1
  253. casadi/tools/__init__.py +4 -0
  254. casadi/tools/bounds.py +3 -3
  255. {casadi-3.6.4.dist-info → casadi-3.6.6.dist-info}/METADATA +12 -4
  256. {casadi-3.6.4.dist-info → casadi-3.6.6.dist-info}/RECORD +257 -140
  257. {casadi-3.6.4.dist-info → casadi-3.6.6.dist-info}/WHEEL +0 -0
@@ -0,0 +1,422 @@
1
+ // Copyright (C) 2004, 2006 International Business Machines and others.
2
+ // All Rights Reserved.
3
+ // This code is published under the Eclipse Public License.
4
+ //
5
+ // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6
+
7
+ #ifndef __IPOBSERVER_HPP__
8
+ #define __IPOBSERVER_HPP__
9
+
10
+ #include "IpUtils.hpp"
11
+ #include <vector>
12
+ #include <algorithm>
13
+
14
+ //#define IP_DEBUG_OBSERVER
15
+ #if IPOPT_CHECKLEVEL > 2
16
+ # define IP_DEBUG_OBSERVER
17
+ #endif
18
+ #ifdef IP_DEBUG_OBSERVER
19
+ # include "IpDebug.hpp"
20
+ #endif
21
+
22
+ namespace Ipopt
23
+ {
24
+ /* Forward declaration */
25
+ class Subject;
26
+
27
+ /** Slight Variation of the Observer Design Pattern.
28
+ *
29
+ * This class implements the Observer class of the
30
+ * Observer Design Pattern. An Observer "Attach"es
31
+ * to a Subject, indicating that it would like to
32
+ * be notified of changes in the Subject.
33
+ * Any derived class wishing to receive notifications
34
+ * from a Subject should inherit off of
35
+ * Observer and overload the protected method,
36
+ * ReceiveNotification_(...).
37
+ */
38
+ class IPOPTLIB_EXPORT Observer
39
+ {
40
+ public:
41
+ #ifdef IP_DEBUG_OBSERVER
42
+ static const Index dbg_verbosity;
43
+ #endif
44
+
45
+ /**@name Constructors/Destructors */
46
+ ///@{
47
+ /** Default Constructor */
48
+ Observer()
49
+ { }
50
+
51
+ /** Destructor */
52
+ inline
53
+ virtual ~Observer();
54
+ ///@}
55
+
56
+ /** Enumeration specifying the type of notification */
57
+ enum NotifyType
58
+ {
59
+ NT_All,
60
+ NT_BeingDestroyed,
61
+ NT_Changed
62
+ };
63
+
64
+ protected:
65
+ /** Derived classes should call this method
66
+ * to request an "Attach" to a Subject.
67
+ *
68
+ * Do not call "Attach" explicitly on the Subject
69
+ * since further processing is done here
70
+ */
71
+ inline
72
+ void RequestAttach(
73
+ NotifyType notify_type,
74
+ const Subject* subject
75
+ );
76
+
77
+ /** Derived classes should call this method
78
+ * to request a "Detach" to a Subject.
79
+ *
80
+ * Do not call "Detach" explicitly on the Subject
81
+ * since further processing is done here
82
+ */
83
+ inline
84
+ void RequestDetach(
85
+ NotifyType notify_type,
86
+ const Subject* subject
87
+ );
88
+
89
+ /** Derived classes should overload this method to
90
+ * receive the requested notification from
91
+ * attached Subjects
92
+ */
93
+ virtual void ReceiveNotification(
94
+ NotifyType notify_type,
95
+ const Subject* subject
96
+ ) = 0;
97
+
98
+ private:
99
+ /**@name Default Compiler Generated Methods
100
+ * (Hidden to avoid implicit creation/calling).
101
+ *
102
+ * These methods are not implemented and
103
+ * we do not want the compiler to implement
104
+ * them for us, so we declare them private
105
+ * and do not define them. This ensures that
106
+ * they will not be implicitly created/called.
107
+ */
108
+ ///@{
109
+ /** Copy Constructor */
110
+ Observer(
111
+ const Observer&
112
+ );
113
+
114
+ /** Default Assignment Operator */
115
+ void operator=(
116
+ const Observer&
117
+ );
118
+ ///@}
119
+
120
+ /** A list of the subjects currently being observed. */
121
+ std::vector<const Subject*> subjects_;
122
+
123
+ /** Private Method for Receiving Notification
124
+ * should only be called by the friend class
125
+ * Subject.
126
+ *
127
+ * This method will, in turn, call
128
+ * the overloaded ReceiveNotification method
129
+ * for the derived class to process.
130
+ */
131
+ inline
132
+ void ProcessNotification(
133
+ NotifyType notify_type,
134
+ const Subject* subject
135
+ );
136
+
137
+ friend class Subject;
138
+ };
139
+
140
+ /** Slight Variation of the Observer Design Pattern (Subject part).
141
+ *
142
+ * This class implements the Subject class of the Observer Design
143
+ * Pattern. An Observer "Attach"es to a Subject, indicating that it
144
+ * would like to be notified of changes in the Subject. Any
145
+ * derived class that is to be observed has to inherit off the
146
+ * Subject base class. If the subject needs to notify the
147
+ * Observer, it calls the Notify method.
148
+ */
149
+ class IPOPTLIB_EXPORT Subject
150
+ {
151
+ public:
152
+ #ifdef IP_DEBUG_OBSERVER
153
+ static const Index dbg_verbosity;
154
+ #endif
155
+
156
+ /**@name Constructors/Destructors */
157
+ ///@{
158
+ /** Default Constructor */
159
+ Subject()
160
+ { }
161
+
162
+ /** Destructor */
163
+ inline
164
+ virtual ~Subject();
165
+ ///@}
166
+
167
+ /**@name Methods to Add and Remove Observers.
168
+ *
169
+ * Currently, the notify_type flags are not used,
170
+ * and Observers are attached in general and will
171
+ * receive all notifications (of the type requested
172
+ * and possibly of types not requested). It is
173
+ * up to the observer to ignore the types they
174
+ * are not interested in. The NotifyType in the
175
+ * parameter list is so a more efficient mechanism
176
+ * depending on type could be implemented later if
177
+ * necessary.
178
+ */
179
+ ///@{
180
+ /** Attach the specified observer
181
+ * (i.e., begin receiving notifications). */
182
+ inline
183
+ void AttachObserver(
184
+ Observer::NotifyType notify_type,
185
+ Observer* observer
186
+ ) const;
187
+
188
+ /** Detach the specified observer
189
+ * (i.e., no longer receive notifications). */
190
+ inline
191
+ void DetachObserver(
192
+ Observer::NotifyType notify_type,
193
+ Observer* observer
194
+ ) const;
195
+ ///@}
196
+
197
+ protected:
198
+
199
+ inline
200
+ void Notify(
201
+ Observer::NotifyType notify_type
202
+ ) const;
203
+
204
+ private:
205
+ /**@name Default Compiler Generated Methods
206
+ * (Hidden to avoid implicit creation/calling).
207
+ *
208
+ * These methods are not implemented and
209
+ * we do not want the compiler to implement
210
+ * them for us, so we declare them private
211
+ * and do not define them. This ensures that
212
+ * they will not be implicitly created/called.
213
+ */
214
+ ///@{
215
+ /** Copy Constructor */
216
+ Subject(
217
+ const Subject&
218
+ );
219
+
220
+ /** Default Assignment Operator */
221
+ void operator=(
222
+ const Subject&
223
+ );
224
+ ///@}
225
+
226
+ mutable std::vector<Observer*> observers_;
227
+ };
228
+
229
+ /* inline methods */
230
+ inline Observer::~Observer()
231
+ {
232
+ #ifdef IP_DEBUG_OBSERVER
233
+ DBG_START_METH("Observer::~Observer", dbg_verbosity);
234
+ if (DBG_VERBOSITY() >= 1)
235
+ {
236
+ for( size_t i = 0; i < subjects_.size(); ++i )
237
+ {
238
+ DBG_PRINT((1, "subjects_[%zd] = %p\n", i, (const void*)subjects_[i]));
239
+ }
240
+ }
241
+ #endif
242
+ // Detach all subjects
243
+ for( size_t i = subjects_.size(); i > 0; --i )
244
+ {
245
+ #ifdef IP_DEBUG_OBSERVER
246
+ DBG_PRINT((1, "About to detach subjects_[%zd] = %p\n", i, (const void*)subjects_[i - 1]));
247
+ #endif
248
+
249
+ RequestDetach(NT_All, subjects_[i - 1]);
250
+ }
251
+ }
252
+
253
+ inline
254
+ void Observer::RequestAttach(
255
+ NotifyType notify_type,
256
+ const Subject* subject
257
+ )
258
+ {
259
+ #ifdef IP_DEBUG_OBSERVER
260
+ DBG_START_METH("Observer::RequestAttach", dbg_verbosity);
261
+
262
+ // Add the subject to the list if it does not already exist
263
+ std::vector<const Subject*>::iterator attached_subject;
264
+ attached_subject = std::find(subjects_.begin(), subjects_.end(), subject);
265
+ DBG_ASSERT(attached_subject == subjects_.end());
266
+ DBG_ASSERT(subject);
267
+ #endif
268
+
269
+ // add the subject to the list
270
+ subjects_.push_back(subject);
271
+ // Attach the observer to the subject
272
+ subject->AttachObserver(notify_type, this);
273
+ }
274
+
275
+ inline
276
+ void Observer::RequestDetach(
277
+ NotifyType notify_type,
278
+ const Subject* subject
279
+ )
280
+ {
281
+ #ifdef IP_DEBUG_OBSERVER
282
+ DBG_START_METH("Observer::RequestDetach", dbg_verbosity);
283
+ DBG_PRINT((1, "Requesting detach of subject: %p\n", (const void*)subject));
284
+ DBG_ASSERT(subject);
285
+ #endif
286
+
287
+ if( subject )
288
+ {
289
+ std::vector<const Subject*>::iterator attached_subject;
290
+ attached_subject = std::find(subjects_.begin(), subjects_.end(), subject);
291
+ #ifdef IP_DEBUG_OBSERVER
292
+
293
+ DBG_ASSERT(attached_subject != subjects_.end());
294
+ #endif
295
+
296
+ if( attached_subject != subjects_.end() )
297
+ {
298
+ #ifdef IP_DEBUG_OBSERVER
299
+ DBG_PRINT((1, "Removing subject: %p from the list\n", (const void*)subject));
300
+ #endif
301
+
302
+ subjects_.erase(attached_subject);
303
+ }
304
+
305
+ // Detach the observer from the subject
306
+ subject->DetachObserver(notify_type, this);
307
+ }
308
+ }
309
+
310
+ inline
311
+ void Observer::ProcessNotification(
312
+ NotifyType notify_type,
313
+ const Subject* subject
314
+ )
315
+ {
316
+ #ifdef IP_DEBUG_OBSERVER
317
+ DBG_START_METH("Observer::ProcessNotification", dbg_verbosity);
318
+ DBG_ASSERT(subject);
319
+ #endif
320
+
321
+ if( subject )
322
+ {
323
+ std::vector<const Subject*>::iterator attached_subject;
324
+ attached_subject = std::find(subjects_.begin(), subjects_.end(), subject);
325
+
326
+ // We must be processing a notification for a
327
+ // subject that was previously attached.
328
+ #ifdef IP_DEBUG_OBSERVER
329
+
330
+ DBG_ASSERT(attached_subject != subjects_.end());
331
+ #endif
332
+
333
+ this->ReceiveNotification(notify_type, subject);
334
+
335
+ if( notify_type == NT_BeingDestroyed )
336
+ {
337
+ // the subject is going away, remove it from our list
338
+ subjects_.erase(attached_subject);
339
+ }
340
+ }
341
+ }
342
+
343
+ inline Subject::~Subject()
344
+ {
345
+ #ifdef IP_DEBUG_OBSERVER
346
+ DBG_START_METH("Subject::~Subject", dbg_verbosity);
347
+ #endif
348
+
349
+ for( std::vector<Observer*>::iterator iter = observers_.begin(); iter != observers_.end(); ++iter )
350
+ {
351
+ (*iter)->ProcessNotification(Observer::NT_BeingDestroyed, this);
352
+ }
353
+ }
354
+
355
+ inline
356
+ void Subject::AttachObserver(
357
+ Observer::NotifyType /*notify_type*/,
358
+ Observer* observer
359
+ ) const
360
+ {
361
+ #ifdef IP_DEBUG_OBSERVER
362
+ DBG_START_METH("Subject::AttachObserver", dbg_verbosity);
363
+ // current implementation notifies all observers of everything
364
+ // they must filter the notifications that they are not interested
365
+ // in (i.e. a hub, not a router)
366
+ DBG_ASSERT(observer);
367
+
368
+ std::vector<Observer*>::iterator attached_observer;
369
+ attached_observer = std::find(observers_.begin(), observers_.end(), observer);
370
+ DBG_ASSERT(attached_observer == observers_.end());
371
+
372
+ DBG_ASSERT(observer);
373
+ #endif
374
+
375
+ observers_.push_back(observer);
376
+ }
377
+
378
+ inline
379
+ void Subject::DetachObserver(
380
+ Observer::NotifyType /*notify_type*/,
381
+ Observer* observer
382
+ ) const
383
+ {
384
+ #ifdef IP_DEBUG_OBSERVER
385
+ DBG_START_METH("Subject::DetachObserver", dbg_verbosity);
386
+ DBG_ASSERT(observer);
387
+ #endif
388
+
389
+ if( observer )
390
+ {
391
+ std::vector<Observer*>::iterator attached_observer;
392
+ attached_observer = std::find(observers_.begin(), observers_.end(), observer);
393
+ #ifdef IP_DEBUG_OBSERVER
394
+
395
+ DBG_ASSERT(attached_observer != observers_.end());
396
+ #endif
397
+
398
+ if( attached_observer != observers_.end() )
399
+ {
400
+ observers_.erase(attached_observer);
401
+ }
402
+ }
403
+ }
404
+
405
+ inline
406
+ void Subject::Notify(
407
+ Observer::NotifyType notify_type
408
+ ) const
409
+ {
410
+ #ifdef IP_DEBUG_OBSERVER
411
+ DBG_START_METH("Subject::Notify", dbg_verbosity);
412
+ #endif
413
+
414
+ for( std::vector<Observer*>::iterator iter = observers_.begin(); iter != observers_.end(); ++iter )
415
+ {
416
+ (*iter)->ProcessNotification(notify_type, this);
417
+ }
418
+ }
419
+
420
+ } // namespace Ipopt
421
+
422
+ #endif