00001 /* 00002 * MAX : data.h, 16.08.2002 -sg 00003 * 00004 * This file is part of Max data acquisition software 00005 * Copyright (C) 1998 Christian Rosen 00006 * 00007 * Max is free software; you can redistribute it and/or modify it 00008 * under the terms of the version 2 of GNU General Public License as 00009 * published by the Free Software Foundation. 00010 * 00011 * Max is distributed in the hope that it will be useful, but WITHOUT 00012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00014 * for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * (see the file COPYING) in this directory; if not, write to the 00018 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 00021 /* this file contains the headers for some additional utility classes 00022 * like list and queue classes for data storage 00023 * the PacketList class is used to stack all measured data and 00024 * convert it to uchar * to send it via sockets 00025 * the "real" data storage is done by the main GUI max.cpp 00026 * in the class sched.cpp 00027 */ 00028 00029 #ifndef _DATA_H_ 00030 #define _DATA_H_ 00031 00032 #include "packet.h" 00033 #include "definitions.h" 00034 00035 #include <stdio.h> 00036 #include <string.h> 00037 //#include <stdlib.h> 00038 //this is one element of the list 00039 //important : performs a deep copy of the packet before 00040 //inserting it into the list 00041 00042 class PacketElement { 00043 friend class PacketList; 00044 public : 00045 PacketElement( dataPacket *packet = 0, PacketElement *E = 0){ 00046 dat_packet = new dataPacket; 00047 memcpy(dat_packet,packet,FULL_P_SIZE); //deep copy 00048 next = E; //never forget this, or list finds no end 00049 } 00050 ~PacketElement(){ 00051 if (dat_packet) 00052 delete dat_packet; 00053 } 00054 private : 00055 dataPacket *dat_packet; 00056 PacketElement *next; //pointer to next Element in the list 00057 }; 00058 00059 //class for linked list of dataPackets 00060 //receives measured data and sone informations as arguments 00061 //converts it to a senPacket (see packet.h) and stores it 00062 class PacketList { 00063 public : 00064 PacketList() { P = new dataPacket; L = NULL; } 00065 ~PacketList() { remove(); } 00066 int empty(); //return TRUE if empty 00067 int length(); //number of elements in the list 00068 PacketElement * last(); //the functions 00069 PacketElement * first(); //return pointers to move around the list 00070 PacketElement * next(); 00071 // PacketElement * end(); 00072 dataPacket * packet(); //return pointer to the datapacket structure 00073 void remove(); //kill List 00074 void append(int, int, int, int); //append integer value 00075 void append(double, int, int, int); //append double value 00076 void append(int *, int, int, int,int); //append integer array 00077 void append(double *, int, int, int,int); //append integer array 00078 private : 00079 PacketElement *L; 00080 PacketElement *L2; //second pointer to scroll through list 00081 dataPacket *P; 00082 }; 00083 00084 #endif