Class Union¶
Defined in File pvIntrospect.h
Inheritance Relationships¶
Base Type¶
public epics::pvData::Field
(Class Field)
Class Documentation¶
-
class Union : public epics::pvData::Field¶
This class implements introspection object for a union.
Public Functions
-
virtual ~Union()¶
-
inline std::size_t getNumberFields() const¶
Get the number of immediate subfields in the union.
- Returns
The number of fields.
-
FieldConstPtr 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.
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.
-
inline FieldConstPtr getFieldT(std::string const &fieldName) const¶
Lookup Field by name
- Parameters
fieldName – Member field name. May not contain ‘.’
- Throws
std::runtime_error – If no member by this name
- Returns
Field pointer (never NULL)
Lookup Field by name and cast to Field sub-class.
- Parameters
fieldName – Member field name. May not contain ‘.’
- Throws
std::runtime_error – If no member by this name, or member exists, but has type other than FT.
- Returns
Field pointer (never NULL)
-
inline FieldConstPtr getField(std::size_t index) const¶
Lookup Field by index, within this Union.
- Parameters
index – Index of member in this union.
index>=0 && index<getNumberFields()
- Throws
std::out_of_range – If index >= getNumberFields()
- Returns
Field pointer (never NULL)
Lookup Field by index, within this Union.
- Parameters
index – Index of member in this union.
index>=0 && index<getNumberFields()
- Throws
std::out_of_range – If index >= getNumberFields()
- Returns
NULL if member is not a sub-class of FT
-
inline FieldConstPtr getFieldT(std::size_t index) const¶
Lookup Field by index, within this Union.
- Parameters
index – Index of member in this union.
index>=0 && index<getNumberFields()
- Throws
std::out_of_range – If index >= getNumberFields()
- Returns
Field pointer (never NULL)
Lookup Field by index, within this Structure.
- Parameters
index – Index of member in this structure.
index>=0 && index<getNumberFields()
- Throws
std::out_of_range – If index >= getNumberFields()
std::runtime_error – If member is not a sub-class of FT
- Returns
Field pointer (never NULL)
-
std::size_t 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.
-
inline FieldConstPtrArray const &getFields() const¶
Get the fields in the union.
- Returns
The array of fields.
-
inline StringArray const &getFieldNames() const¶
Get the names of the fields in the union.
- Returns
The array of fieldNames.
-
inline std::string getFieldName(std::size_t fieldIndex) const¶
Get the name of the field with the specified index;
- Parameters
fieldIndex – The index of the desired field.
- Returns
The fieldName.
-
inline bool isVariant() const¶
Check if this union is variant union (aka any type).
- Returns
true
if this union is variant union, otherwisefalse
.
-
int32 guess(Type t, ScalarType s) const¶
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
-
virtual std::string getID() const¶
Get the identification string.
- Returns
The identification string, can be empty.
-
virtual std::ostream &dump(std::ostream &o) const¶
Puts the string representation to the stream.
- Parameters
o – output stream.
- Returns
The output stream.
-
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const¶
Serialize field into given buffer.
- Parameters
buffer – serialization buffer.
flusher – flush interface.
-
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control)¶
Deserialize buffer.
- Parameters
buffer – serialization buffer.
flusher – deserialization control.
Public Static Functions
-
static const std::string &defaultId()¶
Get the default union ID.
- Returns
The default union ID.
-
static const std::string &anyId()¶
Get the default variant union ID.
- Returns
The default variant union ID.
Public Static Attributes
Protected Functions
-
Union()¶
-
Union(StringArray const &fieldNames, FieldConstPtrArray const &fields, std::string const &id = defaultId())¶
-
virtual ~Union()¶