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 {
23 public abstract ArrayList<GraphVertex> getVertexes();
24
28 public abstract ArrayList<GraphEdge> getEdges();
29
30 private static final class CppProxy extends Graph
31 {
32 private final long nativeRef;
33 private final AtomicBoolean destroyed = new AtomicBoolean(false);
34
35 private CppProxy(long nativeRef)
36 {
37 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
38 this.nativeRef = nativeRef;
39 }
40
41 private native void nativeDestroy(long nativeRef);
42 public void _djinni_private_destroy()
43 {
44 boolean destroyed = this.destroyed.getAndSet(true);
45 if (!destroyed) nativeDestroy(this.nativeRef);
46 }
47 protected void finalize() throws java.lang.Throwable
48 {
49 _djinni_private_destroy();
50 super.finalize();
51 }
52
53 // Graph methods
54
55 @Override
56 public ArrayList<GraphVertex> getVertexes()
57 {
58 assert !this.destroyed.get() : "trying to use a destroyed object";
59 return native_getVertexes(this.nativeRef);
60 }
61 private native ArrayList<GraphVertex> native_getVertexes(long _nativeRef);
62
63 @Override
64 public ArrayList<GraphEdge> getEdges()
65 {
66 assert !this.destroyed.get() : "trying to use a destroyed object";
67 return native_getEdges(this.nativeRef);
68 }
69 private native ArrayList<GraphEdge> native_getEdges(long _nativeRef);
70 }
71}