00001
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef BufferBase_h
00034 #define BufferBase_h
00035
00036 namespace RTC
00037 {
00071 template <class DataType>
00072 class BufferBase
00073 {
00074 public:
00086 virtual ~BufferBase(){};
00087
00099 virtual long int length() const = 0;
00100
00112 virtual bool write(const DataType& value) = 0;
00113
00125 virtual bool read(DataType& value) = 0;
00126
00138 virtual bool isFull() const = 0;
00139
00151 virtual bool isEmpty() const = 0;
00152
00153 protected:
00165 virtual void put(const DataType& data) = 0;
00166
00178 virtual const DataType& get() = 0;
00179
00191 virtual DataType& getRef() = 0;
00192
00193 };
00194
00195
00196
00197
00198 template <class DataType>
00199 class NullBuffer
00200 : public BufferBase<DataType>
00201 {
00202 public:
00203 NullBuffer(long int size = 1)
00204 : m_length(1)
00205 {
00206 }
00207
00208 virtual ~NullBuffer()
00209 {
00210 }
00211
00212 virtual long int length() const
00213 {
00214 return 1;
00215 }
00216
00217 virtual bool write(const DataType& value)
00218 {
00219 m_data = value;
00220 return true;
00221 }
00222
00223 virtual bool read(DataType& value)
00224 {
00225 value = m_data;
00226 return true;
00227 }
00228
00229 virtual bool isFull() const
00230 {
00231 return false;
00232 }
00233
00234 virtual bool isEmpty() const
00235 {
00236 return false;
00237 }
00238
00239 protected:
00240 virtual void put(const DataType& data)
00241 {
00242 m_data = data;
00243 }
00244
00245 virtual const DataType& get()
00246 {
00247 return m_data;
00248 }
00249
00250 virtual DataType& getRef()
00251 {
00252 return m_data;
00253 }
00254
00255 private:
00256 DataType m_data;
00257 long int m_length;
00258 };
00259
00260
00261 };
00262 #endif // BufferBase_h