Loading...
Searching...
No Matches
AsyncRouteManager.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
16public abstract class AsyncRouteManager {
33 public abstract RouteSession createRouteSession(LocationPoint wayPoint, RouteOptions routeOptions);
34
58 public abstract RouteSession createRouteSessionWithTag(LocationPoint wayPoint, RouteOptions routeOptions, String tag);
59
74 public abstract void cancelRouteSession(RouteSession session);
75
76 private static final class CppProxy extends AsyncRouteManager
77 {
78 private final long nativeRef;
79 private final AtomicBoolean destroyed = new AtomicBoolean(false);
80
81 private CppProxy(long nativeRef)
82 {
83 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
84 this.nativeRef = nativeRef;
85 }
86
87 private native void nativeDestroy(long nativeRef);
88 public void _djinni_private_destroy()
89 {
90 boolean destroyed = this.destroyed.getAndSet(true);
91 if (!destroyed) nativeDestroy(this.nativeRef);
92 }
93 protected void finalize() throws java.lang.Throwable
94 {
95 _djinni_private_destroy();
96 super.finalize();
97 }
98
99 // AsyncRouteManager methods
100
101 @Override
102 public RouteSession createRouteSession(LocationPoint wayPoint, RouteOptions routeOptions)
103 {
104 assert !this.destroyed.get() : "trying to use a destroyed object";
105 return native_createRouteSession(this.nativeRef, wayPoint, routeOptions);
106 }
107 private native RouteSession native_createRouteSession(long _nativeRef, LocationPoint wayPoint, RouteOptions routeOptions);
108
109 @Override
110 public RouteSession createRouteSessionWithTag(LocationPoint wayPoint, RouteOptions routeOptions, String tag)
111 {
112 assert !this.destroyed.get() : "trying to use a destroyed object";
113 return native_createRouteSessionWithTag(this.nativeRef, wayPoint, routeOptions, tag);
114 }
115 private native RouteSession native_createRouteSessionWithTag(long _nativeRef, LocationPoint wayPoint, RouteOptions routeOptions, String tag);
116
117 @Override
118 public void cancelRouteSession(RouteSession session)
119 {
120 assert !this.destroyed.get() : "trying to use a destroyed object";
121 native_cancelRouteSession(this.nativeRef, session);
122 }
123 private native void native_cancelRouteSession(long _nativeRef, RouteSession session);
124 }
125}