Loading...
Searching...
No Matches
GraphEdge.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
16public abstract class GraphEdge {
20 public abstract float getWeight();
21
25 public abstract int getDst();
26
30 public abstract int getSrc();
31
35 public abstract int getWeightCoef();
36
37 private static final class CppProxy extends GraphEdge
38 {
39 private final long nativeRef;
40 private final AtomicBoolean destroyed = new AtomicBoolean(false);
41
42 private CppProxy(long nativeRef)
43 {
44 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
45 this.nativeRef = nativeRef;
46 }
47
48 private native void nativeDestroy(long nativeRef);
49 public void _djinni_private_destroy()
50 {
51 boolean destroyed = this.destroyed.getAndSet(true);
52 if (!destroyed) nativeDestroy(this.nativeRef);
53 }
54 protected void finalize() throws java.lang.Throwable
55 {
56 _djinni_private_destroy();
57 super.finalize();
58 }
59
60 // GraphEdge methods
61
62 @Override
63 public float getWeight()
64 {
65 assert !this.destroyed.get() : "trying to use a destroyed object";
66 return native_getWeight(this.nativeRef);
67 }
68 private native float native_getWeight(long _nativeRef);
69
70 @Override
71 public int getDst()
72 {
73 assert !this.destroyed.get() : "trying to use a destroyed object";
74 return native_getDst(this.nativeRef);
75 }
76 private native int native_getDst(long _nativeRef);
77
78 @Override
79 public int getSrc()
80 {
81 assert !this.destroyed.get() : "trying to use a destroyed object";
82 return native_getSrc(this.nativeRef);
83 }
84 private native int native_getSrc(long _nativeRef);
85
86 @Override
87 public int getWeightCoef()
88 {
89 assert !this.destroyed.get() : "trying to use a destroyed object";
90 return native_getWeightCoef(this.nativeRef);
91 }
92 private native int native_getWeightCoef(long _nativeRef);
93 }
94}