00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef ___HxCorbaTagList_tie_h__
00016 #define ___HxCorbaTagList_tie_h__
00017
00018 #include <HxCorbaTagList_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 TagList_tie : virtual public TagList
00041 {
00042 T* ptr_;
00043 PortableServer::POA_ptr poa_;
00044 CORBA::Boolean rel_;
00045
00046 TagList_tie(const TagList_tie<T>&) { }
00047 void operator=(const TagList_tie<T>&) { }
00048
00049 public:
00050
00051 TagList_tie(T& t)
00052 : ptr_(&t), poa_(PortableServer::POA::_nil()), rel_(false)
00053 {
00054 }
00055
00056 TagList_tie(T& t, PortableServer::POA_ptr poa)
00057 : ptr_(&t), poa_(PortableServer::POA::_duplicate(poa)), rel_(false)
00058 {
00059 }
00060
00061 TagList_tie(T* p, CORBA::Boolean release = true)
00062 : ptr_(p), poa_(PortableServer::POA::_nil()), rel_(release)
00063 {
00064 }
00065
00066 TagList_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 ~TagList_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 void
00119 addInt(const char* name,
00120 CORBA::Long val)
00121 throw(CORBA::SystemException)
00122 {
00123 ptr_ -> addInt(name, val);
00124 }
00125
00126 virtual CORBA::Long
00127 getInt(const char* name)
00128 throw(CORBA::SystemException)
00129 {
00130 return ptr_ -> getInt(name);
00131 }
00132
00133 virtual void
00134 addFloat(const char* name,
00135 CORBA::Double val)
00136 throw(CORBA::SystemException)
00137 {
00138 ptr_ -> addFloat(name, val);
00139 }
00140
00141 virtual CORBA::Double
00142 getFloat(const char* name)
00143 throw(CORBA::SystemException)
00144 {
00145 return ptr_ -> getFloat(name);
00146 }
00147
00148 virtual void
00149 addValue(const char* name,
00150 const HxCorba::PixValue& val)
00151 throw(CORBA::SystemException)
00152 {
00153 ptr_ -> addValue(name, val);
00154 }
00155
00156 virtual HxCorba::PixValue
00157 getValue(const char* name)
00158 throw(CORBA::SystemException)
00159 {
00160 return ptr_ -> getValue(name);
00161 }
00162
00163 PortableServer::POA_ptr _default_POA()
00164 {
00165 if(!CORBA::is_nil(poa_))
00166 return PortableServer::POA::_duplicate(poa_);
00167 else
00168 return TagList::_default_POA();
00169 }
00170 };
00171
00172
00173
00174
00175 template<class T>
00176 class TagListFactory_tie : virtual public TagListFactory
00177 {
00178 T* ptr_;
00179 PortableServer::POA_ptr poa_;
00180 CORBA::Boolean rel_;
00181
00182 TagListFactory_tie(const TagListFactory_tie<T>&) { }
00183 void operator=(const TagListFactory_tie<T>&) { }
00184
00185 public:
00186
00187 TagListFactory_tie(T& t)
00188 : ptr_(&t), poa_(PortableServer::POA::_nil()), rel_(false)
00189 {
00190 }
00191
00192 TagListFactory_tie(T& t, PortableServer::POA_ptr poa)
00193 : ptr_(&t), poa_(PortableServer::POA::_duplicate(poa)), rel_(false)
00194 {
00195 }
00196
00197 TagListFactory_tie(T* p, CORBA::Boolean release = true)
00198 : ptr_(p), poa_(PortableServer::POA::_nil()), rel_(release)
00199 {
00200 }
00201
00202 TagListFactory_tie(T* p, PortableServer::POA_ptr poa, CORBA::Boolean release = true)
00203 : ptr_(p), poa_(PortableServer::POA::_duplicate(poa)), rel_(release)
00204 {
00205 }
00206
00207 virtual
00208 ~TagListFactory_tie()
00209 {
00210 if(rel_)
00211 delete ptr_;
00212
00213 CORBA::release(poa_);
00214 }
00215
00216 T*
00217 _tied_object()
00218 {
00219 return ptr_;
00220 }
00221
00222 void
00223 _tied_object(T& obj)
00224 {
00225 if(rel_)
00226 delete ptr_;
00227
00228 ptr_ = &obj;
00229 rel_ = false;
00230 }
00231
00232 void
00233 _tied_object(T* obj, CORBA::Boolean release = true)
00234 {
00235 if(rel_)
00236 delete ptr_;
00237
00238 ptr_ = obj;
00239 rel_ = release;
00240 }
00241
00242 CORBA::Boolean
00243 _is_owner()
00244 {
00245 return rel_;
00246 }
00247
00248 void
00249 _is_owner(CORBA::Boolean b)
00250 {
00251 rel_ = b;
00252 }
00253
00254 virtual HxCorba::TagList_ptr
00255 emptyTagList()
00256 throw(CORBA::SystemException)
00257 {
00258 return ptr_ -> emptyTagList();
00259 }
00260
00261 virtual HxCorba::TagList_ptr
00262 simpleIntTag(const char* name,
00263 CORBA::Long val)
00264 throw(CORBA::SystemException)
00265 {
00266 return ptr_ -> simpleIntTag(name, val);
00267 }
00268
00269 virtual HxCorba::TagList_ptr
00270 simpleFloatTag(const char* name,
00271 CORBA::Double val)
00272 throw(CORBA::SystemException)
00273 {
00274 return ptr_ -> simpleFloatTag(name, val);
00275 }
00276
00277 PortableServer::POA_ptr _default_POA()
00278 {
00279 if(!CORBA::is_nil(poa_))
00280 return PortableServer::POA::_duplicate(poa_);
00281 else
00282 return TagListFactory::_default_POA();
00283 }
00284 };
00285
00286 }
00287
00288 #endif