V4 View Generated Code

From EPICSWIKI
Revision as of 04:37, 13 July 2005 by AndrewJohnson (talk | contribs) (First attempt, based on old DataAccess interfaces)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This page shows the code that will be generated from a Record View.

Each view maps to a separate property catalog that gives access to a particular set of fields of the record as a hierarchy. Taking as a simple example the following record definition:

record(rdouble) extends iocRecord {
    field(value, float64)
    field(units, string)
    view(value) {
        property(value, value) {
            property(units, units)
            property(timestamp, timeStamp)
            property(alarmSeverity, alarmSeverity)
            property(alarmStatus, alarmStatus)
        }
    }
}

This very simple record type defines a single value view with 5 properties, of which 4 are subordinate to the main value property. The following code would be generated from the above DBD definition to implement the view as a property catalog for use by the Data Access interface to the CA Server:

class rdouble_view_value_value : public propertyCatalog {
public:
    rdouble_view_value_value(rdoubleRecord &record);
    void traverse(dataViewer &);
    // this isn't exactly Jeff's interface, but it shows the idea
private:
    rdoubleRecord &r;
};
rdouble_view_value_value::rdouble_view_value_value(rdoubleRecord &r_in)
    : r(r_in) {}
void rdouble_cat_value_value::traverse(dataViewer & v) {
    v.reveal(pidUnits, r.units);
    v.reveal(pidTimestamp, r.timestamp);
    v.reveal(pidAlarmSeverity, r.alarmSeverity);
    v.reveal(pidAlarmStatus, r.alarmStatus);
}
class rdouble_view_value : public propertyCatalog {
public:
    rdouble_view_value(rdoubleRecord &record);
    void traverse(dataViewer &);
    // this isn't exactly Jeff's interface, but it shows the idea
private:
    rdoubleRecord &r;
    rdouble_view_value_value view_value_value;
};
rdouble_view_value::rdouble_view_value(rdoubleRecord &r_in)
    : r(r_in), view_value_value(r_in) {}
void rdouble_cat_value::traverse(dataViewer & v) {
    v.reveal(pidValue, r.value, view_value_value);
}