00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef ___HxCorbaConfigure_tie_h__
00016 #define ___HxCorbaConfigure_tie_h__
00017
00018 #include <HxCorbaConfigure_skel.h>
00019
00020 #ifndef OB_INTEGER_VERSION
00021 # error No ORBacus version defined! Is <OB/CORBA.h> included?
00022 #endif
00023
00024 #ifndef OB_NO_VERSION_CHECK
00025 # if (OB_INTEGER_VERSION != 4010000L)
00026 # error ORBacus version mismatch!
00027 # endif
00028 #endif
00029
00030
00031
00032
00033 namespace POA_HxCorba
00034 {
00035
00036
00037
00038
00039 template<class T>
00040 class ObjectUsage_tie : virtual public ObjectUsage
00041 {
00042 T* ptr_;
00043 PortableServer::POA_ptr poa_;
00044 CORBA::Boolean rel_;
00045
00046 ObjectUsage_tie(const ObjectUsage_tie<T>&) { }
00047 void operator=(const ObjectUsage_tie<T>&) { }
00048
00049 public:
00050
00051 ObjectUsage_tie(T& t)
00052 : ptr_(&t), poa_(PortableServer::POA::_nil()), rel_(false)
00053 {
00054 }
00055
00056 ObjectUsage_tie(T& t, PortableServer::POA_ptr poa)
00057 : ptr_(&t), poa_(PortableServer::POA::_duplicate(poa)), rel_(false)
00058 {
00059 }
00060
00061 ObjectUsage_tie(T* p, CORBA::Boolean release = true)
00062 : ptr_(p), poa_(PortableServer::POA::_nil()), rel_(release)
00063 {
00064 }
00065
00066 ObjectUsage_tie(T* p, PortableServer::POA_ptr poa, CORBA::Boolean release = true)
00067 : ptr_(p), poa_(PortableServer::POA::_duplicate(poa)), rel_(release)
00068 {
00069 }
00070
00071 virtual
00072 ~ObjectUsage_tie()
00073 {
00074 if(rel_)
00075 delete ptr_;
00076
00077 CORBA::release(poa_);
00078 }
00079
00080 T*
00081 _tied_object()
00082 {
00083 return ptr_;
00084 }
00085
00086 void
00087 _tied_object(T& obj)
00088 {
00089 if(rel_)
00090 delete ptr_;
00091
00092 ptr_ = &obj;
00093 rel_ = false;
00094 }
00095
00096 void
00097 _tied_object(T* obj, CORBA::Boolean release = true)
00098 {
00099 if(rel_)
00100 delete ptr_;
00101
00102 ptr_ = obj;
00103 rel_ = release;
00104 }
00105
00106 CORBA::Boolean
00107 _is_owner()
00108 {
00109 return rel_;
00110 }
00111
00112 void
00113 _is_owner(CORBA::Boolean b)
00114 {
00115 rel_ = b;
00116 }
00117
00118 virtual CORBA::Long
00119 getUsed(const char* unit)
00120 throw(CORBA::SystemException)
00121 {
00122 return ptr_ -> getUsed(unit);
00123 }
00124
00125 virtual CORBA::Long
00126 getTotalLimit(const char* unit)
00127 throw(CORBA::SystemException)
00128 {
00129 return ptr_ -> getTotalLimit(unit);
00130 }
00131
00132 virtual void
00133 setTotalLimit(const char* unit,
00134 CORBA::Long limit)
00135 throw(CORBA::SystemException)
00136 {
00137 ptr_ -> setTotalLimit(unit, limit);
00138 }
00139
00140 virtual CORBA::Long
00141 getObjectLimit(const char* unit)
00142 throw(CORBA::SystemException)
00143 {
00144 return ptr_ -> getObjectLimit(unit);
00145 }
00146
00147 virtual void
00148 setObjectLimit(const char* unit,
00149 CORBA::Long limit)
00150 throw(CORBA::SystemException)
00151 {
00152 ptr_ -> setObjectLimit(unit, limit);
00153 }
00154
00155 virtual HxCorba::StringSeq*
00156 listUnits()
00157 throw(CORBA::SystemException)
00158 {
00159 return ptr_ -> listUnits();
00160 }
00161
00162 virtual void
00163 close()
00164 throw(CORBA::SystemException)
00165 {
00166 ptr_ -> close();
00167 }
00168
00169 PortableServer::POA_ptr _default_POA()
00170 {
00171 if(!CORBA::is_nil(poa_))
00172 return PortableServer::POA::_duplicate(poa_);
00173 else
00174 return ObjectUsage::_default_POA();
00175 }
00176 };
00177
00178
00179
00180
00181 template<class T>
00182 class Configure_tie : virtual public Configure
00183 {
00184 T* ptr_;
00185 PortableServer::POA_ptr poa_;
00186 CORBA::Boolean rel_;
00187
00188 Configure_tie(const Configure_tie<T>&) { }
00189 void operator=(const Configure_tie<T>&) { }
00190
00191 public:
00192
00193 Configure_tie(T& t)
00194 : ptr_(&t), poa_(PortableServer::POA::_nil()), rel_(false)
00195 {
00196 }
00197
00198 Configure_tie(T& t, PortableServer::POA_ptr poa)
00199 : ptr_(&t), poa_(PortableServer::POA::_duplicate(poa)), rel_(false)
00200 {
00201 }
00202
00203 Configure_tie(T* p, CORBA::Boolean release = true)
00204 : ptr_(p), poa_(PortableServer::POA::_nil()), rel_(release)
00205 {
00206 }
00207
00208 Configure_tie(T* p, PortableServer::POA_ptr poa, CORBA::Boolean release = true)
00209 : ptr_(p), poa_(PortableServer::POA::_duplicate(poa)), rel_(release)
00210 {
00211 }
00212
00213 virtual
00214 ~Configure_tie()
00215 {
00216 if(rel_)
00217 delete ptr_;
00218
00219 CORBA::release(poa_);
00220 }
00221
00222 T*
00223 _tied_object()
00224 {
00225 return ptr_;
00226 }
00227
00228 void
00229 _tied_object(T& obj)
00230 {
00231 if(rel_)
00232 delete ptr_;
00233
00234 ptr_ = &obj;
00235 rel_ = false;
00236 }
00237
00238 void
00239 _tied_object(T* obj, CORBA::Boolean release = true)
00240 {
00241 if(rel_)
00242 delete ptr_;
00243
00244 ptr_ = obj;
00245 rel_ = release;
00246 }
00247
00248 CORBA::Boolean
00249 _is_owner()
00250 {
00251 return rel_;
00252 }
00253
00254 void
00255 _is_owner(CORBA::Boolean b)
00256 {
00257 rel_ = b;
00258 }
00259
00260 virtual void
00261 shutdown()
00262 throw(CORBA::SystemException)
00263 {
00264 ptr_ -> shutdown();
00265 }
00266
00267 virtual HxCorba::ObjectUsage_ptr
00268 getDefaultObjectUsage()
00269 throw(CORBA::SystemException)
00270 {
00271 return ptr_ -> getDefaultObjectUsage();
00272 }
00273
00274 virtual HxCorba::ObjectUsage_ptr
00275 getObjectUsage(const char* name)
00276 throw(CORBA::SystemException)
00277 {
00278 return ptr_ -> getObjectUsage(name);
00279 }
00280
00281 virtual HxCorba::StringSeq*
00282 listObjectUsages()
00283 throw(CORBA::SystemException)
00284 {
00285 return ptr_ -> listObjectUsages();
00286 }
00287
00288 PortableServer::POA_ptr _default_POA()
00289 {
00290 if(!CORBA::is_nil(poa_))
00291 return PortableServer::POA::_duplicate(poa_);
00292 else
00293 return Configure::_default_POA();
00294 }
00295 };
00296
00297 }
00298
00299 #endif