00001 00002 #ifndef _CORBA_SEQ_VAR_H 00003 #define _CORBA_SEQ_VAR_H 00004 00005 #include <assert.h> 00006 00007 namespace CORBA 00008 { 00012 template <class T> class IDL_Seq_var 00013 { 00014 public: 00015 00017 IDL_Seq_var (); 00018 00020 IDL_Seq_var (T * p); 00021 00023 IDL_Seq_var (const IDL_Seq_var<T> & seq); 00024 00026 ~IDL_Seq_var (); 00027 00029 IDL_Seq_var<T> & operator = (T * p); 00030 00032 IDL_Seq_var<T> & operator = (const IDL_Seq_var<T> & seq); 00033 00035 T * operator->(); 00036 00038 typename T::_subscript_type operator [] (::CORBA::ULong index) 00039 { 00040 assert (m_ptr); 00041 return m_ptr->operator[] (index); 00042 } 00043 00045 typename T::_const_subscript_type operator [] (::CORBA::ULong index) const 00046 { 00047 assert (m_ptr); 00048 return ((const T *)m_ptr)->operator[] (index); 00049 } 00050 00051 protected: 00052 00054 T * m_ptr; 00055 }; 00056 00057 template <class T> inline 00058 IDL_Seq_var<T>::IDL_Seq_var() 00059 : m_ptr (0) 00060 { 00061 } 00062 00063 template <class T> inline 00064 IDL_Seq_var<T>::IDL_Seq_var(T * p) 00065 : m_ptr (p) 00066 { 00067 } 00068 00069 template <class T> inline 00070 IDL_Seq_var<T>::IDL_Seq_var(const IDL_Seq_var<T>& t) 00071 : m_ptr(0) 00072 { 00073 if(t.m_ptr != 0) m_ptr = new T(*t.m_ptr); 00074 } 00075 00076 template <class T> inline 00077 IDL_Seq_var<T>::~IDL_Seq_var() 00078 { 00079 if(m_ptr) delete m_ptr; 00080 } 00081 00082 template <class T> inline IDL_Seq_var<T>& 00083 IDL_Seq_var<T>::operator=(T* t) 00084 { 00085 if(t != m_ptr) { 00086 if(m_ptr) delete m_ptr; 00087 m_ptr = t; 00088 } 00089 return *this; 00090 } 00091 00092 template <class T> inline IDL_Seq_var<T>& 00093 IDL_Seq_var<T>::operator=(const IDL_Seq_var<T>& t) 00094 { 00095 if(this != &t){ 00096 T* old_m_ptr = m_ptr; 00097 if(t.m_ptr != 0) m_ptr = new T(*t.m_ptr); 00098 else m_ptr = 0; 00099 if(old_m_ptr) delete old_m_ptr; 00100 } 00101 return *this; 00102 } 00103 00104 template <class T> inline T* 00105 IDL_Seq_var<T>::operator->() 00106 { 00107 return m_ptr; 00108 } 00109 00110 } 00111 00112 #endif /* _IDL_SEQ_VAR_H */ 00113