PacMaster 2.0(r200)
Controls digital PAC measurements and collects the results

PacEventChunk.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008-2010 by Matthias Nagl                              *
00003  *   mnagl@uni-goettingen.de                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef PACEVENTCHUNK_H
00022 #define PACEVENTCHUNK_H
00023 #include "PacEvent.h"
00024 
00030 class PacEventChunk
00031 {
00032   public:
00033     PacEventChunk(PacEvent **events, unsigned int size) : ev(events), s(size), pos(0) {};
00034     ~PacEventChunk() {
00035       for (unsigned int i=0; i<s; i++)
00036         if (ev[i]!=0)
00037           delete ev[i];
00038       delete [] ev;
00039     }
00040 
00041     inline unsigned int size() const { return s; };
00042 
00047     inline bool getNext(PacEvent **result) {
00048       if (pos<s) {
00049         *result = ev[pos];
00050         ev[pos] = 0;
00051         pos++;
00052         return true;
00053       }
00054       else if (s==0) {
00055         *result=0;
00056         return true;
00057       }
00058       *result = 0;
00059       return false;
00060     }
00061 
00062     inline PacEvent * getEvent(quint32 idx) { Q_ASSERT(idx<s); return ev[idx]; };
00063 
00064   private:
00065     PacEvent **ev;
00066     unsigned int s;
00067     unsigned int pos;
00068 };
00069 
00070 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines