Entry and Derived Data Members
Server lets you declare active values. An active value is an object attribute whose value depends on, or is a function of, other attributes. Server makes a distinction between two types of data members: derived data members and entry data members.
-
Derived members (or active values) are associated with an evaluation function (that is, a formula). The function can be a sum, a consolidation, an alarm, and the like. The value of derived members depends on the value of other attributes called entries. When the attributes making up a formula are modified, the associated derived member is automatically recomputed. This means that derived members can never be modified directly.
Note A derived member is re-evaluated on demand and only if necessary.
-
Unlike derived members, entry data members are not associated with an evaluation function: Their value can be accessed and modified directly. The modification of an entry triggers the recomputation of the derived members depending on this entry.
Assume that an airline needs to be informed of the total number of passengers flying on the different routes it operates. This number will be the sum of the number of passengers traveling on each route of the airline. The number of passengers on each route is in turn the sum of the number of passengers traveling on each flight. This value will change each time a passenger books or cancels a seat. The total number of passengers of an airline is typically a derived member, whereas the number of passengers on a flight is an entry. The modification of the entry passengers triggers the recomputation of the total number of passengers.
Derived members are not only sensitive to entry modifications but also to modifications in the object structure. Thus, if an airline decides to create a new flight or to cancel a route because the departure or arrival airport is closed, the total number of passengers flying with the airline will be recalculated as well.
A characteristic of a derived member is that it is sensitive to remote information modifications. In this respect, derived members are similar to C++ objects in a spreadsheet.
Class Templates for Attributes
Server provides class templates to define entry data members and derived data members.
For a description of these class templates, see the Server Reference Manual.
Example
class Line:
public IlsObject
{
public:
Line();
private:
IlsEntry<int> capacity;
};
class Node:
public IlsObject
{
public:
Node();
int computeInput();
int computeOutput();
private:
//InputCapacity:
class InputEvaluator{
public:
static int Evaluate(Node& node){return node.computeInput();}
};
IlsDerived<Node,int,InputEvaluator> inputCapacity;
// Output capacity:
class OutputEvaluator{
public:
static int Evaluate (Node& node) {return node.computeOutput();}
};
IlsDerived<Node,int,OutputEvaluator> outputCapacity;
...
};
Derived members can be marked as eager or not. This distinction influences the way they are recalculated. When a derived member is marked as eager, it is recomputed upon an explicit call to the IlsReevaluate function or during each interaction cycle of the view server. Otherwise, it is recalculated on demand. The recomputation of a derived member is incremental, that is, it applies only to out-of-date values.