00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef ___HxCorbaVideoWriter_tie_h__
00016 #define ___HxCorbaVideoWriter_tie_h__
00017
00018 #include <HxCorbaVideoWriter_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 VideoWriter_tie : virtual public VideoWriter
00041 {
00042 T* ptr_;
00043 PortableServer::POA_ptr poa_;
00044 CORBA::Boolean rel_;
00045
00046 VideoWriter_tie(const VideoWriter_tie<T>&) { }
00047 void operator=(const VideoWriter_tie<T>&) { }
00048
00049 public:
00050
00051 VideoWriter_tie(T& t)
00052 : ptr_(&t), poa_(PortableServer::POA::_nil()), rel_(false)
00053 {
00054 }
00055
00056 VideoWriter_tie(T& t, PortableServer::POA_ptr poa)
00057 : ptr_(&t), poa_(PortableServer::POA::_duplicate(poa)), rel_(false)
00058 {
00059 }
00060
00061 VideoWriter_tie(T* p, CORBA::Boolean release = true)
00062 : ptr_(p), poa_(PortableServer::POA::_nil()), rel_(release)
00063 {
00064 }
00065
00066 VideoWriter_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 ~VideoWriter_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 putFrame(CORBA::Octet r,
00120 CORBA::Octet g,
00121 CORBA::Octet b)
00122 throw(CORBA::SystemException)
00123 {
00124 ptr_ -> putFrame(r, g, b);
00125 }
00126
00127 virtual void
00128 putImage(HxCorba::ImageRep_ptr img,
00129 const char* mode)
00130 throw(CORBA::SystemException)
00131 {
00132 ptr_ -> putImage(img, mode);
00133 }
00134
00135 virtual void
00136 closeVideo()
00137 throw(CORBA::SystemException)
00138 {
00139 ptr_ -> closeVideo();
00140 }
00141
00142 PortableServer::POA_ptr _default_POA()
00143 {
00144 if(!CORBA::is_nil(poa_))
00145 return PortableServer::POA::_duplicate(poa_);
00146 else
00147 return VideoWriter::_default_POA();
00148 }
00149 };
00150
00151
00152
00153
00154 template<class T>
00155 class VideoWriterFactory_tie : virtual public VideoWriterFactory
00156 {
00157 T* ptr_;
00158 PortableServer::POA_ptr poa_;
00159 CORBA::Boolean rel_;
00160
00161 VideoWriterFactory_tie(const VideoWriterFactory_tie<T>&) { }
00162 void operator=(const VideoWriterFactory_tie<T>&) { }
00163
00164 public:
00165
00166 VideoWriterFactory_tie(T& t)
00167 : ptr_(&t), poa_(PortableServer::POA::_nil()), rel_(false)
00168 {
00169 }
00170
00171 VideoWriterFactory_tie(T& t, PortableServer::POA_ptr poa)
00172 : ptr_(&t), poa_(PortableServer::POA::_duplicate(poa)), rel_(false)
00173 {
00174 }
00175
00176 VideoWriterFactory_tie(T* p, CORBA::Boolean release = true)
00177 : ptr_(p), poa_(PortableServer::POA::_nil()), rel_(release)
00178 {
00179 }
00180
00181 VideoWriterFactory_tie(T* p, PortableServer::POA_ptr poa, CORBA::Boolean release = true)
00182 : ptr_(p), poa_(PortableServer::POA::_duplicate(poa)), rel_(release)
00183 {
00184 }
00185
00186 virtual
00187 ~VideoWriterFactory_tie()
00188 {
00189 if(rel_)
00190 delete ptr_;
00191
00192 CORBA::release(poa_);
00193 }
00194
00195 T*
00196 _tied_object()
00197 {
00198 return ptr_;
00199 }
00200
00201 void
00202 _tied_object(T& obj)
00203 {
00204 if(rel_)
00205 delete ptr_;
00206
00207 ptr_ = &obj;
00208 rel_ = false;
00209 }
00210
00211 void
00212 _tied_object(T* obj, CORBA::Boolean release = true)
00213 {
00214 if(rel_)
00215 delete ptr_;
00216
00217 ptr_ = obj;
00218 rel_ = release;
00219 }
00220
00221 CORBA::Boolean
00222 _is_owner()
00223 {
00224 return rel_;
00225 }
00226
00227 void
00228 _is_owner(CORBA::Boolean b)
00229 {
00230 rel_ = b;
00231 }
00232
00233 virtual HxCorba::VideoWriter_ptr
00234 openVideo(const char* videoName,
00235 CORBA::Long w,
00236 CORBA::Long h)
00237 throw(CORBA::SystemException)
00238 {
00239 return ptr_ -> openVideo(videoName, w, h);
00240 }
00241
00242 PortableServer::POA_ptr _default_POA()
00243 {
00244 if(!CORBA::is_nil(poa_))
00245 return PortableServer::POA::_duplicate(poa_);
00246 else
00247 return VideoWriterFactory::_default_POA();
00248 }
00249 };
00250
00251 }
00252
00253 #endif