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

Class that holds the data for each possible scalar type. More...

#include "pvData.h"

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

Public Types

typedef T value_type
 
typedef T * pointer
 
typedef const T * const_pointer
 
- Public Types inherited from epics::pvData::PVScalar
typedef PVScalarreference
 
typedef const PVScalarconst_reference
 
- Public Types inherited from epics::pvData::PVField
enum  { isPVField =1 }
 

Public Member Functions

 POINTER_DEFINITIONS (PVScalarValue)
 
virtual ~PVScalarValue ()
 
storage_t::arg_type get () const
 
void put (typename storage_t::arg_type v)
 
virtual std::ostream & dumpValue (std::ostream &o) const OVERRIDE
 
virtual void operator>>= (T &value) const
 
virtual void operator<<= (typename storage_t::arg_type value)
 
template<typename T1 >
T1 getAs () const
 
template<typename T1 >
void putFrom (typename detail::ScalarStorageOps< T1 >::arg_type val)
 
void putFrom (const AnyScalar &v)
 
virtual void assign (const PVScalar &scalar) OVERRIDE FINAL
 
virtual void copy (const PVScalar &from) OVERRIDE FINAL
 
virtual void copyUnchecked (const PVScalar &from) OVERRIDE FINAL
 
virtual void serialize (ByteBuffer *pbuffer, SerializableControl *pflusher) const OVERRIDE
 
virtual void deserialize (ByteBuffer *pbuffer, DeserializableControl *pflusher) OVERRIDE FINAL
 
virtual void getAs (AnyScalar &v) const OVERRIDE FINAL
 
virtual void putFrom (const void *src, ScalarType stype) OVERRIDE FINAL
 Convert and assign. More...
 
template<>
const ScalarType typeCode
 
template<>
void serialize (ByteBuffer *pbuffer, SerializableControl *pflusher) const
 
template<>
void deserialize (ByteBuffer *pbuffer, DeserializableControl *pflusher)
 
template<>
std::ostream & dumpValue (std::ostream &o) const
 Some explicit specializations exist. More...
 
template<>
std::ostream & dumpValue (std::ostream &o) const
 
template<>
std::ostream & dumpValue (std::ostream &o) const
 
- Public Member Functions inherited from epics::pvData::PVScalar
 POINTER_DEFINITIONS (PVScalar)
 
virtual ~PVScalar ()
 
const ScalarConstPtr getScalar () const
 
template<typename T >
getAs () const
 
template<typename T >
void putFrom (T val)
 
void putFrom (const AnyScalar &v)
 
- 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
 
virtual void setImmutable ()
 
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 ()
 

Static Public Attributes

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

Protected Member Functions

 PVScalarValue (ScalarConstPtr const &scalar)
 
virtual void getAs (void *result, ScalarType rtype) const OVERRIDE FINAL
 
- Protected Member Functions inherited from epics::pvData::PVScalar
 PVScalar (ScalarConstPtr const &scalar)
 
- 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

storage_t storage
 

Friends

class PVDataCreate
 

Detailed Description

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

Class that holds the data for each possible scalar type.

Definition at line 54 of file pvData.h.

Member Typedef Documentation

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

Definition at line 384 of file pvData.h.

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

Definition at line 383 of file pvData.h.

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

Definition at line 382 of file pvData.h.

Constructor & Destructor Documentation

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

Destructor

Definition at line 62 of file PVDataCreateFactory.cpp.

62 {}
template<typename T>
epics::pvData::PVScalarValue< T >::PVScalarValue ( ScalarConstPtr const &  scalar)
inlineexplicitprotected

Definition at line 444 of file pvData.h.

445  : PVScalar(scalar), storage() {}
PVScalar(ScalarConstPtr const &scalar)
Definition: PVScalar.cpp:24

Member Function Documentation

template<typename T >
void epics::pvData::PVScalarValue< T >::assign ( const PVScalar scalar)
virtual

Implements epics::pvData::PVScalar.

Definition at line 83 of file PVDataCreateFactory.cpp.

84 {
85  if(isImmutable())
86  throw std::invalid_argument("destination is immutable");
88 }
virtual void copyUnchecked(const PVScalar &from) OVERRIDE FINAL
bool isImmutable() const
Definition: pvData.h:198
template<typename T >
void epics::pvData::PVScalarValue< T >::copy ( const PVScalar from)
virtual

Implements epics::pvData::PVScalar.

Definition at line 91 of file PVDataCreateFactory.cpp.

92 {
93  assign(from);
94 }
virtual void assign(const PVScalar &scalar) OVERRIDE FINAL
template<typename T >
void epics::pvData::PVScalarValue< T >::copyUnchecked ( const PVScalar from)
virtual

Implements epics::pvData::PVScalar.

Definition at line 97 of file PVDataCreateFactory.cpp.

98 {
99  if(this==&from)
100  return;
101  T result;
102  from.getAs((void*)&result, typeCode);
103  put(result);
104 }
pvac::PutEvent result
Definition: clientSync.cpp:117
void put(typename storage_t::arg_type v)
Definition: pvData.h:401
template<>
void epics::pvData::PVScalarValue< std::string >::deserialize ( ByteBuffer buffer,
DeserializableControl flusher 
)
virtual

Deserialize buffer.

Parameters
bufferserialization buffer.
flusherdeserialization control.

Implements epics::pvData::Serializable.

Definition at line 128 of file PVDataCreateFactory.cpp.

130 {
132  // TODO: check for violations of maxLength?
133 }
static std::string deserializeString(ByteBuffer *buffer, DeserializableControl *control)
char * pbuffer
Definition: errlog.c:85
template<typename T >
void epics::pvData::PVScalarValue< T >::deserialize ( ByteBuffer buffer,
DeserializableControl flusher 
)
virtual

Deserialize buffer.

Parameters
bufferserialization buffer.
flusherdeserialization control.

Implements epics::pvData::Serializable.

Definition at line 120 of file PVDataCreateFactory.cpp.

122 {
123  pflusher->ensureData(sizeof(T));
124  storage.value = pbuffer->GET(T);
125 }
char * pbuffer
Definition: errlog.c:85
template<typename T >
std::ostream & epics::pvData::PVScalarValue< 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.

Reimplemented in epics::pvData::PVString.

Definition at line 65 of file PVDataCreateFactory.cpp.

66 {
67  return o << get();
68 }
template<>
std::ostream & epics::pvData::PVScalarValue< int8 >::dumpValue ( std::ostream &  o) const
inlinevirtual

Some explicit specializations exist.

Implements epics::pvData::PVField.

Definition at line 473 of file pvData.h.

474 {
475  return o << static_cast<int>(get());
476 }
template<>
std::ostream & epics::pvData::PVScalarValue< uint8 >::dumpValue ( std::ostream &  o) const
inlinevirtual

Puts the PVField raw value to the stream.

Parameters
ooutput stream.
Returns
The output stream.

Implements epics::pvData::PVField.

Definition at line 479 of file pvData.h.

480 {
481  return o << static_cast<unsigned int>(get());
482 }
template<>
std::ostream & epics::pvData::PVScalarValue< boolean >::dumpValue ( std::ostream &  o) const
inlinevirtual

Puts the PVField raw value to the stream.

Parameters
ooutput stream.
Returns
The output stream.

Implements epics::pvData::PVField.

Definition at line 485 of file pvData.h.

486 {
487  return o << std::boolalpha << static_cast<bool>(get());
488 }
template<typename T>
storage_t::arg_type epics::pvData::PVScalarValue< T >::get ( ) const
inline

Get the value.

Returns
The value.

Definition at line 396 of file pvData.h.

template<typename T>
template<typename T1 >
T1 epics::pvData::PVScalarValue< T >::getAs ( ) const
inline

Definition at line 419 of file pvData.h.

419  {
420  T1 result(castUnsafe<T1,T>(get()));
421  return result;
422  }
pvac::PutEvent result
Definition: clientSync.cpp:117
template<typename T>
virtual void epics::pvData::PVScalarValue< T >::getAs ( void *  result,
ScalarType  rtype 
) const
inlineprotectedvirtual

Implements epics::pvData::PVScalar.

Definition at line 446 of file pvData.h.

447  {
448  const T src = get();
449  castUnsafeV(1, rtype, result, typeCode, (const void*)&src);
450  }
pvac::PutEvent result
Definition: clientSync.cpp:117
epicsShareExtern void castUnsafeV(size_t count, ScalarType to, void *dest, ScalarType from, const void *src)
Definition: typeCast.cpp:72
template<typename T>
virtual void epics::pvData::PVScalarValue< T >::getAs ( AnyScalar v) const
inlinevirtual

Implements epics::pvData::PVScalar.

Definition at line 452 of file pvData.h.

453  {
454  v = get();
455  }
template<typename T >
void epics::pvData::PVScalarValue< T >::operator<<= ( typename storage_t::arg_type  value)
virtual

Definition at line 77 of file PVDataCreateFactory.cpp.

78 {
79  put(value);
80 }
Definition: link.h:174
void put(typename storage_t::arg_type v)
Definition: pvData.h:401
template<typename T>
void epics::pvData::PVScalarValue< T >::operator>>= ( T &  value) const
virtual

Definition at line 71 of file PVDataCreateFactory.cpp.

72 {
73  value = get();
74 }
Definition: link.h:174
template<typename T>
epics::pvData::PVScalarValue< T >::POINTER_DEFINITIONS ( PVScalarValue< T >  )
template<typename T>
void epics::pvData::PVScalarValue< T >::put ( typename storage_t::arg_type  v)
inline

Put a new value into the PVScalar.

Parameters
valueThe value.

Definition at line 401 of file pvData.h.

401  {
402  storage.store(v);
404  }
template<typename T>
template<typename T1 >
void epics::pvData::PVScalarValue< T >::putFrom ( typename detail::ScalarStorageOps< T1 >::arg_type  val)
inline

Definition at line 425 of file pvData.h.

425  {
426  put(castUnsafe<T,T1>(val));
427  }
void put(typename storage_t::arg_type v)
Definition: pvData.h:401
template<typename T>
void epics::pvData::PVScalarValue< T >::putFrom ( const AnyScalar v)
inline

Definition at line 429 of file pvData.h.

429  {
430  // the template form of putFrom() hides the base class AnyScalar overload
432  }
void putFrom(T val)
Definition: pvData.h:324
template<typename T>
virtual void epics::pvData::PVScalarValue< T >::putFrom ( const void *  ,
ScalarType   
)
inlinevirtual

Convert and assign.

Implements epics::pvData::PVScalar.

Definition at line 456 of file pvData.h.

457  {
458  T result;
459  castUnsafeV(1, typeCode, (void*)&result, stype, src);
460  put(result);
461  }
pvac::PutEvent result
Definition: clientSync.cpp:117
void put(typename storage_t::arg_type v)
Definition: pvData.h:401
epicsShareExtern void castUnsafeV(size_t count, ScalarType to, void *dest, ScalarType from, const void *src)
Definition: typeCast.cpp:72
template<>
void epics::pvData::PVScalarValue< std::string >::serialize ( ByteBuffer buffer,
SerializableControl flusher 
) const
virtual

Serialize field into given buffer.

Parameters
bufferserialization buffer.
flusherflush interface.

Implements epics::pvData::Serializable.

Definition at line 114 of file PVDataCreateFactory.cpp.

115  {
117 }
static void serializeString(const std::string &value, ByteBuffer *buffer, SerializableControl *flusher)
char * pbuffer
Definition: errlog.c:85
template<typename T >
void epics::pvData::PVScalarValue< T >::serialize ( ByteBuffer buffer,
SerializableControl flusher 
) const
virtual

Serialize field into given buffer.

Parameters
bufferserialization buffer.
flusherflush interface.

Implements epics::pvData::Serializable.

Reimplemented in epics::pvData::PVString.

Definition at line 107 of file PVDataCreateFactory.cpp.

108  {
109  pflusher->ensureBuffer(sizeof(T));
110  pbuffer->put(storage.value);
111 }
char * pbuffer
Definition: errlog.c:85
template<>
const ScalarType epics::pvData::PVScalarValue< string >::typeCode ( )

Definition at line 45 of file PVDataCreateFactory.cpp.

Friends And Related Function Documentation

template<typename T>
friend class PVDataCreate
friend

Definition at line 464 of file pvData.h.

Member Data Documentation

template<typename T>
storage_t epics::pvData::PVScalarValue< T >::storage
protected

Definition at line 465 of file pvData.h.

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

Definition at line 386 of file pvData.h.


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