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 {
33 public abstract ArrayList<GraphVertex> getVertexes();
34
48 public abstract ArrayList<GraphEdge> getEdges();
49
50 private static final class CppProxy extends Graph
51 {
52 private final long nativeRef;
53 private final AtomicBoolean destroyed = new AtomicBoolean(false);
54
55 private CppProxy(long nativeRef)
56 {
57 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
58 this.nativeRef = nativeRef;
59 }
60
61 private native void nativeDestroy(long nativeRef);
62 public void _djinni_private_destroy()
63 {
64 boolean destroyed = this.destroyed.getAndSet(true);
65 if (!destroyed) nativeDestroy(this.nativeRef);
66 }
67 protected void finalize() throws java.lang.Throwable
68 {
69 _djinni_private_destroy();
70 super.finalize();
71 }
72
73 // Graph methods
74
75 @Override
76 public ArrayList<GraphVertex> getVertexes()
77 {
78 assert !this.destroyed.get() : "trying to use a destroyed object";
79 return native_getVertexes(this.nativeRef);
80 }
81 private native ArrayList<GraphVertex> native_getVertexes(long _nativeRef);
82
83 @Override
84 public ArrayList<GraphEdge> getEdges()
85 {
86 assert !this.destroyed.get() : "trying to use a destroyed object";
87 return native_getEdges(this.nativeRef);
88 }
89 private native ArrayList<GraphEdge> native_getEdges(long _nativeRef);
90 }
91}