/****************************************************************** 
 *
 * calculationclass.h --
 *
 *     Interface to calculation class.
 *
 *
 * Created: 24 June 1998
 * $Author: mstoufer $
 * $Date: 2000/12/05 19:52:33 $
 * $Id: calculationclass.h,v 1.1.1.1 2000/12/05 19:52:33 mstoufer Exp $
 *
 ****************************************************************** 
 */
#ifndef NLV_CALC_INCLUDED
#define NLV_CALC_INCLUDED

#include <stdio.h>
#include <sys/types.h>
#include "structs.h"
#include "analysisclass.h"
#include "keysclass.h"
#include "syswrappers.h"

/*========= DATA =====================================================*/

#define T Nlv_cc
typedef struct T *T;
typedef void (*Nlv_CalcFn) ( T, Nlv_AData * );
typedef void (*Nlv_ClearFn) ( T, int );

/* types of tree nodes */
enum { VAL_NUM, VAL_OP, VAL_PARAM, VAL_FN };

/* tree node structure */
struct t_node {
  struct t_node *left, *right;
  union {
    double number;
    int    op;
    void*  param;
    struct function {
      Nlv_CalcFn  calc;
      Nlv_ClearFn clear;
    } fn;
  } val;
  int valtype;
  int visited;
};


/*========= FUNCTIONS ================================================*/

T               Nlv_ccNew( );
void            Nlv_ccProcess( T, Nlv_AData *dataPtr );
void            Nlv_ccClear( T, int numClients );
char           *Nlv_ccGetName( T );
int             Nlv_ccGetSize( T );
Nlv_CalcResult *Nlv_ccGetResult( T, int slot );
int             Nlv_ccGetVecSize( T this );
long            Nlv_ccGetIter( T this, int slot );
int             Nlv_ccGetKeySetShow( T, int ksIndex );
void            Nlv_ccSetCapacity( T, int );
void            Nlv_ccSetFunctions( T, Nlv_CalcFn, Nlv_ClearFn );
void            Nlv_ccSetName( T, char *);
void            Nlv_ccSetParam( T, int vecSize, int otherSize );
void            Nlv_ccSetKeysetShow( T, Nlv_ky ky );
void            Nlv_ccSetFnTreePtr( T, struct t_node *ptr );
void            Nlv_ccAddIter( T, int client );
void            Nlv_ccInitParam( Nlv_CalcParam *p );
void            Nlv_ccNewParams( Nlv_CalcParam **arr, int *n );

#undef T

#endif
