epics-base / pvDataCPP

pvDataCPP is an EPICS V4 C++ module
https://epics-base.github.io/pvDataCPP/
Other
6 stars 16 forks source link

add serializeToVector() #17

Closed mdavidsaver closed 8 years ago

mdavidsaver commented 8 years ago

serializeToVector() takes an arbitrary subclass of Serializable to do so, with the results placed in a byte array (vector). No type information caching is performed as the code to do this is presently in pvAccessCPP.

I wrote serializeToVector() for the new gateway to provide a key for a lookup table to de-duplicate requests having idential pvrequest blobs. I was concerned that, while operator< could be implemented for PVStructure for use with key std::map, this wouldn't be efficient. This would be the ideal situation for a hash table, but PVField sub-classes also doesn't define a hash function, and I can't easily use std::unordered_map anyway.

While this code began like as a workaround, I think it can function as a useful example of operating on Serialization. If it isn't accepted here I'll pull it into the gateway.

msekoranja commented 8 years ago

Looks good to me (it's an additional functionality).

mdavidsaver commented 8 years ago

Rebased and added deserializeFromVector() and deserializeFromBuffer() to match.

mdavidsaver commented 8 years ago

Updated comments as requested