Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add PVRequestMapper #56

Merged
merged 1 commit into from
Sep 21, 2018
Merged

Conversation

mdavidsaver
Copy link
Member

Utility for pvRequest .field mangling in ChannelProvider implementations, either my or @mrkraimer preferred schemes can be selected with an enum. As per #51 this API is intended as a replacement of pvCopy, and the simpler extractRequestMask() I added previously.

A PVRequestMapper holds a precomputed mapping between two Structures, referred to as "Base" and "Requested".

  • Base - The internal structure manipulated by server/provider logic.
  • Requested - The structure seen by user/client code.

The API itself revolves around the PVRequestMapper::copyBaseToRequested() and PVRequestMapper::copyBaseFromRequested() methods which allow masked shallow copying between PVStructures of the two types.

So a minimal usage would look like

// eg. during ChannelGet setup
PVStructurePtr mybase = ...; // some server internal structure
PVStructurePtr pvRequest = ...; // A client provided request

PVRequestMapper mapper(*mybase, *pvRequest); // precompute mapping and save for later use

// ... eg. later during ChannelGet::get()

BitSet valid = ...; // those fields of mybase which may actually be sent. (eg. having non-default values)
BitSet uvalid; // mapping of bit mask onto Requested Structure
PVStructurePtr userval(mapper.buildRequested());

mapper.copyBaseToRequested(*mybase, valid, *userval, uvalid); // copying.  userval and uvalid modified

There are a couple of differences in behavior vs. pvCopy which I know of (and probably some I don't).

  • This code will warn if requesting some non-existent fields, and only error if none of the requested fields exist. This is intended to allow clients to request optional fields.
  • By default, structures which are "Sliced"d will lose their type ID string. This is controllable via an option eg. "record[keepIDs=true]".
  • The pvRequest represented as "" is treated identically to "field()", aka. wildcard. pvCopy treats this as an empty request (no fields). As a side effect this makes it impossible to make an empty request.
  • There is an arbitrary depth limit to pvRequest '.field' selections (currently 5 levels). This is a safe guard of the recursive implementation. Attempting to exceeding the depth limit selects the entire 4th level parent structure (and warns).

Currently this API has been added in the SharedPV (aka. simplified server api) in pvAccessCPP. cf. https://github.com/mdavidsaver/pvAccessCPP/tree/inprog . I'm planning to use it as well in QSRV, and perhaps P2P.

utility to having pvRequest .field mangling

Warn if requesting some non-existant fields.
Error if no requested fields exist.

PVRequestMapper mode enum to select between
two "styles" of interpretation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant