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

Data class for a structureArray. More...

#include "pvData.h"

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

Public Types

typedef PVStructurePtr value_type
 
typedef PVStructurePtrpointer
 
typedef const PVStructurePtrconst_pointer
 
typedef PVStructureArrayreference
 
typedef const PVStructureArrayconst_reference
 
typedef ::epics::pvData::shared_vector< PVStructurePtrsvector
 
typedef ::epics::pvData::shared_vector< const PVStructurePtrconst_svector
 
- Public Types inherited from epics::pvData::detail::PVVectorStorage< PVStructurePtr, PVArray >
typedef PVStructurePtr value_type
 
typedef PVStructurePtrpointer
 
typedef const PVStructurePtrconst_pointer
 
typedef ::epics::pvData::shared_vector< PVStructurePtrsvector
 
typedef ::epics::pvData::shared_vector< const PVStructurePtrconst_svector
 
- Public Types inherited from epics::pvData::PVField
enum  { isPVField =1 }
 

Public Member Functions

 POINTER_DEFINITIONS (PVStructureArray)
 
virtual ~PVValueArray ()
 
virtual ArrayConstPtr getArray () 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 (std::size_t length) OVERRIDE FINAL
 
StructureArrayConstPtr getStructureArray () const
 
std::size_t append (std::size_t number)
 
bool remove (std::size_t offset, std::size_t number)
 
void compress ()
 
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 &other) OVERRIDE FINAL
 
virtual void serialize (ByteBuffer *pbuffer, SerializableControl *pflusher) const OVERRIDE FINAL
 
virtual void deserialize (ByteBuffer *buffer, DeserializableControl *pflusher) OVERRIDE FINAL
 
virtual void serialize (ByteBuffer *pbuffer, SerializableControl *pflusher, std::size_t offset, std::size_t count) const OVERRIDE FINAL
 
virtual std::ostream & dumpValue (std::ostream &o) const OVERRIDE FINAL
 
virtual std::ostream & dumpValue (std::ostream &o, std::size_t index) const OVERRIDE FINAL
 
void copy (const PVStructureArray &from)
 
void copyUnchecked (const PVStructureArray &from)
 
- Public Member Functions inherited from epics::pvData::detail::PVVectorStorage< PVStructurePtr, PVArray >
virtual ~PVVectorStorage ()
 
svector reuse ()
 
- Public Member Functions inherited from epics::pvData::PVArray
 POINTER_DEFINITIONS (PVArray)
 
virtual ~PVArray ()
 
virtual void setImmutable () OVERRIDE
 
bool isCapacityMutable () const
 
void setCapacityMutable (bool isMutable)
 
virtual void setCapacity (std::size_t capacity)=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 ()
 

Protected Member Functions

 PVValueArray (StructureArrayConstPtr const &structureArray)
 
- Protected Member Functions inherited from epics::pvData::detail::PVVectorStorage< PVStructurePtr, PVArray >
 PVVectorStorage (A a)
 
- 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)
 

Friends

class PVDataCreate
 

Additional Inherited Members

- Static Public Attributes inherited from epics::pvData::PVField
static size_t num_instances
 

Detailed Description

template<>
class epics::pvData::PVValueArray< PVStructurePtr >

Data class for a structureArray.

Definition at line 1236 of file pvData.h.

Member Typedef Documentation

Definition at line 1243 of file pvData.h.

Constructor & Destructor Documentation

Destructor

Definition at line 1253 of file pvData.h.

1253 {}

Definition at line 197 of file PVDataCreateFactory.cpp.

Member Function Documentation

std::size_t epics::pvData::PVValueArray< PVStructurePtr >::append ( std::size_t  number)

Append new elements to the end of the array.

Parameters
numberThe number of elements to add.
Returns
the new length of the array.
void epics::pvData::PVStructureArray::compress ( )

Compress. This removes all null elements from the array.

Definition at line 69 of file PVStructureArray.cpp.

69  {
70  if (getArray()->getArraySizeType() == Array::fixed)
71  return;
72 
73  svector vec(reuse()); // TODO: check for first NULL before realloc
74 
75  size_t length = vec.size();
76  size_t newLength = 0;
77 
78  for(size_t i=0; i<length; i++) {
79  if(vec[i]) {
80  newLength++;
81  continue;
82  }
83  // find first non 0
84  size_t notNull = 0;
85  for(size_t j=i+1;j<length;j++) {
86  if(vec[j]) {
87  notNull = j;
88  break;
89  }
90  }
91  if(notNull!=0) {
92  vec[i] = vec[notNull];
93  vec[notNull].reset();
94  newLength++;
95  continue;
96  }
97  break;
98  }
99 
100  vec.resize(newLength);
101  const_svector cdata(freeze(vec));
102  swap(cdata);
103 }
int i
Definition: scan.c:967
::epics::pvData::shared_vector< PVStructurePtr > svector
Definition: pvData.h:1248
virtual void swap(const_svector &other) OVERRIDE FINAL
::epics::pvData::shared_vector< const PVStructurePtr > const_svector
Definition: pvData.h:1249
virtual ArrayConstPtr getArray() const OVERRIDE FINAL
Definition: pvData.h:1255
void epics::pvData::PVStructureArray::copy ( const PVStructureArray from)

Definition at line 243 of file PVStructureArray.cpp.

244 {
245  if(isImmutable())
246  throw std::invalid_argument("destination is immutable");
247 
248  if(*getStructureArray() != *from.getStructureArray())
249  throw std::invalid_argument("structureArray definitions do not match");
250 
251  copyUnchecked(from);
252 }
StructureArrayConstPtr getStructureArray() const
Definition: pvData.h:1278
bool isImmutable() const
Definition: pvData.h:198
void copyUnchecked(const PVStructureArray &from)
void epics::pvData::PVStructureArray::copyUnchecked ( const PVStructureArray from)

Definition at line 254 of file PVStructureArray.cpp.

255 {
256  if (this == &from)
257  return;
258 
259  replace(from.view());
260 }
virtual void replace(const const_svector &other) OVERRIDE FINAL
Definition: pvData.h:1299
void epics::pvData::PVStructureArray::deserialize ( ByteBuffer buffer,
DeserializableControl flusher 
)
virtual

Deserialize buffer.

Parameters
bufferserialization buffer.
flusherdeserialization control.

Implements epics::pvData::Serializable.

Definition at line 159 of file PVStructureArray.cpp.

160  {
161  svector data(reuse());
162 
163  size_t size = this->getArray()->getArraySizeType() == Array::fixed ?
164  this->getArray()->getMaximumCapacity() :
166 
167  data.resize(size);
168 
169  StructureConstPtr structure = structureArray->getStructure();
170 
171  PVDataCreatePtr pvDataCreate = getPVDataCreate();
172 
173  for(size_t i = 0; i<size; i++) {
174  pcontrol->ensureData(1);
175  size_t temp = pbuffer->getByte();
176  if(temp==0) {
177  data[i].reset();
178  }
179  else {
180  if(data[i].get()==NULL || !data[i].unique()) {
181  data[i] = pvDataCreate->createPVStructure(structure);
182  }
183  data[i]->deserialize(pbuffer, pcontrol);
184  }
185  }
186  replace(freeze(data)); // calls postPut()
187 }
int i
Definition: scan.c:967
::epics::pvData::shared_vector< PVStructurePtr > svector
Definition: pvData.h:1248
virtual void replace(const const_svector &other) OVERRIDE FINAL
Definition: pvData.h:1299
std::tr1::shared_ptr< const Structure > StructureConstPtr
Definition: pvIntrospect.h:162
#define NULL
Definition: catime.c:38
static std::size_t readSize(ByteBuffer *buffer, DeserializableControl *control)
std::tr1::shared_ptr< PVDataCreate > PVDataCreatePtr
Definition: pvData.h:124
char * pbuffer
Definition: errlog.c:85
virtual ArrayConstPtr getArray() const OVERRIDE FINAL
Definition: pvData.h:1255
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
Definition: pvData.h:1648
std::ostream & epics::pvData::PVStructureArray::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 215 of file PVStructureArray.cpp.

216 {
217  o << format::indent() << getStructureArray()->getID() << ' ' << getFieldName() << std::endl;
218  size_t length = getLength();
219  if (length > 0)
220  {
221  format::indent_scope s(o);
222 
223  for (size_t i = 0; i < length; i++)
224  dumpValue(o, i);
225  }
226 
227  return o;
228 }
const std::string & getFieldName() const
Definition: pvData.h:166
int i
Definition: scan.c:967
StructureArrayConstPtr getStructureArray() const
Definition: pvData.h:1278
virtual std::ostream & dumpValue(std::ostream &o) const OVERRIDE FINAL
virtual size_t getLength() const OVERRIDE FINAL
Definition: pvData.h:1260
std::ostream & epics::pvData::PVStructureArray::dumpValue ( std::ostream &  o,
std::size_t  index 
) const
virtual

Implements epics::pvData::PVArray.

Definition at line 230 of file PVStructureArray.cpp.

231 {
232  const_svector temp(view());
233  if (index<temp.size())
234  {
235  if (temp[index])
236  o << *temp[index];
237  else
238  o << format::indent() << "(none)" << std::endl;
239  }
240  return o;
241 }
::epics::pvData::shared_vector< const PVStructurePtr > const_svector
Definition: pvData.h:1249
virtual const_svector view() const OVERRIDE FINAL
Fetch a read-only view of the current array data.
Definition: pvData.h:1297
virtual ArrayConstPtr epics::pvData::PVValueArray< PVStructurePtr >::getArray ( ) const
inlinevirtual

Get the introspection interface

Returns
The interface.

Implements epics::pvData::PVArray.

Definition at line 1255 of file pvData.h.

1256  {
1257  return std::tr1::static_pointer_cast<const Array>(structureArray);
1258  }
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:788
virtual size_t epics::pvData::PVValueArray< PVStructurePtr >::getCapacity ( ) const
inlinevirtual

Get the array capacity.

Returns
The capacity.

Implements epics::pvData::PVArray.

Definition at line 1261 of file pvData.h.

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

Get the array length.

Returns
The length.

Implements epics::pvData::PVArray.

Definition at line 1260 of file pvData.h.

1260 {return value.size();}
Definition: link.h:174
StructureArrayConstPtr epics::pvData::PVValueArray< PVStructurePtr >::getStructureArray ( ) const
inline

Get the introspection interface

Returns
The interface.

Definition at line 1278 of file pvData.h.

bool epics::pvData::PVValueArray< PVStructurePtr >::remove ( std::size_t  offset,
std::size_t  number 
)

Remove elements from the array.

Parameters
offsetThe offset of the first element to remove.
numberThe number of elements to remove.
Returns
(false,true) if the elements were removed.
virtual void epics::pvData::PVValueArray< PVStructurePtr >::replace ( const const_svector next)
inlinevirtual

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

Implements epics::pvData::detail::PVVectorStorage< PVStructurePtr, PVArray >.

Definition at line 1299 of file pvData.h.

1299  {
1300  checkLength(other.size());
1301  value = other;
1302  PVField::postPut();
1303  }
Definition: link.h:174
void checkLength(size_t length) const
void epics::pvData::PVStructureArray::serialize ( ByteBuffer buffer,
SerializableControl flusher 
) const
virtual

Serialize field into given buffer.

Parameters
bufferserialization buffer.
flusherflush interface.

Implements epics::pvData::Serializable.

Definition at line 154 of file PVStructureArray.cpp.

155  {
156  serialize(pbuffer, pflusher, 0, getLength());
157 }
char * pbuffer
Definition: errlog.c:85
virtual size_t getLength() const OVERRIDE FINAL
Definition: pvData.h:1260
virtual void serialize(ByteBuffer *pbuffer, SerializableControl *pflusher) const OVERRIDE FINAL
virtual void epics::pvData::PVValueArray< PVStructurePtr >::serialize ( ByteBuffer buffer,
SerializableControl flusher,
std::size_t  offset,
std::size_t  count 
) const
virtual

Serialize field into given buffer.

Parameters
bufferserialization buffer.
flusherflush interface.
offsetoffset in elements.
countnumber of elements

Implements epics::pvData::SerializableArray.

void epics::pvData::PVStructureArray::setCapacity ( size_t  capacity)
virtual

Set the array capacity.

Parameters
capacityThe length.

Definition at line 105 of file PVStructureArray.cpp.

106 {
107  if (this->isCapacityMutable()) {
108  checkLength(capacity);
110  swap(value);
111  if(value.capacity()<capacity) {
112  svector mvalue(thaw(value));
113  mvalue.reserve(capacity);
114  value = freeze(mvalue);
115  }
116  swap(value);
117  }
118  else
119  THROW_EXCEPTION2(std::logic_error, "capacity immutable");
120 }
Definition: link.h:174
#define THROW_EXCEPTION2(TYPE, MSG)
::epics::pvData::shared_vector< PVStructurePtr > svector
Definition: pvData.h:1248
void checkLength(size_t length) const
virtual void swap(const_svector &other) OVERRIDE FINAL
::epics::pvData::shared_vector< const PVStructurePtr > const_svector
Definition: pvData.h:1249
bool isCapacityMutable() const
Definition: PVArray.cpp:33
virtual void epics::pvData::PVValueArray< PVStructurePtr >::setLength ( std::size_t  length)
virtual

Set the array length.

Parameters
lengthThe length.

Implements epics::pvData::PVArray.

void epics::pvData::PVStructureArray::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< PVStructurePtr, PVArray >.

Definition at line 144 of file PVStructureArray.cpp.

145 {
146  if (this->isImmutable())
147  THROW_EXCEPTION2(std::logic_error, "immutable");
148 
149  // no checkLength call here
150 
151  value.swap(other);
152 }
Definition: link.h:174
#define THROW_EXCEPTION2(TYPE, MSG)
bool isImmutable() const
Definition: pvData.h:198
virtual const_svector epics::pvData::PVValueArray< PVStructurePtr >::view ( ) const
inlinevirtual

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

Implements epics::pvData::detail::PVVectorStorage< PVStructurePtr, PVArray >.

Definition at line 1297 of file pvData.h.

1297 { return value; }
Definition: link.h:174

Friends And Related Function Documentation

friend class PVDataCreate
friend

Definition at line 1323 of file pvData.h.


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