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