This is Unofficial EPICS BASE Doxygen Site
epics::pvData::PVValueArray< T > Class Template Reference

template class for all extensions of PVArray. More...

#include "pvData.h"

+ Inheritance diagram for epics::pvData::PVValueArray< T >:
+ Collaboration diagram for epics::pvData::PVValueArray< T >:

Public Types

typedef T value_type
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef ::epics::pvData::shared_vector< T > svector
 
typedef ::epics::pvData::shared_vector< const T > const_svector
 
- Public Types inherited from epics::pvData::detail::PVVectorStorage< T, PVScalarArray >
typedef T value_type
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef ::epics::pvData::shared_vector< T > svector
 
typedef ::epics::pvData::shared_vector< const T > const_svector
 
- Public Types inherited from epics::pvData::PVScalarArray
typedef PVScalarArrayreference
 
typedef const PVScalarArrayconst_reference
 
- Public Types inherited from epics::pvData::PVField
enum  { isPVField =1 }
 

Public Member Functions

 POINTER_DEFINITIONS (PVValueArray)
 
virtual ~PVValueArray ()
 
virtual ArrayConstPtr getArray () const OVERRIDE FINAL
 
virtual std::ostream & dumpValue (std::ostream &o) const OVERRIDE FINAL
 
virtual std::ostream & dumpValue (std::ostream &o, size_t index) const OVERRIDE FINAL
 
virtual size_t getLength () const OVERRIDE FINAL
 
virtual size_t getCapacity () const OVERRIDE FINAL
 
virtual void setCapacity (size_t capacity) OVERRIDE FINAL
 
virtual void setLength (size_t length) OVERRIDE FINAL
 
virtual const_svector view () const OVERRIDE FINAL
 Fetch a read-only view of the current array data. More...
 
virtual void swap (const_svector &other) OVERRIDE FINAL
 
virtual void replace (const const_svector &next) OVERRIDE FINAL
 
virtual void serialize (ByteBuffer *pbuffer, SerializableControl *pflusher) const OVERRIDE FINAL
 
virtual void deserialize (ByteBuffer *pbuffer, DeserializableControl *pflusher) OVERRIDE FINAL
 
virtual void serialize (ByteBuffer *pbuffer, SerializableControl *pflusher, size_t offset, size_t count) const OVERRIDE FINAL
 
template<>
std::ostream & dumpValue (std::ostream &o, size_t index) const
 
template<>
std::ostream & dumpValue (std::ostream &o) const
 
template<>
void deserialize (ByteBuffer *pbuffer, DeserializableControl *pcontrol)
 
template<>
void serialize (ByteBuffer *pbuffer, SerializableControl *pflusher, size_t offset, size_t count) const
 
- Public Member Functions inherited from epics::pvData::detail::PVVectorStorage< T, PVScalarArray >
virtual ~PVVectorStorage ()
 
svector reuse ()
 
- Public Member Functions inherited from epics::pvData::PVScalarArray
 POINTER_DEFINITIONS (PVScalarArray)
 
virtual ~PVScalarArray ()
 
const ScalarArrayConstPtr getScalarArray () const
 
template<typename T >
void getAs (shared_vector< const T > &out) const
 
template<typename T >
void putFrom (const shared_vector< const T > &inp)
 
void assign (const PVScalarArray &pv)
 
void copy (const PVScalarArray &from)
 
void copyUnchecked (const PVScalarArray &from)
 
- Public Member Functions inherited from epics::pvData::PVArray
 POINTER_DEFINITIONS (PVArray)
 
virtual ~PVArray ()
 
virtual void setImmutable () OVERRIDE
 
virtual void setLength (std::size_t length)=0
 
bool isCapacityMutable () const
 
void setCapacityMutable (bool isMutable)
 
virtual void setCapacity (std::size_t capacity)=0
 
virtual std::ostream & dumpValue (std::ostream &o, std::size_t index) const =0
 
- Public Member Functions inherited from epics::pvData::PVField
 POINTER_DEFINITIONS (PVField)
 
virtual ~PVField ()
 
const std::string & getFieldName () const
 
std::string getFullName () const
 
std::size_t getFieldOffset () const
 
std::size_t getNextFieldOffset () const
 
std::size_t getNumberFields () const
 
bool isImmutable () const
 
const FieldConstPtrgetField () const
 
PVStructuregetParent ()
 
const PVStructuregetParent () const
 
void postPut ()
 
void setPostHandler (PostHandlerPtr const &postHandler)
 
virtual bool equals (PVField &pv)
 
void copy (const PVField &from)
 
void copyUnchecked (const PVField &from)
 
- Public Member Functions inherited from epics::pvData::Serializable
virtual ~Serializable ()
 
- Public Member Functions inherited from epics::pvData::SerializableArray
virtual ~SerializableArray ()
 
virtual void serialize (ByteBuffer *buffer, SerializableControl *flusher, std::size_t offset, std::size_t count) const =0
 

Static Public Attributes

static const ScalarType typeCode = pvBoolean
 
- Static Public Attributes inherited from epics::pvData::PVField
static size_t num_instances
 

Protected Member Functions

virtual void _getAsVoid (epics::pvData::shared_vector< const void > &out) const OVERRIDE FINAL
 
virtual void _putFromVoid (const epics::pvData::shared_vector< const void > &in) OVERRIDE FINAL
 
 PVValueArray (ScalarArrayConstPtr const &scalar)
 
- Protected Member Functions inherited from epics::pvData::detail::PVVectorStorage< T, PVScalarArray >
 PVVectorStorage (A a)
 
- Protected Member Functions inherited from epics::pvData::PVScalarArray
 PVScalarArray (ScalarArrayConstPtr const &scalarArray)
 
- Protected Member Functions inherited from epics::pvData::PVArray
 PVArray (FieldConstPtr const &field)
 
void checkLength (size_t length) const
 
- Protected Member Functions inherited from epics::pvData::PVField
PVField::shared_pointer getPtrSelf ()
 
 PVField (FieldConstPtr field)
 
void setParentAndName (PVStructure *parent, std::string const &fieldName)
 

Protected Attributes

const_svector value
 

Friends

class PVDataCreate
 

Detailed Description

template<typename T>
class epics::pvData::PVValueArray< T >

template class for all extensions of PVArray.

The direct extensions are pvBooleanArray, pvByteArray, ..., pvStringArray. There are specializations for PVStringArray, PVStructureArray, and PVUnionArray.

Definition at line 55 of file pvData.h.

Member Typedef Documentation

template<typename T>
typedef const T* epics::pvData::PVValueArray< T >::const_pointer

Definition at line 1181 of file pvData.h.

template<typename T>
typedef ::epics::pvData::shared_vector<const T> epics::pvData::PVValueArray< T >::const_svector

Definition at line 1185 of file pvData.h.

template<typename T>
typedef T* epics::pvData::PVValueArray< T >::pointer

Definition at line 1180 of file pvData.h.

template<typename T>
typedef ::epics::pvData::shared_vector<T> epics::pvData::PVValueArray< T >::svector

Definition at line 1184 of file pvData.h.

template<typename T>
typedef T epics::pvData::PVValueArray< T >::value_type

Definition at line 1179 of file pvData.h.

Constructor & Destructor Documentation

template<typename T >
epics::pvData::PVValueArray< T >::~PVValueArray ( )
virtual

Destructor

Definition at line 209 of file PVDataCreateFactory.cpp.

209 {}
template<typename T >
epics::pvData::PVValueArray< T >::PVValueArray ( ScalarArrayConstPtr const &  scalar)
explicitprotected

Definition at line 191 of file PVDataCreateFactory.cpp.

192  :base_t(scalarArray)
193  ,value()
194 
195 {}

Member Function Documentation

template<typename T >
void epics::pvData::PVValueArray< T >::_getAsVoid ( epics::pvData::shared_vector< const void > &  out) const
protectedvirtual

Implements epics::pvData::PVScalarArray.

Definition at line 454 of file PVDataCreateFactory.cpp.

455 {
456  out = static_shared_vector_cast<const void>(this->view());
457 }
virtual const_svector view() const OVERRIDE FINAL
Fetch a read-only view of the current array data.
Definition: pvData.h:1209
template<typename T >
void epics::pvData::PVValueArray< T >::_putFromVoid ( const epics::pvData::shared_vector< const void > &  in)
protectedvirtual

Implements epics::pvData::PVScalarArray.

Definition at line 460 of file PVDataCreateFactory.cpp.

461 {
462  this->replace(shared_vector_convert<const T>(in));
463 }
virtual void replace(const const_svector &next) OVERRIDE FINAL
template<>
void epics::pvData::PVValueArray< string >::deserialize ( ByteBuffer buffer,
DeserializableControl flusher 
)
virtual

Deserialize buffer.

Parameters
bufferserialization buffer.
flusherdeserialization control.

Implements epics::pvData::Serializable.

Definition at line 410 of file PVDataCreateFactory.cpp.

411  {
412 
413  size_t size = this->getArray()->getArraySizeType() == Array::fixed ?
414  this->getArray()->getMaximumCapacity() :
416 
417  svector nextvalue(thaw(value));
418 
419  // Decide if we must re-allocate
420  if(size > nextvalue.size() || !nextvalue.unique())
421  nextvalue.resize(size);
422  else if(size < nextvalue.size())
423  nextvalue.slice(0, size);
424 
425 
426  string * pvalue = nextvalue.data();
427  for(size_t i = 0; i<size; i++) {
429  pcontrol);
430  }
431  value = freeze(nextvalue);
432  // inform about the change?
433  postPut();
434 }
Definition: link.h:174
::epics::pvData::shared_vector< T > svector
Definition: pvData.h:1184
static std::string deserializeString(ByteBuffer *buffer, DeserializableControl *control)
int i
Definition: scan.c:967
static std::size_t readSize(ByteBuffer *buffer, DeserializableControl *control)
virtual ArrayConstPtr getArray() const OVERRIDE FINAL
char * pbuffer
Definition: errlog.c:85
template<typename T >
void epics::pvData::PVValueArray< T >::deserialize ( ByteBuffer buffer,
DeserializableControl flusher 
)
virtual

Deserialize buffer.

Parameters
bufferserialization buffer.
flusherdeserialization control.

Implements epics::pvData::Serializable.

Definition at line 317 of file PVDataCreateFactory.cpp.

318  {
319 
320  size_t size = this->getArray()->getArraySizeType() == Array::fixed ?
321  this->getArray()->getMaximumCapacity() :
323 
324  svector nextvalue(thaw(value));
325  nextvalue.resize(size); // TODO: avoid copy of stuff we will then overwrite
326 
327  T* cur = nextvalue.data();
328 
329  // try to avoid deserializing from the buffer
330  // this is only possible if we do not need to do endian-swapping
331  if (!pbuffer->reverse<T>())
332  if (pcontrol->directDeserialize(pbuffer, (char*)cur, size, sizeof(T)))
333  {
334  // inform about the change?
336  return;
337  }
338 
339  // retrieve value from the buffer
340  size_t remaining = size;
341  while(remaining) {
342  const size_t have_bytes = pbuffer->getRemaining();
343 
344  // correctly rounds down in an element is partially received
345  const size_t available = have_bytes/sizeof(T);
346 
347  if(available == 0) {
348  // get at least one element
349  pcontrol->ensureData(sizeof(T));
350  continue;
351  }
352 
353  const size_t n2read = std::min(remaining, available);
354 
355  pbuffer->getArray(cur, n2read);
356  cur += n2read;
357  remaining -= n2read;
358  }
359  value = freeze(nextvalue);
360  // TODO !!!
361  // inform about the change?
363 }
Definition: link.h:174
::epics::pvData::shared_vector< T > svector
Definition: pvData.h:1184
#define min(x, y)
Definition: flexdef.h:78
static std::size_t readSize(ByteBuffer *buffer, DeserializableControl *control)
virtual ArrayConstPtr getArray() const OVERRIDE FINAL
char * pbuffer
Definition: errlog.c:85
template<>
std::ostream & epics::pvData::PVValueArray< std::string >::dumpValue ( std::ostream &  o,
size_t  index 
) const

Definition at line 234 of file PVDataCreateFactory.cpp.

235 {
236  return o << '"' << escape(this->view().at(index)) << '"';
237 }
virtual const_svector view() const OVERRIDE FINAL
Fetch a read-only view of the current array data.
Definition: pvData.h:1209
template<>
std::ostream & epics::pvData::PVValueArray< std::string >::dumpValue ( std::ostream &  o) const
virtual

Puts the PVField raw value to the stream.

Parameters
ooutput stream.
Returns
The output stream.

Implements epics::pvData::PVField.

Definition at line 240 of file PVDataCreateFactory.cpp.

241 {
242  const_svector v(this->view());
243  const_svector::const_iterator it(v.begin()),
244  end(v.end());
245  o << '[';
246  if(it!=end) {
247  o << '"' << escape(*it++) << '"';
248  for(; it!=end; ++it)
249  o << ", \"" << escape(*it) << '"';
250 
251  }
252  return o << ']';
253 }
virtual const_svector view() const OVERRIDE FINAL
Fetch a read-only view of the current array data.
Definition: pvData.h:1209
meta::decorate_const< const T >::type * const_iterator
Definition: sharedVector.h:300
::epics::pvData::shared_vector< const T > const_svector
Definition: pvData.h:1185
template<typename T >
std::ostream & epics::pvData::PVValueArray< T >::dumpValue ( std::ostream &  o) const
virtual

Puts the PVField raw value to the stream.

Parameters
ooutput stream.
Returns
The output stream.

Implements epics::pvData::PVField.

Definition at line 218 of file PVDataCreateFactory.cpp.

219 {
220  const_svector v(this->view());
221  typename const_svector::const_iterator it(v.begin()),
222  end(v.end());
223  o << '[';
224  if(it!=end) {
225  o << print_cast(*it++);
226  for(; it!=end; ++it)
227  o << ',' << print_cast(*it);
228 
229  }
230  return o << ']';
231 }
virtual const_svector view() const OVERRIDE FINAL
Fetch a read-only view of the current array data.
Definition: pvData.h:1209
meta::decorate_const< const T >::type * const_iterator
Definition: sharedVector.h:300
::epics::pvData::shared_vector< const T > const_svector
Definition: pvData.h:1185
template<typename T >
std::ostream & epics::pvData::PVValueArray< T >::dumpValue ( std::ostream &  o,
size_t  index 
) const
virtual

Definition at line 256 of file PVDataCreateFactory.cpp.

257 {
258  return o << print_cast(this->view().at(index));
259 }
virtual const_svector view() const OVERRIDE FINAL
Fetch a read-only view of the current array data.
Definition: pvData.h:1209
template<typename T >
ArrayConstPtr epics::pvData::PVValueArray< T >::getArray ( ) const
virtual

Get introspection interface.

Implements epics::pvData::PVArray.

Definition at line 212 of file PVDataCreateFactory.cpp.

213 {
214  return std::tr1::static_pointer_cast<const Array>(this->getField());
215 }
const FieldConstPtr & getField() const
Definition: pvData.h:208
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:788
template<typename T>
virtual size_t epics::pvData::PVValueArray< T >::getCapacity ( ) const
inlinevirtual

Get the array capacity.

Returns
The capacity.

Implements epics::pvData::PVArray.

Definition at line 1204 of file pvData.h.

1204 {return value.capacity();}
Definition: link.h:174
template<typename T>
virtual size_t epics::pvData::PVValueArray< T >::getLength ( ) const
inlinevirtual

Get the array length.

Returns
The length.

Implements epics::pvData::PVArray.

Definition at line 1203 of file pvData.h.

1203 {return value.size();}
Definition: link.h:174
template<typename T>
epics::pvData::PVValueArray< T >::POINTER_DEFINITIONS ( PVValueArray< T >  )
template<typename T >
void epics::pvData::PVValueArray< T >::replace ( const const_svector next)
virtual

Discard current contents and replaced with the provided. Fails for Immutable arrays calls postPut()

Implements epics::pvData::detail::PVVectorStorage< T, PVScalarArray >.

Definition at line 290 of file PVDataCreateFactory.cpp.

291 {
292  this->checkLength(next.size());
293 
294  value = next;
295  this->postPut();
296 }
Definition: link.h:174
void checkLength(size_t length) const
template<>
void epics::pvData::PVValueArray< string >::serialize ( ByteBuffer pbuffer,
SerializableControl pflusher,
size_t  offset,
size_t  count 
) const

Definition at line 437 of file PVDataCreateFactory.cpp.

438  {
439 
440  const_svector temp(value);
441  temp.slice(offset, count);
442 
443  // TODO if fixed count == getArray()->getMaximumCapacity()
444  if (this->getArray()->getArraySizeType() != Array::fixed)
445  SerializeHelper::writeSize(temp.size(), pbuffer, pflusher);
446 
447  const string * pvalue = temp.data();
448  for(size_t i = 0; i<temp.size(); i++) {
449  SerializeHelper::serializeString(pvalue[i], pbuffer, pflusher);
450  }
451 }
Definition: link.h:174
int i
Definition: scan.c:967
static void writeSize(std::size_t s, ByteBuffer *buffer, SerializableControl *flusher)
virtual ArrayConstPtr getArray() const OVERRIDE FINAL
static void serializeString(const std::string &value, ByteBuffer *buffer, SerializableControl *flusher)
char * pbuffer
Definition: errlog.c:85
::epics::pvData::shared_vector< const T > const_svector
Definition: pvData.h:1185
template<typename T >
void epics::pvData::PVValueArray< T >::serialize ( ByteBuffer buffer,
SerializableControl flusher 
) const
virtual

Serialize field into given buffer.

Parameters
bufferserialization buffer.
flusherflush interface.

Implements epics::pvData::Serializable.

Definition at line 311 of file PVDataCreateFactory.cpp.

312  {
313  serialize(pbuffer, pflusher, 0, this->getLength());
314 }
virtual void serialize(ByteBuffer *pbuffer, SerializableControl *pflusher) const OVERRIDE FINAL
char * pbuffer
Definition: errlog.c:85
virtual size_t getLength() const OVERRIDE FINAL
Definition: pvData.h:1203
template<typename T >
void epics::pvData::PVValueArray< T >::serialize ( ByteBuffer pbuffer,
SerializableControl pflusher,
size_t  offset,
size_t  count 
) const
virtual

Definition at line 366 of file PVDataCreateFactory.cpp.

368 {
369  //TODO: avoid incrementing the ref counter...
370  const_svector temp(value);
371  temp.slice(offset, count);
372  count = temp.size();
373 
374  ArrayConstPtr array = this->getArray();
375  if (array->getArraySizeType() != Array::fixed)
376  SerializeHelper::writeSize(count, pbuffer, pflusher);
377  else if (count != array->getMaximumCapacity())
378  throw std::length_error("fixed array cannot be partially serialized");
379 
380  const T* cur = temp.data();
381 
382  // try to avoid copying into the buffer
383  // this is only possible if we do not need to do endian-swapping
384  if (!pbuffer->reverse<T>())
385  if (pflusher->directSerialize(pbuffer, (const char*)cur, count, sizeof(T)))
386  return;
387 
388  while(count) {
389  const size_t empty = pbuffer->getRemaining();
390  const size_t space_for = empty/sizeof(T);
391 
392  if(space_for==0) {
393  pflusher->flushSerializeBuffer();
394  // Can we be certain that more space is now free???
395  // If not then we spinnnnnnnnn
396  continue;
397  }
398 
399  const size_t n2send = std::min(count, space_for);
400 
401  pbuffer->putArray(cur, n2send);
402  cur += n2send;
403  count -= n2send;
404  }
405 }
epics::pvData::BitSetPtr empty
Definition: pvAccess.cpp:135
Definition: link.h:174
#define min(x, y)
Definition: flexdef.h:78
std::tr1::shared_ptr< const Array > ArrayConstPtr
Definition: pvIntrospect.h:154
static void writeSize(std::size_t s, ByteBuffer *buffer, SerializableControl *flusher)
virtual ArrayConstPtr getArray() const OVERRIDE FINAL
char * pbuffer
Definition: errlog.c:85
::epics::pvData::shared_vector< const T > const_svector
Definition: pvData.h:1185
template<typename T >
void epics::pvData::PVValueArray< T >::setCapacity ( size_t  capacity)
virtual

Definition at line 262 of file PVDataCreateFactory.cpp.

263 {
264  if(this->isCapacityMutable()) {
265  this->checkLength(capacity);
266  value.reserve(capacity);
267  }
268  else
269  THROW_EXCEPTION2(std::logic_error, "capacity immutable");
270 }
Definition: link.h:174
#define THROW_EXCEPTION2(TYPE, MSG)
void checkLength(size_t length) const
bool isCapacityMutable() const
Definition: PVArray.cpp:33
template<typename T >
void epics::pvData::PVValueArray< T >::setLength ( size_t  length)
virtual

Definition at line 273 of file PVDataCreateFactory.cpp.

274 {
275  if(this->isImmutable())
276  THROW_EXCEPTION2(std::logic_error, "immutable");
277 
278  if (length == value.size())
279  return;
280 
281  this->checkLength(length);
282 
283  if (length < value.size())
284  value.slice(0, length);
285  else
286  value.resize(length);
287 }
Definition: link.h:174
#define THROW_EXCEPTION2(TYPE, MSG)
void checkLength(size_t length) const
bool isImmutable() const
Definition: pvData.h:198
template<typename T >
void epics::pvData::PVValueArray< T >::swap ( const_svector other)
virtual

Exchange our contents for the provided.

Exceptions
std::logic_errorfor Immutable arrays.

Callers must ensure that postPut() is called after the last swap() operation.

Before you call this directly, consider using the reuse(), or replace() methods.

Implements epics::pvData::detail::PVVectorStorage< T, PVScalarArray >.

Definition at line 299 of file PVDataCreateFactory.cpp.

300 {
301  if (this->isImmutable())
302  THROW_EXCEPTION2(std::logic_error, "immutable");
303 
304  // no checkLength call here
305 
306  value.swap(other);
307 }
Definition: link.h:174
#define THROW_EXCEPTION2(TYPE, MSG)
bool isImmutable() const
Definition: pvData.h:198
template<typename T>
virtual const_svector epics::pvData::PVValueArray< T >::view ( ) const
inlinevirtual

Fetch a read-only view of the current array data.

Implements epics::pvData::detail::PVVectorStorage< T, PVScalarArray >.

Definition at line 1209 of file pvData.h.

1209 {return value;}

Friends And Related Function Documentation

template<typename T>
friend class PVDataCreate
friend

Definition at line 1225 of file pvData.h.

Member Data Documentation

template<typename T>
const ScalarType epics::pvData::PVStringArray::typeCode = pvBoolean
static

Definition at line 1188 of file pvData.h.

template<typename T>
const_svector epics::pvData::PVValueArray< T >::value
protected

Definition at line 1224 of file pvData.h.


The documentation for this class was generated from the following files: