Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

VrTestCountSink.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- 00002 * 00003 * Copyright 1997 Massachusetts Institute of Technology 00004 * 00005 * Permission to use, copy, modify, distribute, and sell this software and its 00006 * documentation for any purpose is hereby granted without fee, provided that 00007 * the above copyright notice appear in all copies and that both that 00008 * copyright notice and this permission notice appear in supporting 00009 * documentation, and that the name of M.I.T. not be used in advertising or 00010 * publicity pertaining to distribution of the software without specific, 00011 * written prior permission. M.I.T. makes no representations about the 00012 * suitability of this software for any purpose. It is provided "as is" 00013 * without express or implied warranty. 00014 * 00015 */ 00016 00017 00018 #ifndef _VRTESTCOUNTSINK_H_ 00019 #define _VRTESTCOUNTSINK_H_ 00020 00021 #include <VrSink.h> 00022 #include <pthread.h> 00023 00024 template<class iType> 00025 class VrTestCountSink : public VrSink<iType> { 00026 iType counter; 00027 public: 00028 virtual const char *name() { return "VrTestCountSink"; } 00029 virtual void work(timestamp ts, unsigned int size, iType *i[]); 00030 virtual void initialize(); 00031 }; 00032 00033 template<class iType> void 00034 VrTestCountSink<iType>::initialize() 00035 { 00036 counter=0; 00037 } 00038 00039 template<class iType> void 00040 VrTestCountSink<iType>::work(timestamp ts, unsigned int size, iType *i[]) 00041 { 00042 00043 sync(ts); //simulate sequential Sink 00044 00045 int size_save = size; 00046 timestamp ts_save=ts; 00047 00048 while(size-- > 0) { 00049 //waste some time 00050 int n=ts; 00051 for(int ii=0; ii<5;ii++) 00052 n += n % 13; 00053 00054 if(*i[0] != counter) { 00055 fprintf(stderr, "Value at ts=%lld is %d instead of %d\n", 00056 ts, (int) *i[0], (int) ts); 00057 } 00058 i[0]++; counter++; 00059 } 00060 00061 // if(size_save > 0) 00062 // cerr<<size_save<<" complete["<<pthread_self()<<"] at "<<ts_save<<"."<<endl; 00063 00064 } 00065 00066 #endif 00067 00068 00069 00070 00071

Generated on Wed Aug 4 02:22:06 2004 for GNU Radio by doxygen 1.3.8