This is Unofficial EPICS BASE Doxygen Site
epics::pvData::PVField Class Referenceabstract

PVField is the base class for each PVData field. More...

#include "pvData.h"

+ Inheritance diagram for epics::pvData::PVField:
+ Collaboration diagram for epics::pvData::PVField:

Public Types

enum  { isPVField =1 }
 

Public Member Functions

 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
 
virtual void setImmutable ()
 
const FieldConstPtrgetField () const
 
PVStructuregetParent ()
 
const PVStructuregetParent () const
 
void postPut ()
 
void setPostHandler (PostHandlerPtr const &postHandler)
 
virtual bool equals (PVField &pv)
 
virtual std::ostream & dumpValue (std::ostream &o) const =0
 
void copy (const PVField &from)
 
void copyUnchecked (const PVField &from)
 
- Public Member Functions inherited from epics::pvData::Serializable
virtual ~Serializable ()
 
virtual void serialize (ByteBuffer *buffer, SerializableControl *flusher) const =0
 
virtual void deserialize (ByteBuffer *buffer, DeserializableControl *flusher)=0
 

Static Public Attributes

static size_t num_instances
 

Protected Member Functions

PVField::shared_pointer getPtrSelf ()
 
 PVField (FieldConstPtr field)
 
void setParentAndName (PVStructure *parent, std::string const &fieldName)
 

Friends

class PVDataCreate
 
class PVStructure
 

Detailed Description

PVField is the base class for each PVData field.

Each PVData field has an interface that extends PVField.

Definition at line 152 of file pvData.h.

Member Enumeration Documentation

anonymous enum
Enumerator
isPVField 

Definition at line 242 of file pvData.h.

Constructor & Destructor Documentation

epics::pvData::PVField::~PVField ( )
virtual

Destructor

Definition at line 38 of file PVField.cpp.

39 {
40  REFTRACE_DECREMENT(num_instances);
41 }
static size_t num_instances
Definition: pvData.h:241
epics::pvData::PVField::PVField ( FieldConstPtr  field)
explicitprotected

Definition at line 30 of file PVField.cpp.

31 : parent(NULL),field(field),
32  fieldOffset(0), nextFieldOffset(0),
33  immutable(false)
34 {
35  REFTRACE_INCREMENT(num_instances);
36 }
static size_t num_instances
Definition: pvData.h:241
#define NULL
Definition: catime.c:38

Member Function Documentation

void epics::pvData::PVField::copy ( const PVField from)

Definition at line 182 of file PVField.cpp.

183 {
184  if(isImmutable())
185  throw std::invalid_argument("destination is immutable");
186 
187  if (getField() != from.getField())
188  throw std::invalid_argument("field types do not match");
189 
190  copyUnchecked(from);
191 }
const FieldConstPtr & getField() const
Definition: pvData.h:208
void copyUnchecked(const PVField &from)
Definition: PVField.cpp:193
bool isImmutable() const
Definition: pvData.h:198
void epics::pvData::PVField::copyUnchecked ( const PVField from)

Definition at line 193 of file PVField.cpp.

194 {
195  assert(getField()==from.getField());
196 
197  switch(getField()->getType())
198  {
199  case scalar:
200  {
201  const PVScalar* fromS = static_cast<const PVScalar*>(&from);
202  PVScalar* toS = static_cast<PVScalar*>(this);
203  toS->copyUnchecked(*fromS);
204  break;
205  }
206  case scalarArray:
207  {
208  const PVScalarArray* fromS = static_cast<const PVScalarArray*>(&from);
209  PVScalarArray* toS = static_cast<PVScalarArray*>(this);
210  toS->copyUnchecked(*fromS);
211  break;
212  }
213  case structure:
214  {
215  const PVStructure* fromS = static_cast<const PVStructure*>(&from);
216  PVStructure* toS = static_cast<PVStructure*>(this);
217  toS->copyUnchecked(*fromS);
218  break;
219  }
220  case structureArray:
221  {
222  const PVStructureArray* fromS = static_cast<const PVStructureArray*>(&from);
223  PVStructureArray* toS = static_cast<PVStructureArray*>(this);
224  toS->copyUnchecked(*fromS);
225  break;
226  }
227  case union_:
228  {
229  const PVUnion* fromS = static_cast<const PVUnion*>(&from);
230  PVUnion* toS = static_cast<PVUnion*>(this);
231  toS->copyUnchecked(*fromS);
232  break;
233  }
234  case unionArray:
235  {
236  const PVUnionArray* fromS = static_cast<const PVUnionArray*>(&from);
237  PVUnionArray* toS = static_cast<PVUnionArray*>(this);
238  toS->copyUnchecked(*fromS);
239  break;
240  }
241  default:
242  {
243  throw std::logic_error("PVField::copy unknown type");
244  }
245  }
246 }
void copyUnchecked(const PVUnionArray &from)
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
const FieldConstPtr & getField() const
Definition: pvData.h:208
PVValueArray< PVStructurePtr > PVStructureArray
Definition: pvData.h:99
PVValueArray< PVUnionPtr > PVUnionArray
Definition: pvData.h:119
friend class PVStructure
Definition: pvData.h:261
void copyUnchecked(const PVStructureArray &from)
bool epics::pvData::PVField::equals ( PVField pv)
virtual

Is this field equal to another field.

Parameters
pvother field
Returns
(false,true) if (is not,is) equal.

Definition at line 87 of file PVField.cpp.

88 {
89  return pv==*this;
90 }
Definition: tool_lib.h:67
const FieldConstPtr& epics::pvData::PVField::getField ( ) const
inline

Get the Field that describes the field.

Returns
Field, which is the reflection interface.

Definition at line 208 of file pvData.h.

208 {return field;}
const std::string& epics::pvData::PVField::getFieldName ( ) const
inline

Get the fieldName for this field.

Returns
The name or empty string if top-level field.

Definition at line 166 of file pvData.h.

166 {return fieldName;}
size_t epics::pvData::PVField::getFieldOffset ( ) const

Get offset of the PVField field within top-level structure. Every field within the PVStructure has a unique offset. The top-level structure has an offset of 0. The first field within the structure has offset equal to 1. The other offsets are determined by recursively traversing each structure of the tree.

Returns
The offset.

Definition at line 44 of file PVField.cpp.

45 {
46  if(nextFieldOffset==0) computeOffset(this);
47  return fieldOffset;
48 }
string epics::pvData::PVField::getFullName ( ) const

Fully expand the name of this field using the names of its parent fields with a dot '.' separating each name.

Definition at line 97 of file PVField.cpp.

98 {
99  string ret(fieldName);
100  for(const PVField *fld=getParent(); fld; fld=fld->getParent())
101  {
102  if(fld->getFieldName().size()==0) break;
103  ret = fld->getFieldName() + '.' + ret;
104  }
105  return ret;
106 }
PVField(FieldConstPtr field)
Definition: PVField.cpp:30
PVStructure * getParent()
Definition: pvData.h:213
size_t epics::pvData::PVField::getNextFieldOffset ( ) const

Get the next offset. If the field is a scalar or array field then this is just offset + 1. If the field is a structure it is the offset of the next field after this structure. Thus (nextOffset - offset) is always equal to the number of fields within the field.

Returns
The offset.

Definition at line 50 of file PVField.cpp.

51 {
52  if(nextFieldOffset==0) computeOffset(this);
53  return nextFieldOffset;
54 }
size_t epics::pvData::PVField::getNumberFields ( ) const

Get the total number of fields in this field. This is equal to nextFieldOffset - fieldOffset.

Definition at line 56 of file PVField.cpp.

57 {
58  if(nextFieldOffset==0) computeOffset(this);
59  return (nextFieldOffset - fieldOffset);
60 }
PVStructure* epics::pvData::PVField::getParent ( )
inline

Get the parent of this field.

Returns
The parent interface or null if this is PVRecord

Definition at line 213 of file pvData.h.

213 {return parent;}
const PVStructure* epics::pvData::PVField::getParent ( ) const
inline

Definition at line 214 of file pvData.h.

214 {return parent;}
PVField::shared_pointer epics::pvData::PVField::getPtrSelf ( )
inlineprotected

Definition at line 244 of file pvData.h.

245  {
246  return shared_from_this();
247  }
bool epics::pvData::PVField::isImmutable ( ) const
inline

Is the field immutable, i.e. does it not allow changes.

Returns
(false,true) if it (is not, is) immutable.

Definition at line 198 of file pvData.h.

198 {return immutable;}
epics::pvData::PVField::POINTER_DEFINITIONS ( PVField  )
void epics::pvData::PVField::postPut ( )

postPut. Called when the field is updated by the implementation.

Definition at line 65 of file PVField.cpp.

66 {
67  if(postHandler) postHandler->postPut();
68 }
void epics::pvData::PVField::setImmutable ( )
virtual

Set the field to be immutable, i.e. it can no longer be modified. This is permanent, i.e. once done the field cannot be made mutable.

Reimplemented in epics::pvData::PVStructure, and epics::pvData::PVArray.

Definition at line 63 of file PVField.cpp.

63 {immutable = true;}
void epics::pvData::PVField::setParentAndName ( PVStructure parent,
std::string const &  fieldName 
)
protected

Definition at line 81 of file PVField.cpp.

82 {
83  parent = xxx;
84  fieldName = name;
85 }
void epics::pvData::PVField::setPostHandler ( PostHandlerPtr const &  postHandler)

Set the handler for postPut. At most one handler can be set.

Parameters
postHandlerThe handler.

Definition at line 70 of file PVField.cpp.

71 {
72  if(postHandler) {
73  if(postHandler.get()==handler.get()) return;
74  throw std::logic_error(
75  "PVField::setPostHandler a postHandler is already registered");
76 
77  }
78  postHandler = handler;
79 }

Friends And Related Function Documentation

friend class PVDataCreate
friend

Definition at line 260 of file pvData.h.

friend class PVStructure
friend

Definition at line 261 of file pvData.h.

Member Data Documentation

size_t epics::pvData::PVField::num_instances
static

Definition at line 241 of file pvData.h.


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