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 {
29 public abstract float getWeight();
30
43 public abstract int getDst();
44
57 public abstract int getSrc();
58
71 public abstract int getWeightCoef();
72
73 private static final class CppProxy extends GraphEdge
74 {
75 private final long nativeRef;
76 private final AtomicBoolean destroyed = new AtomicBoolean(false);
77
78 private CppProxy(long nativeRef)
79 {
80 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
81 this.nativeRef = nativeRef;
82 }
83
84 private native void nativeDestroy(long nativeRef);
85 public void _djinni_private_destroy()
86 {
87 boolean destroyed = this.destroyed.getAndSet(true);
88 if (!destroyed) nativeDestroy(this.nativeRef);
89 }
90 protected void finalize() throws java.lang.Throwable
91 {
92 _djinni_private_destroy();
93 super.finalize();
94 }
95
96 // GraphEdge methods
97
98 @Override
99 public float getWeight()
100 {
101 assert !this.destroyed.get() : "trying to use a destroyed object";
102 return native_getWeight(this.nativeRef);
103 }
104 private native float native_getWeight(long _nativeRef);
105
106 @Override
107 public int getDst()
108 {
109 assert !this.destroyed.get() : "trying to use a destroyed object";
110 return native_getDst(this.nativeRef);
111 }
112 private native int native_getDst(long _nativeRef);
113
114 @Override
115 public int getSrc()
116 {
117 assert !this.destroyed.get() : "trying to use a destroyed object";
118 return native_getSrc(this.nativeRef);
119 }
120 private native int native_getSrc(long _nativeRef);
121
122 @Override
123 public int getWeightCoef()
124 {
125 assert !this.destroyed.get() : "trying to use a destroyed object";
126 return native_getWeightCoef(this.nativeRef);
127 }
128 private native int native_getWeightCoef(long _nativeRef);
129 }
130}