Loading...
Searching...
No Matches
Graph.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.ArrayList;
4import java.util.concurrent.atomic.AtomicBoolean;
5
19public abstract class Graph {
32 public abstract ArrayList<GraphVertex> getVertexes();
33
45 public abstract ArrayList<GraphEdge> getEdges();
46
47 private static final class CppProxy extends Graph
48 {
49 private final long nativeRef;
50 private final AtomicBoolean destroyed = new AtomicBoolean(false);
51
52 private CppProxy(long nativeRef)
53 {
54 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
55 this.nativeRef = nativeRef;
56 }
57
58 private native void nativeDestroy(long nativeRef);
59 public void _djinni_private_destroy()
60 {
61 boolean destroyed = this.destroyed.getAndSet(true);
62 if (!destroyed) nativeDestroy(this.nativeRef);
63 }
64 protected void finalize() throws java.lang.Throwable
65 {
66 _djinni_private_destroy();
67 super.finalize();
68 }
69
70 // Graph methods
71
72 @Override
73 public ArrayList<GraphVertex> getVertexes()
74 {
75 assert !this.destroyed.get() : "trying to use a destroyed object";
76 return native_getVertexes(this.nativeRef);
77 }
78 private native ArrayList<GraphVertex> native_getVertexes(long _nativeRef);
79
80 @Override
81 public ArrayList<GraphEdge> getEdges()
82 {
83 assert !this.destroyed.get() : "trying to use a destroyed object";
84 return native_getEdges(this.nativeRef);
85 }
86 private native ArrayList<GraphEdge> native_getEdges(long _nativeRef);
87 }
88}