OpenDDS  Snapshot(2023/04/28-20:55)
SafetyProfileSequenceVar.h
Go to the documentation of this file.
1 #ifndef OPENDDS_DCPS_SAFETYPROFILESEQUENCEVAR_H
2 #define OPENDDS_DCPS_SAFETYPROFILESEQUENCEVAR_H
3 
4 
5 namespace OpenDDS {
6 namespace SafetyProfile {
7 
8  /**
9  * @class SequenceVar
10  *
11  * @brief Parametrized implementation of var class for sequences.
12  *
13  */
14  template <typename T>
15  class SequenceVar {
16  public:
17  typedef typename T::subscript_type T_elem;
18  typedef typename T::const_subscript_type T_const_elem;
19 
21  : ptr_(0)
22  {
23  }
24 
26  : ptr_(p)
27  {
28  }
29 
31  : ptr_(p.ptr_ ? new T(*p.ptr_) : 0)
32  {
33  }
34 
36  {
37  delete ptr_;
38  }
39 
40 
41  SequenceVar& operator=(T* p);
43 
45  {
46  return ptr_;
47  }
48 
49  const T* operator->() const
50  {
51  return ptr_;
52  }
53 
54 
55  typedef const T& _in_type;
56  typedef T& _inout_type;
57  typedef T*& _out_type;
58  typedef T* _retn_type;
59 
60  _in_type in() const
61  {
62  return *ptr_;
63  }
64 
65  _inout_type inout()
66  {
67  return *ptr_;
68  }
69 
70  _out_type out();
71  _retn_type _retn();
72 
73  _retn_type ptr() const
74  {
75  return ptr_;
76  }
77 
78  operator _in_type() const
79  {
80  return in();
81  }
82 
83  operator _inout_type()
84  {
85  return inout();
86  }
87 
88  operator _out_type()
89  {
90  return out();
91  }
92 
93 
94  T_elem operator[](CORBA::ULong index)
95  {
96  return (*ptr_)[index];
97  }
98 
99  T_const_elem operator[](CORBA::ULong index) const
100  {
101  return (*ptr_)[index];
102  }
103 
104  private:
105  T* ptr_;
106  };
107 
108  template<typename T>
109  inline
112  {
113  delete ptr_;
114  ptr_ = p;
115  return *this;
116  }
117 
118  template<typename T>
119  inline
122  const SequenceVar<T>& p)
123  {
124  SequenceVar<T> tmp(p);
125 
126  T* old_ptr = ptr_;
127  ptr_ = tmp.ptr_;
128  tmp.ptr_ = old_ptr;
129 
130  return *this;
131  }
132 
133  template<typename T>
134  inline
135  T*&
137  {
138  delete ptr_;
139  ptr_ = 0;
140  return ptr_;
141  }
142 
143  template<typename T>
144  inline
145  T*
147  {
148  T* tmp = ptr_;
149  ptr_ = 0;
150  return tmp;
151  }
152 }
153 }
154 
155 #endif /* dds_DCPS_SafetyProfileSequencVar_h */
Parametrized implementation of var class for sequences.
ACE_CDR::ULong ULong
T_const_elem operator[](CORBA::ULong index) const
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28