CppADCodeGen 2.4.3
A C++ Algorithmic Differentiation Package with Source Code Generation
Loading...
Searching...
No Matches
llvm_model.hpp
1#ifndef CPPAD_CG_LLVM_MODEL_INCLUDED
2#define CPPAD_CG_LLVM_MODEL_INCLUDED
3/* --------------------------------------------------------------------------
4 * CppADCodeGen: C++ Algorithmic Differentiation with Source Code Generation:
5 * Copyright (C) 2013 Ciengis
6 * Copyright (C) 2018 Joao Leal
7 *
8 * CppADCodeGen is distributed under multiple licenses:
9 *
10 * - Eclipse Public License Version 1.0 (EPL1), and
11 * - GNU General Public License Version 3 (GPL3).
12 *
13 * EPL1 terms and conditions can be found in the file "epl-v10.txt", while
14 * terms and conditions for the GPL3 can be found in the file "gpl3.txt".
15 * ----------------------------------------------------------------------------
16 * Author: Joao Leal
17 */
18
19namespace CppAD {
20namespace cg {
21
27template<class Base>
28class LlvmModel : public FunctorGenericModel<Base> {
29protected:
32
33public:
34
35 LlvmModel(const LlvmModel&) = delete;
36 LlvmModel& operator=(const LlvmModel&) = delete;
37
38 virtual ~LlvmModel() {
39 if (_dynLib != nullptr) {
40 _dynLib->destroyed(this);
41 }
42 }
43
44protected:
45
52 const std::string& name) :
53 FunctorGenericModel<Base>(name),
54 _dynLib(dynLib) {
55
56 CPPADCG_ASSERT_UNKNOWN(_dynLib != nullptr);
57
58 this->init();
59 }
60
61 void* loadFunction(const std::string& functionName, bool required = true) override {
62 return _dynLib->loadFunction(functionName, required);
63 }
64
65 void modelLibraryClosed() override {
66 _dynLib = nullptr;
67 FunctorGenericModel<Base>::modelLibraryClosed();
68 }
69
70 friend class LlvmModelLibrary<Base>;
71};
72
73} // END cg namespace
74} // END CppAD namespace
75
76#endif
LlvmModel(LlvmModelLibrary< Base > *dynLib, const std::string &name)
LlvmModelLibrary< Base > * _dynLib
the dynamic library