Modeling Services > Entry and Derived Data Members > Derived Data Members > Defining a Derived Data Member
 
Defining a Derived Data Member
A derived data member is an instance of the Rogue Wave® Server class template IlsDerived. This class template must be a member of a class that directly or transitively derives from IlsObject or IlsEntity. Derivation must also be public.
You declare a derived data member as follows:
class Airline:
public IlsObject
{
public:
  Airline();
  int countPassengers();
  class Evaluator{
  public:
    static int Evaluate(Airline& airline){
       return airline.countPassengers();
    }
  };
  IlsDerived<Airline,int,Evaluator> passengers;
};
The code sample above declares a derived data member passengers of type int for the class Airline. As its first argument, the class template IlsDerived takes the class of which the derived data is a member, here Airline. The second argument passed to the class template is the type of the derived member, here int. The third argument, Evaluator, is a class which must contain one public static function with the following signature:
static DerivedType Evaluate(HolderType&);
This function must return the value of the derived data member. It must not modify relations or entries. Otherwise, it might interfere with the evaluation algorithm of derived members. The evaluation algorithm is described in section “Evaluation Algorithm of a Derived Data Member”..

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.