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

priority.h

Go to the documentation of this file.
00001 /**************************************************************************
00002  * $Id: priority.hpp,v 1.5 1999/02/21 18:48:11 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 
00024 //header file for the class definition for the priority list
00025 //the priority list conatins the names of the devices and their priority
00026 //e.g. the roder they are called in
00027 //the scheduler calls all devices according to their priority list
00028 
00029 
00030 #ifndef PRIORITY_H
00031 #define PRIORITY_H
00032 
00033 #include <qwidget.h>
00034 #include <qtimer.h>
00035 #include <qimage.h>
00036 #include <assert.h>
00037 #include <stdio.h>
00038 #include "error.hh"
00039 
00040 class Pr_element {
00041         friend class Pr_list;
00042 private :
00043         Pr_element( char *name =0, int p=0, Pr_element *E = 0) {
00044                 priority = p;
00045                 next = E;
00046                 device_name = new char[strlen(name)+1]; //reserve mem for dev_name
00047                 assert(device_name != 0);               //not enough mem
00048                 strcpy(device_name,name);               //copy dev_name into reserved mem of class
00049         }
00050         int   priority;
00051         char *device_name;
00052         Pr_element* next;
00053 };
00054 
00055 class Pr_list {                //this class creates the linked list for the priority numbers
00056         friend class Scheduler;
00057         friend class Data_list;
00058 public :
00059         Pr_list () { L = 0; };
00060         ~Pr_list() { Pr_kill_list(); };
00061 
00062         Pr_element * end();          //returns pointer to the end of the list
00063         Pr_element * exist(char *);    //return pointer to element char *dev_name in list or NULL
00064         void   Pr_append(char *,int);  //append to list
00065         void   Pr_sort();              //sort list according to priorities -> faster search useful ??
00066                                //at least it is  nicer to edit a sorted list on the screen
00067         int    N_Devices();             //Number of Devices in Priority list
00068         int    Max_Priority();         //return Maximum priority
00069         int    Pr_initlist(char *);    //create list from diskinitfile
00070         void   Pr_kill_list();         //remove complete list out of memory
00071         void   Pr_remove();
00072         void   Put_priority(int, int);//Put (prior, index)
00073         void     Sort_priority();   //put priorities in right order and check for double an missing occurences
00074         int    Pr_empty ();
00075         int    exist(int );             //returns 1 if int exist as priority
00076         int    Get_priority(char *);    //returns priority of device char* <device_name>
00077         int    Get_priority(int );      //returns priority of device i
00078         int    check4double();          //check for double priority
00079         bool   check4zerolist();          //check wether all priorities are zero
00080         int    varcomp(Pr_element *,char *);//compares string with device_name in priority list
00081         char*  Get_device_name(int );
00082         char*  Get_dev_name (int );  //get device name defined by priority
00083         void   Pr_printlist();
00084         int    Consistency();  //Check order of devices for consistency. Return = if o.k. or number of missing element
00085  
00086         /*network related functions only in ver 2.0 !!!*/
00087         void   ResetHelpPointer(void);         //reset help list pointer to beginning of list
00088         int    AdvanceHelpPointer(void);    //go to next element
00089         char*  GetNextName();                    //return device name pointed to by BufferPointer
00090         int    GetNextPriority();                 //return priority pointed to by BufferPointer
00091  private :
00092         Pr_element *L;
00093         Pr_element *Buffer_pointer,*BufferPointer;
00094 };
00095 
00096 #endif

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