Loading...
Searching...
No Matches
ZoneManager.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
16public abstract class ZoneManager {
25 public abstract void addZoneListener(ZoneListener listener);
26
33 public abstract void removeZoneListener(ZoneListener listener);
34
35 private static final class CppProxy extends ZoneManager
36 {
37 private final long nativeRef;
38 private final AtomicBoolean destroyed = new AtomicBoolean(false);
39
40 private CppProxy(long nativeRef)
41 {
42 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
43 this.nativeRef = nativeRef;
44 }
45
46 private native void nativeDestroy(long nativeRef);
47 public void _djinni_private_destroy()
48 {
49 boolean destroyed = this.destroyed.getAndSet(true);
50 if (!destroyed) nativeDestroy(this.nativeRef);
51 }
52 protected void finalize() throws java.lang.Throwable
53 {
54 _djinni_private_destroy();
55 super.finalize();
56 }
57
58 // ZoneManager methods
59
60 @Override
61 public void addZoneListener(ZoneListener listener)
62 {
63 assert !this.destroyed.get() : "trying to use a destroyed object";
64 native_addZoneListener(this.nativeRef, listener);
65 }
66 private native void native_addZoneListener(long _nativeRef, ZoneListener listener);
67
68 @Override
69 public void removeZoneListener(ZoneListener listener)
70 {
71 assert !this.destroyed.get() : "trying to use a destroyed object";
72 native_removeZoneListener(this.nativeRef, listener);
73 }
74 private native void native_removeZoneListener(long _nativeRef, ZoneListener listener);
75 }
76}