Codemesh Runtime v3 C++ API Reference  3.9.205
xmog_remote_ref_map.h
1 //
2 // Copyright (c) 1999-2020 by Codemesh, Inc.. ALL RIGHTS RESERVED.
3 //
4 
5 #ifndef xmogRemoteRefMapInc
6 #define xmogRemoteRefMapInc
7 
8 
9 #include "xmog.h"
10 
11 
12 #if (XMOG_IMPLEMENTS_REMOTE_CLIENT==1)
13 
14 
15 #include "ace/Map_Manager.h"
16 #include "ace/Recursive_Thread_Mutex.h"
17 #include "ace/Null_Mutex.h"
18 
19 
21 {
22  jint refCount_;
23  void * data_;
24  size_t size_;
25 
26 public:
27 
28  xmog_remote_ref( void * data = NULL, size_t size = (size_t)-1 ) : refCount_( 1 ), data_( data ), size_( size ) {}
29  xmog_remote_ref( const xmog_remote_ref & rhs );
30  xmog_remote_ref( const xmog_remote_ref * src, jint refCount );
31  ~xmog_remote_ref();
32  xmog_remote_ref & operator = ( const xmog_remote_ref & );
33 
34  void inc() { refCount_++; };
35  jint dec() { return --refCount_; }
36  size_t size() const { return size_; }
37  void * data() const { return data_; }
38 };
39 
45 {
46 public:
47 
48  typedef jobject Key;
49  typedef xmog_remote_ref* Value;
50  typedef ACE_Map_Manager<Key,Value,ACE_Null_Mutex> ObjectFrame;
51 
52 private:
53 
54  ObjectFrame * globals_;
55 
56  bool bOwnsGlobals_;
57 
58  ObjectFrame * weak_globals_;
59 
60  bool bOwnsWeakGlobals_;
61 
62  ObjectFrame * locals_;
63 
64  bool bOwnsLocals_;
65 
66  xmog_remote_ref_map * parent_;
67 
68 public:
69 
74 
76 
80  int get_data( jobject _ref, void ** pData, size_t * pLength );
81 
87  int delete_global( jobject _ref );
88 
92  jobject new_global( jobject _ref, void * data = NULL, size_t size = 0 );
93 
99  int delete_local( jobject _ref );
100 
104  jobject new_local( jobject _ref, void * data = NULL, size_t size = 0 );
105 
111  int delete_weakglobal( jobject _ref );
112 
116  jobject new_weakglobal( jobject _ref, void * data = NULL, size_t size = 0 );
117 
122 
127 };
128 
129 #endif /* (XMOG_IMPLEMENTS_REMOTE_CLIENT==1) */
130 
131 
132 #endif /* xmogRemoteRefMapInc */
xmog_remote_ref
Definition: xmog_remote_ref_map.h:20
xmog_remote_ref_map::new_global
jobject new_global(jobject _ref, void *data=NULL, size_t size=0)
Adds a global reference to the map.
xmog_remote_ref_map::delete_global
int delete_global(jobject _ref)
Deletes a global reference from the map.
xmog_remote_ref_map::new_weakglobal
jobject new_weakglobal(jobject _ref, void *data=NULL, size_t size=0)
Adds a weak global reference to the map.
xmog_remote_ref_map
A utility class that tracks remote object references with a reference count.
Definition: xmog_remote_ref_map.h:44
xmog_remote_ref_map::get_data
int get_data(jobject _ref, void **pData, size_t *pLength)
Returns the cached data associated with a reference.
xmog_remote_ref_map::xmog_remote_ref_map
xmog_remote_ref_map(xmog_remote_ref_map *parentFrame)
Constructs a reference map.
xmog_remote_ref_map::new_local
jobject new_local(jobject _ref, void *data=NULL, size_t size=0)
Adds a local reference to the map.
xmog_remote_ref_map::delete_local
int delete_local(jobject _ref)
Deletes a local reference from the map.
xmog_remote_ref_map::pop_frame
xmog_remote_ref_map * pop_frame()
Pops a frame from the stack and returns the parent frame.
xmog_remote_ref_map::push_frame
xmog_remote_ref_map * push_frame()
Pushes a new frame on the stack and returns the new frame.
xmog_remote_ref_map::delete_weakglobal
int delete_weakglobal(jobject _ref)
Deletes a weak global reference from the map.

Copyright (c) 1999-2020 by Codemesh, Inc., ALL RIGHTS RESERVED.