5. 1. 3 Quantity Accessors

In order to introduce the principles of designing classes for the use in combination with the Phoenix 2 library, a quantity accessor which provides access to the underlying quantity is shown. The Phoenix style function classes have to provide an evaluation method eval. In this method an environment $ \texttt{env}$ containing all function arguments (externally written as _1 $ \ldots$ ) as well as all named variables (_a $ \ldots$ _z) are passed. During the construction of an instance of the class, the topological complex of the class as well as the quantity name is passed. Schematically, the class can be written as follows:

 template <class Complex>
 struct accessor
   accessor(Complex & C, Complex::quan_name_t name) 
     : C(C), name(name) {}


   eval(Env & env)
      return C.retrieve_quantity(at<0>(env.args), name);

Michael 2008-01-16