gpulog_ilogstream.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2010 by Mario Juric                                     *
00003  *   mjuric@cfa.harvard.EDU                                                *
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 3 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 
00027 #ifndef bits_gpulog_ilogstream_h__
00028 #define bits_gpulog_ilogstream_h__
00029 
00030 namespace gpulog
00031 {
00032 namespace internal
00033 {
00034 
00036         struct ilogstream
00037         {
00038         protected:
00039                 header hend;
00040 
00041         protected:
00042                 const char *const ptr;
00043                 int at, len;
00044 
00045         public:
00047                 __device__ __host__ ilogstream(const char *ptr_, int len_) : ptr(ptr_), at(0), len(len_), hend(-1, 0) {}
00049                 __device__ __host__ ilogstream(const host_log &l) : ptr(l.internal_buffer()), at(0), len(l.size()), hend(-1, 0) {}
00050 
00052                 __device__ __host__ logrecord next()
00053                 {
00054                         // if we're at the end
00055                         if(at == len) { return logrecord((char *)&hend); }
00056 
00057                         // return next packet
00058                         logrecord rec(ptr + at);
00059                         at += rec.len();
00060 
00061                         return rec;
00062                 }
00063         };
00064 
00065 }
00066 }
00067 
00068 #endif

doxygen