This class implements introspection object for a union.
More...
#include "pvIntrospect.h"
This class implements introspection object for a union.
Definition at line 866 of file pvIntrospect.h.
epics::pvData::Union::~Union |
( |
| ) |
|
|
virtual |
epics::pvData::Union::Union |
( |
| ) |
|
|
protected |
const string & epics::pvData::Union::anyId |
( |
| ) |
|
|
static |
Get the default variant union ID.
- Returns
- The default variant union ID.
Definition at line 676 of file FieldCreateFactory.cpp.
678 static const string id =
"any";
std::tr1::shared_ptr< PVUnion > epics::pvData::Union::build |
( |
| ) |
const |
Allocate a new instance
- Version
- Added after 7.0.0
Definition at line 882 of file FieldCreateFactory.cpp.
884 return getPVDataCreate()->createPVUnion(std::tr1::static_pointer_cast<const Union>(shared_from_this()));
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
const string & epics::pvData::Union::defaultId |
( |
| ) |
|
|
static |
Get the default union ID.
- Returns
- The default union ID.
Definition at line 668 of file FieldCreateFactory.cpp.
670 static const string id =
"union";
Deserialize buffer.
- Parameters
-
buffer | serialization buffer. |
flusher | deserialization control. |
Implements epics::pvData::Serializable.
Definition at line 878 of file FieldCreateFactory.cpp.
879 throw std::runtime_error(
"not valid operation, use FieldCreate::deserialize instead");
std::ostream & epics::pvData::Union::dump |
( |
std::ostream & |
o | ) |
const |
|
virtual |
Puts the string representation to the stream.
- Parameters
-
- Returns
- The output stream.
Implements epics::pvData::Field.
Definition at line 812 of file FieldCreateFactory.cpp.
814 o << format::indent() <<
getID() << std::endl;
816 format::indent_scope s(o);
virtual std::string getID() const OVERRIDE FINAL
FieldConstPtr epics::pvData::Union::getField |
( |
std::string const & |
fieldName | ) |
const |
Lookup Field by name
- Parameters
-
fieldName | Member field name. May not contain '.' |
- Returns
- NULL if no member by this name.
template<typename FT >
std::tr1::shared_ptr<const FT> epics::pvData::Union::getField |
( |
std::string const & |
fieldName | ) |
const |
|
inline |
Lookup Field by name and cast to Field sub-class.
- Parameters
-
fieldName | Member field name. May not contain '.' |
- Returns
- NULL If no member by this name, or member exists, but has type other than FT.
Definition at line 914 of file pvIntrospect.h.
#define STATIC_ASSERT(expr)
Declare a condition that should be true at compile-time.
FieldConstPtr getField(std::string const &fieldName) const
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
FieldConstPtr epics::pvData::Union::getField |
( |
std::size_t |
index | ) |
const |
|
inline |
Lookup Field by index, within this Union.
- Parameters
-
index | Index of member in this union. |
- Returns
- Field pointer (never NULL)
- Exceptions
-
Definition at line 952 of file pvIntrospect.h.
952 {
return fields.at(index);}
template<typename FT >
std::tr1::shared_ptr<const FT> epics::pvData::Union::getField |
( |
std::size_t |
index | ) |
const |
|
inline |
Lookup Field by index, within this Union.
- Parameters
-
index | Index of member in this union. |
- Returns
- NULL if member is not a sub-class of FT
- Exceptions
-
Definition at line 960 of file pvIntrospect.h.
#define STATIC_ASSERT(expr)
Declare a condition that should be true at compile-time.
FieldConstPtr getField(std::string const &fieldName) const
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
size_t epics::pvData::Union::getFieldIndex |
( |
std::string const & |
fieldName | ) |
const |
Get the field index for the specified fieldName.
- Returns
- The introspection interface. This will be -1 if the field is not in the union.
Definition at line 787 of file FieldCreateFactory.cpp.
788 size_t numberFields = fields.size();
789 for(
size_t i=0;
i<numberFields;
i++) {
791 int result = fieldName.compare(fieldNames[
i]);
792 if(result==0)
return i;
std::tr1::shared_ptr< const Field > FieldConstPtr
std::string epics::pvData::Union::getFieldName |
( |
std::size_t |
fieldIndex | ) |
const |
|
inline |
Get the name of the field with the specified index;
- Parameters
-
fieldIndex | The index of the desired field. |
- Returns
- The fieldName.
Definition at line 1014 of file pvIntrospect.h.
1014 {
return fieldNames.at(fieldIndex);}
StringArray const& epics::pvData::Union::getFieldNames |
( |
| ) |
const |
|
inline |
Get the names of the fields in the union.
- Returns
- The array of fieldNames.
Definition at line 1008 of file pvIntrospect.h.
1008 {
return fieldNames;}
Get the fields in the union.
- Returns
- The array of fields.
Definition at line 1003 of file pvIntrospect.h.
FieldConstPtr epics::pvData::Union::getFieldT |
( |
std::string const & |
fieldName | ) |
const |
|
inline |
Lookup Field by name
- Parameters
-
fieldName | Member field name. May not contain '.' |
- Returns
- Field pointer (never NULL)
- Exceptions
-
std::runtime_error | If no member by this name |
Definition at line 926 of file pvIntrospect.h.
926 {
return getFieldImpl(fieldName,
true);};
template<typename FT >
std::tr1::shared_ptr<const FT> epics::pvData::Union::getFieldT |
( |
std::string const & |
fieldName | ) |
const |
|
inline |
Lookup Field by name and cast to Field sub-class.
- Parameters
-
fieldName | Member field name. May not contain '.' |
- Returns
- Field pointer (never NULL)
- Exceptions
-
std::runtime_error | If no member by this name, or member exists, but has type other than FT. |
Definition at line 934 of file pvIntrospect.h.
937 std::tr1::shared_ptr<const FT>
result(
938 std::tr1::dynamic_pointer_cast<const FT>(
getFieldT(fieldName))
942 throw std::runtime_error(
"Wrong Field type");
FieldConstPtr getFieldT(std::string const &fieldName) const
#define STATIC_ASSERT(expr)
Declare a condition that should be true at compile-time.
FieldConstPtr epics::pvData::Union::getFieldT |
( |
std::size_t |
index | ) |
const |
|
inline |
Lookup Field by index, within this Union.
- Parameters
-
index | Index of member in this union. |
- Returns
- Field pointer (never NULL)
- Exceptions
-
Definition at line 971 of file pvIntrospect.h.
971 {
return fields.at(index);}
template<typename FT >
std::tr1::shared_ptr<const FT> epics::pvData::Union::getFieldT |
( |
std::size_t |
index | ) |
const |
|
inline |
Lookup Field by index, within this Structure.
- Parameters
-
index | Index of member in this structure. |
- Returns
- Field pointer (never NULL)
- Exceptions
-
std::out_of_range | If index >= getNumberFields() |
std::runtime_error | If member is not a sub-class of FT |
Definition at line 980 of file pvIntrospect.h.
983 std::tr1::shared_ptr<const FT>
result(
984 std::tr1::dynamic_pointer_cast<const FT>(
getFieldT(index))
988 throw std::runtime_error(
"Wrong Field type");
FieldConstPtr getFieldT(std::string const &fieldName) const
#define STATIC_ASSERT(expr)
Declare a condition that should be true at compile-time.
string epics::pvData::Union::getID |
( |
| ) |
const |
|
virtual |
std::size_t epics::pvData::Union::getNumberFields |
( |
| ) |
const |
|
inline |
Get the number of immediate subfields in the union.
- Returns
- The number of fields.
Definition at line 900 of file pvIntrospect.h.
900 {
return fieldNames.size();}
Attempt to find an suitable member to stored the specified type.
Returned index is guerenteed to by of specified Type (either scalar or scalarArray). Provided ScalarType is taken as a hint.
- Parameters
-
t | Must be either scalar or scalarArray |
s | The preferred ScalarType |
- Returns
- A valid index or -1
Definition at line 736 of file FieldCreateFactory.cpp.
739 THROW_EXCEPTION2(std::logic_error,
"PVUnion::guess() only support scalar and scalarArray");
742 for(
size_t i=0, N=fields.size();
i<N;
i++)
750 type =
static_cast<const Scalar*
>(fields[
i].get())->
getScalarType();
753 type =
static_cast<const ScalarArray*
>(fields[
i].get())->getElementType();
#define THROW_EXCEPTION2(TYPE, MSG)
ScalarType getScalarType(const string &pvalue)
pvd::StructureConstPtr type
bool epics::pvData::Union::isVariant |
( |
| ) |
const |
|
inline |
Check if this union is variant union (aka any type).
- Returns
true
if this union is variant union, otherwise false
.
Definition at line 1019 of file pvIntrospect.h.
1019 {
return (fieldNames.size() == 0);}
epics::pvData::Union::POINTER_DEFINITIONS |
( |
Union |
| ) |
|
Serialize field into given buffer.
- Parameters
-
buffer | serialization buffer. |
flusher | flush interface. |
Implements epics::pvData::Serializable.
Definition at line 864 of file FieldCreateFactory.cpp.
865 control->ensureBuffer(1);
866 if (fields.size() == 0)
869 buffer->putByte((
int8)0x82);
873 buffer->putByte((
int8)0x81);
874 serializeUnionField(
this, buffer, control);
The documentation for this class was generated from the following files: