-
Notifications
You must be signed in to change notification settings - Fork 436
Expand file tree
/
Copy pathcallback.cpp
More file actions
128 lines (107 loc) · 4.12 KB
/
callback.cpp
File metadata and controls
128 lines (107 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* This file is part of CasADi.
*
* CasADi -- A symbolic framework for dynamic optimization.
* Copyright (C) 2010-2023 Joel Andersson, Joris Gillis, Moritz Diehl,
* KU Leuven. All rights reserved.
* Copyright (C) 2011-2014 Greg Horn
*
* CasADi is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* CasADi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with CasADi; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "callback_internal.hpp"
namespace casadi {
Callback::Callback() {
}
Callback::Callback(const Callback& obj) : Function() { // NOLINT
casadi_error("Callback objects cannot be copied");
}
void Callback::construct(const std::string& name, const Dict& opts) {
if (!is_null()) {
casadi_error("Cannot create '" + name + "': Internal class already created");
}
own(new CallbackInternal(name, this));
(*this)->construct(opts);
}
Callback::~Callback() {
try {
// Make sure that this object isn't used after its deletion
if (!is_null()) get<CallbackInternal>()->self_ = nullptr;
} catch (...) {
casadi_warning("Problem in Callback destructor");
}
}
int Callback::eval_buffer(const double **arg, const std::vector<casadi_int>& sizes_arg,
double **res, const std::vector<casadi_int>& sizes_res) const {
casadi_error("eval_buffer not overloaded.");
}
bool Callback::has_eval_buffer() const {
return false;
}
std::vector<DM> Callback::eval(const std::vector<DM>& arg) const {
return (*this)->FunctionInternal::eval_dm(arg);
}
casadi_int Callback::get_n_in() {
return (*this)->FunctionInternal::get_n_in();
}
casadi_int Callback::get_n_out() {
return (*this)->FunctionInternal::get_n_out();
}
Sparsity Callback::get_sparsity_in(casadi_int i) {
return (*this)->FunctionInternal::get_sparsity_in(i);
}
Sparsity Callback::get_sparsity_out(casadi_int i) {
return (*this)->FunctionInternal::get_sparsity_out(i);
}
std::string Callback::get_name_in(casadi_int i) {
return (*this)->FunctionInternal::get_name_in(i);
}
std::string Callback::get_name_out(casadi_int i) {
return (*this)->FunctionInternal::get_name_out(i);
}
bool Callback::uses_output() const {
return (*this)->FunctionInternal::uses_output();
}
bool Callback::has_jacobian() const {
return (*this)->FunctionInternal::has_jacobian();
}
Function Callback::
get_jacobian(const std::string& name,
const std::vector<std::string>& inames,
const std::vector<std::string>& onames,
const Dict& opts) const {
return (*this)->FunctionInternal::get_jacobian(name, inames, onames, opts);
}
Function Callback::
get_forward(casadi_int nfwd, const std::string& name,
const std::vector<std::string>& inames,
const std::vector<std::string>& onames,
const Dict& opts) const {
return (*this)->FunctionInternal::get_forward(nfwd, name, inames, onames, opts);
}
bool Callback::has_forward(casadi_int nfwd) const {
return (*this)->FunctionInternal::has_forward(nfwd);
}
Function Callback::
get_reverse(casadi_int nadj, const std::string& name,
const std::vector<std::string>& inames,
const std::vector<std::string>& onames,
const Dict& opts) const {
return (*this)->FunctionInternal::get_reverse(nadj, name, inames, onames, opts);
}
bool Callback::has_reverse(casadi_int nadj) const {
return (*this)->FunctionInternal::has_reverse(nadj);
}
} // namespace casadi