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

VrMUX.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 * Created by Sunil K. Rao, January 18th, 2000 00016 * 00017 * Allows one input to be connected to the output with no copying overhead. 00018 */ 00019 00020 #ifndef _VRMUX_H_ 00021 #define _VRMUX_H_ 00022 00023 #include <VrSigProc.h> 00024 00025 00026 template<class T> class VrMUXBuffer; 00027 template<class T> 00028 class VrMUX : public VrSigProc { 00029 friend class VrMUXBuffer<T>; 00030 protected: 00031 unsigned int selectedInput; 00032 public: 00033 virtual const char *name() { return "VrMUX"; } 00034 /* 00035 virtual int forecast(VrSampleRange output, 00036 VrSampleRange inputs[]); 00037 */ 00038 virtual int work(VrSampleRange output, void *ao[], 00039 VrSampleRange inputs[], void *ai[]); 00040 virtual int input(int n) { 00041 selectedInput = n; 00042 return 0; 00043 } 00044 VrMUX(): VrSigProc(1,sizeof(T),sizeof(T)) { input(0); } 00045 virtual ~VrMUX() {} 00046 }; 00047 00048 #if 0 00049 template<class T> int 00050 VrMUX<T>::forecast(VrSampleRange output, 00051 VrSampleRange inputs[]) { 00052 printf("numberInputs is %d\n", numberInputs); 00053 for(unsigned int i=0;i<numberInputs;i++) { 00054 if(i==selectedInput) { 00055 inputs[i].index=output.index; 00056 inputs[i].size=output.size; 00057 } else { 00058 inputs[i].index=output.index; //skip data on other inputs 00059 inputs[i].size=0; 00060 } 00061 } 00062 return 0; 00063 } 00064 #endif 00065 00066 template<class T> int 00067 VrMUX<T>::work(VrSampleRange output, void *ao[],VrSampleRange inputs[], void *ai[]) 00068 { 00069 T **i = (T **)ai; 00070 T **o = (T **)ao; 00071 int size = output.size; 00072 00073 while(size-- > 0) { 00074 *o[0]++ = (oType)*i[selectedInput]++; 00075 } 00076 return output.size; 00077 }; 00078 #endif

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