15 #define epicsExportSharedSymbols 25 namespace epics {
namespace pvData {
27 #define PVUNION_UNDEFINED_INDEX -1 37 variant(unionPtr->isVariant())
41 #undef PVUNION_UNDEFINED_INDEX 51 return unionPtr->getFieldName(selector);
57 throw std::invalid_argument(
"index out of bounds");
60 if (selector == index && !variant)
69 else if (index < 0 ||
size_t(index) >= unionPtr->getFields().size())
70 throw std::invalid_argument(
"index out of bounds");
74 value = pvDataCreate->createPVField(field);
81 int32 index = variant ? -1 :
static_cast<int32>(unionPtr->getFieldIndex(fieldName));
83 throw std::invalid_argument(
"no such fieldName");
90 throw std::invalid_argument(
"index out of bounds");
97 throw std::invalid_argument(
"non-null value for index == UNDEFINED_INDEX");
99 else if (index < 0 ||
size_t(index) >= unionPtr->getFields().size())
100 throw std::invalid_argument(
"index out of bounds");
102 throw std::invalid_argument(
"Can't set defined index w/ NULL");
103 else if (value->getField() != unionPtr->getField(index))
104 throw std::invalid_argument(
"selected field and its introspection data do not match");
114 int32 index = variant ? -1 :
static_cast<int32>(unionPtr->getFieldIndex(fieldName));
116 throw std::invalid_argument(
"no such fieldName");
126 if (value.get() == 0) {
131 value->serialize(pbuffer, pflusher);
140 value->serialize(pbuffer, pflusher);
152 if (!value.get() || *value->getField() != *field)
153 value = pvDataCreate->createPVField(field);
154 value->deserialize(pbuffer, pcontrol);
161 int32 previousSelector = selector;
165 if (selector != previousSelector)
169 if (!value.get() || *value->getField() != *field)
170 value = pvDataCreate->createPVField(field);
172 value->deserialize(pbuffer, pcontrol);
184 const PVField::const_shared_pointer& fieldField =
get();
185 if (fieldField.get() ==
NULL)
189 Type type = fieldField->getField()->getType();
191 o <<
format::indent() << fieldField->getField()->getID() <<
' ' << fieldField->getFieldName() <<
' ' << *(fieldField.get()) << std::endl;
193 o << *(fieldField.get());
202 throw std::invalid_argument(
"destination is immutable");
205 throw std::invalid_argument(
"union definitions do not match");
213 const PVField::const_shared_pointer& fromValue = from.
get();
216 if (fromValue.get() == 0)
218 set(PVField::shared_pointer());
223 if (toValue.get() == 0 || *toValue->getField() != *fromValue->getField())
225 toValue = pvDataCreate->createPVField(fromValue->getField());
226 toValue->copyUnchecked(*fromValue);
231 toValue->copyUnchecked(*fromValue);
238 if (fromValue.get() == 0)
240 select(PVUnion::UNDEFINED_INDEX);
const std::string & getFieldName() const
#define PVUNION_UNDEFINED_INDEX
virtual std::ostream & dumpValue(std::ostream &o) const OVERRIDE FINAL
int32 getSelectedIndex() const
const UnionConstPtr & getUnion() const
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
pvd::StructureConstPtr type
TODO only here because of the Lockable.
static void writeSize(std::size_t s, ByteBuffer *buffer, SerializableControl *flusher)
static std::size_t readSize(ByteBuffer *buffer, DeserializableControl *control)
Callback class for deserialization.
PVField is the base class for each PVData field.
PVUnion(UnionConstPtr const &punion)
std::string getSelectedFieldName() const
std::tr1::shared_ptr< PVDataCreate > PVDataCreatePtr
virtual std::tr1::shared_ptr< const Field > cachedDeserialize(ByteBuffer *buffer)=0
std::tr1::shared_ptr< const Union > UnionConstPtr
virtual void deserialize(ByteBuffer *pbuffer, DeserializableControl *pflusher) OVERRIDE FINAL
This class implements a Bytebuffer that is like the java.nio.ByteBuffer.
PVUnion has a single subfield.
void copy(const PVUnion &from)
std::tr1::shared_ptr< const Field > FieldConstPtr
void set(PVFieldPtr const &value)
virtual void cachedSerialize(std::tr1::shared_ptr< const Field > const &field, ByteBuffer *buffer)=0
PVFieldPtr select(int32 index)
virtual void serialize(ByteBuffer *pbuffer, SerializableControl *pflusher) const OVERRIDE FINAL
std::tr1::shared_ptr< PVField > PVFieldPtr
virtual void ensureBuffer(std::size_t size)=0
Callback class for serialization.
void copyUnchecked(const PVUnion &from)
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
static const int32 UNDEFINED_INDEX