Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

list.hh

Go to the documentation of this file.
00001 /**************************************************************************
00002  * $Id: list.hpp,v 1.2 1999/02/21 18:48:41 rosen Exp rosen $
00003  *
00004  * Revision 1.01 1998/10/03 14:34:15  rosen
00005  *
00006  * This file is part of Max data acquisition software
00007  * Copyright (C) 1998 Christian Rosen
00008  *
00009  * Max is free software; you can redistribute it and/or modify it
00010  * under the terms of the version 2 of GNU General Public License as
00011  * published by the Free Software Foundation.
00012  *
00013  * Max is distributed in the hope that it will be useful, but WITHOUT
00014  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016  * for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * (see the file COPYING) in this directory; if not, write to the
00020  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021  *
00022  **************************************************************************/
00023 
00034 
00035 
00036 #ifndef LIST_H
00037 #define LIST_H
00038 
00039 #include "packet.h"
00040 
00041 #include <iostream.h>
00042 #include <assert.h>
00043 #include <string.h>
00044 #include <stdio.h>
00045 #include <string.h>
00046 #include <stdlib.h>
00047 
00048 //STL includes
00049 #include <string>
00050 
00051 #include <qstring.h>
00052 #include <qlist.h>
00053 
00054 
00055 //the data_type flag contains the variable type of the save variable
00056 // -> see : List::get_data_type(char *)
00057 //this is neccessary to determine the type for saving the data
00058 //Scheduler::store(var) now sets up an array during first measurement cycle to store data types
00059 //look there to figure that out
00060 //IMPROVEMENT :
00061 //BUT ADD TEMPLATE LIST CLASS TO REMOVE SWITCH STATEMENTS IN GETSTRING AND
00062 // GETALLDEVICEPARAMETERS functions
00063 //
00064 /*class Element
00065  *\brief It contains one element of the linked list of device parameters.
00066  */
00067 class Element {
00068  friend class List;
00069 public:
00070 
00071 private:
00072 //private Konstructor for int var
00073   Element(int W, const char *device, const char *var,int flag,int data_type,
00074         int x=0,int y=0, Element *E = 0) {
00075     i_var       = W;
00076     next        = E;
00077     enabled   = flag; //this is the enabled flag !!!! TRUE -> device stores the data
00078     plotflag    = y;   //TRUE is var is plotted
00079     type        = data_type;
00080     storeflag   = x;   //TRUE if variable is a store variable
00081     device_name = device;
00082     var_name    = var;
00083   }
00084 //private Konstructor for double var
00085  Element(double W, const char *device,const char *var,int flag, int data_type,
00086         int x=0,int y=0, Element *E = 0) {
00087     d_var       = W;
00088     next        = E;
00089     enabled     = flag; //this is the enabled flag
00090     plotflag    = y;    //plot ot ?
00091     type        = data_type;
00092     storeflag   = x;  //indicates that thiselemet is a "store" variable
00093     device_name = device;
00094     var_name    = var;
00095  }      
00096   ~Element() {
00097     device_name.~string();
00098     var_name.~string();
00099   }
00100   string   device_name;
00101   string   var_name;     //data ist a reserved word for a variable name
00102   int      enabled;    //if that is nonzero the according variable
00103   //is saved to disk and can be plotted
00104   //1 = int,2 = double, 3 =char, 4 = string
00105   int      i_var;
00106   double   d_var;
00107   char     c_var;
00108   char *s_var;
00109   Element  *next;
00110   int       type;      //type flag 1 = int,2 = double, 3 = char, 4 = string
00111   int       storeflag; //TRUE is var is a store variable
00112   int       plotflag;  //TRUE is variable is to be plotted
00113 };
00114 
00129 class List
00130 {
00131 public:
00132   List()
00133   {
00134     L=0; Buffer_pointer=L;
00135     ParameterStr = new char[10000];
00136     assert(ParameterStr !=0);
00137     Packet= new devDataPacket;
00138   }
00139   ~List() {
00140     remove();
00141   }
00142   void initialize();
00143   void insert  (int   , char *,char *,int,int ); //insert new data-element
00144   void insert  (double, char *,char *,int,int ); //dito but with double
00145   void append  (int,    char *,char *,int,int,int,int ); //append new data-element (at the end)
00146   void append  (double ,char *,char *,int,int,int,int ); //dito but with double-variable
00147   Element * exist(char *,char *);                //check for deviceName && varName in the list
00148   void remove  ();                        //removes complete list from memory
00149   int is_active(char *);                  //returns 1 is char* device_name is an active device,
00150                                           //otherwise -1
00151   int    getvar (int *   ,char *,char *); //first  device then var-name
00168   int    getvar (double *,char *,char *); //same for double vars
00177   int    putvar (int     ,char *,char *); //set variable value (int)
00187   int    putvar (double  ,char *,char *); //set variable value (double)
00197   int    varcomp(Element *,char *,char *);
00198   void   putvar(int, int);                //set new variable for element at position i
00199   void   putvar(double, int);
00200   void   putvar( char *,int);
00201   int    enabled(char *,char *);          //return TRUE if this var is enabled
00213   int    plotstatus(int );                //return plotstaus(nostorevar,enabled,plot)
00214   char*  get_data_type(char *);           /* returns a string with a list of the
00215          *saved data type of device char
00216          *f.e. : the variables string,double,int
00217          *would return : sdi   *
00218          * needed for the save-routine*/
00219   /*network related functions only in ver 2.0 !!!*/
00220   devDataPacket * GetPacketElement(char *); //return struct packet for socket transfer
00221   devDataPacket * GetNextPacket(void );   //return data element pointed to by BufferPointer
00222   void   ResetHelpPointer(void);         //reset help list pointer to beginning of list
00223   int    AdvanceHelpPointer(void);       //go to next element
00224   /* end */
00225   void   reset_data_buffer();             //which is needed for parameter file save routine
00226   void   printlist();
00227   Element* End_Of_List();
00228   char *  getstring(int);                  //returns string with dev-name par-name value
00229   int    get_type(int );                  //returns type of ith element         
00230   char * get_name(int );                  //return name of device at position i
00231   char * get_var_name(int );              //return var name of device at position i
00232   int    get_store_flag(int );            //return the storeflag out of parameter database
00233   int    get_plot_flag(int);      //check if variable specified by position contains plotdata (ysize)
00234   int    get_enabled_flag(int);
00235   void   set_enabled_flag(int,bool);        //toggle the flags according to user input
00236   void   set_plot_flag(int,bool);         //"switch" on/off a variable
00237   int    get_number_plotvars(char *);     //return number of variables to be plotted
00238   string get_plotvar_namelist(char *);   //defined by "data" statement in initfile
00239                                           //or zero if list is empty or at the end
00240 private:
00241   char *ParameterStr;
00242   devDataPacket *Packet;
00243   int index;    //index for plotvariable
00244   int x,i,y;
00245   Element *L;
00246   Element *BufferPointer,*Buffer_pointer;
00247 };
00248 
00249 #endif
00250 
00251 //Don't write behind the endif line !!
00252 

Generated at Mon Sep 2 18:21:03 2002 for MAX by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001