Mercurial > hg > orthanc-java
comparison CodeGeneration/JavaClass.mustache @ 0:3ecef5782f2c
initial commit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 18 Oct 2023 17:59:44 +0200 |
parents | |
children | 26c08ff926a3 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3ecef5782f2c |
---|---|
1 package be.uclouvain.orthanc; | |
2 | |
3 /** | |
4 * SPDX-FileCopyrightText: 2023 Sebastien Jodogne, UCLouvain, Belgium | |
5 * SPDX-License-Identifier: GPL-3.0-or-later | |
6 */ | |
7 | |
8 /** | |
9 * Java plugin for Orthanc | |
10 * Copyright (C) 2023 Sebastien Jodogne, UCLouvain, Belgium | |
11 * | |
12 * This program is free software: you can redistribute it and/or | |
13 * modify it under the terms of the GNU General Public License as | |
14 * published by the Free Software Foundation, either version 3 of the | |
15 * License, or (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, but | |
18 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 * General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program. If not, see http://www.gnu.org/licenses/. | |
24 **/ | |
25 | |
26 | |
27 {{#has_documentation}} | |
28 /** | |
29 * {{documentation}} | |
30 **/ | |
31 {{/has_documentation}} | |
32 public class {{class_name}} { | |
33 private long self; | |
34 | |
35 /** | |
36 * Construct a Java object wrapping a C object that is managed by Orthanc. | |
37 * @param self Pointer to the C object. | |
38 **/ | |
39 protected {{class_name}}(long self) { | |
40 if (self == 0) { | |
41 throw new IllegalArgumentException("Null pointer"); | |
42 } else { | |
43 this.self = self; | |
44 } | |
45 } | |
46 | |
47 /** | |
48 * Return the C object that is associated with this Java wrapper. | |
49 * @return Pointer to the C object. | |
50 **/ | |
51 protected long getSelf() { | |
52 return self; | |
53 } | |
54 | |
55 {{#destructor}} | |
56 @Override | |
57 protected void finalize() throws Throwable { | |
58 dispose(); | |
59 super.finalize(); | |
60 } | |
61 | |
62 /** | |
63 * Manually deallocate the C object that is associated with this Java wrapper. | |
64 * | |
65 * This method can be used to immediately deallocate the C object, | |
66 * instead of waiting for the garbage collector to dispose the Java wrapper. | |
67 **/ | |
68 public void dispose() { | |
69 if (self != 0) { | |
70 NativeSDK.{{destructor}}(self); | |
71 self = 0; | |
72 } | |
73 } | |
74 {{/destructor}} | |
75 | |
76 {{#constructors}} | |
77 {{#has_documentation}} | |
78 /** | |
79 {{#documentation}} | |
80 * {{line}} | |
81 {{/documentation}} | |
82 **/ | |
83 {{/has_documentation}} | |
84 public static {{return.java_wrapper_type}} {{java_name}}({{#args}} | |
85 {{java_wrapper_type}} {{sdk_name}}{{^last}},{{/last}}{{/args}}) { | |
86 return new {{return.java_wrapper_type}}(NativeSDK.{{c_function}}({{#args}}{{java_wrapper_accessor}}{{^last}}, {{/last}}{{/args}}){{java_return_end}}; | |
87 } | |
88 | |
89 {{/constructors}} | |
90 | |
91 {{#methods}} | |
92 {{#has_documentation}} | |
93 /** | |
94 {{#documentation}} | |
95 * {{line}} | |
96 {{/documentation}} | |
97 **/ | |
98 {{/has_documentation}} | |
99 public {{return.java_wrapper_type}} {{java_name}}({{#args}} | |
100 {{java_wrapper_type}} {{sdk_name}}{{^last}},{{/last}}{{/args}}) { | |
101 {{java_return_start}}NativeSDK.{{c_function}}(self{{#has_args}}, {{/has_args}}{{#args}}{{java_wrapper_accessor}}{{^last}}, {{/last}}{{/args}}){{java_return_end}}; | |
102 } | |
103 | |
104 {{/methods}} | |
105 } |