Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

miscdevices.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           miscdevices.h  -  description
00003                              -------------------
00004     begin                : Mit Jun 5 2002
00005     copyright            : (C) 2002 by Peter Haase
00006     email                : mail@p-haase.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00024  *   MA  02111-1307  USA                                                   *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 
00029 #ifndef MISC_DEVICES_HEADER
00030 #define MISC_DEVICES_HEADER
00031 
00032 #include <cstdio>
00033 #include <simthetic/basicdevicefactory.h>
00034 #include <simthetic/basicdevice.h>
00035 #include <simthetic/phbib.h>
00036 
00037 
00038 namespace simthlib
00039 {
00040 
00041 void initMiscDevice(const std::string filename, simth::Device** dev, simth::DeviceSystemIntf* sysPtr, int ID,
00042                     const std::string& regionQualifier = "");
00043 void initMiscDevice(simth::DeviceFactory& registration);
00044 
00045 void initFilter(const std::string filename, simth::Device** dev, simth::DeviceSystemIntf* sysPtr, int ID,
00046                 const std::string& regionQualifier = "");
00047 
00048 class DummyDevice : public simth::Device
00049 {
00050 
00051   public:
00052     DummyDevice(int deviceID, simth::DeviceSystemIntf* system, const simth::PropertyList& pl = simth::PropertyList())
00053         : simth::Device(deviceID, system, pl) {};
00054 
00055     virtual void updateInputLengths();
00056     virtual void updateOutputLengths();
00057 
00058     virtual void process();
00059 
00060     void print(std::ostream &os) const {os<<"#DUMMY DEVICE";}
00061 };
00062 
00063 inline void DummyDevice::process()
00064 {
00065   throw std::logic_error("inline void DummyDevice::process() : error 1");
00066 }
00067 
00068 template<class T>
00069 class Drainpipe : public simth::Device
00070 {
00071 
00072   public:
00073     Drainpipe(int deviceID, simth::DeviceSystemIntf* system, const simth::PropertyList& pl = simth::PropertyList() );
00074 
00075     virtual void updateInputLengths();
00076     virtual void updateOutputLengths();
00077 
00078     virtual void process();
00079 
00080     void print(std::ostream &os) const {os<<"#Drainpipe";}
00081 };
00082 
00083 
00084 
00085 
00086 
00089 template<class T>
00090 class Filepipe : public simth::Device
00091 {
00092 
00093     std::string filename;
00094     bool saveOnlyFirst;
00095     bool first;
00096 
00097   public:
00098     Filepipe(int deviceID, simth::DeviceSystemIntf* system, 
00099          const simth::PropertyList& pl);
00100 
00101     virtual void updateInputLengths();
00102     virtual void updateOutputLengths();
00103 
00104     virtual void process();
00105 
00106     void refresh();
00107 
00108     void print(std::ostream &os) const;
00109 };
00110 
00111 
00112 
00154 template <class seqT>
00155 class HistogramPipeT : public simth::Device
00156 {
00157   private:
00158     bool bins_at_center;
00159     double left, right, width;
00160     bool ignore_outside;
00161     size_t nr_bins;
00162     std::vector<unsigned> bins;
00163 
00164     bool ignore_point(const double& v) const;
00165     size_t value2bin(const double& v) const;
00166     double bin2value(size_t v) const;
00167 
00168   public:
00176     HistogramPipeT(int deviceID, simth::DeviceSystemIntf* system,
00177                    const simth::PropertyList& pl);
00178 
00179     void process();
00180 
00181     void updateInputLengths();
00182     void updateOutputLengths();
00183     void print(std::ostream &os) const;
00184 };
00185 
00188 class CDFPipe : public simth::Device
00189 {
00190   private:
00191     double normFactor;
00192     bool do_norm;
00193 
00194   public:
00201     CDFPipe(int deviceID, simth::DeviceSystemIntf* system,
00202              const simth::PropertyList &pl);
00203 
00204     void process();
00205 
00206     void updateInputLengths();
00207     void updateOutputLengths();
00208     void print(std::ostream &os) const;
00209 };
00210 
00211 
00212 
00213 
00216 class TransversalFilter : public simth::Device
00217 {
00218   private:
00219 
00220     typedef simth::ModSeq::value_type value_type;
00221 
00222     const simth::checkedVector<double> coefficients;
00223     simth::checkedVector<value_type> stateMem;
00224 
00230     int usedStateMemSize_;
00231 
00232   protected:
00233 
00234     int usedStateMemSize() const {return usedStateMemSize_;}
00235 
00236     void FilterSeq(const simth::ModSeq &modIn, simth::ModSeq* modOut);
00237 
00238   public:
00239     TransversalFilter(int deviceID, simth::DeviceSystemIntf* system,
00240                       const simth::checkedVector<double>& coefficients_);
00241 
00242     ~TransversalFilter(){};
00243 
00244     virtual void updateInputLengths();
00245     virtual void updateOutputLengths();
00246 
00247 
00248     virtual void process();
00249 
00250     void print(std::ostream &os) const;
00251 
00252     void setUsedCoefficients(int numUsedCoeff);
00253 
00254 };
00255 
00256 }
00257 
00258 #endif
00259 
00260 
00261 
00262 
00263 
00264 
00265 
00266 

Generated on Tue Aug 9 14:35:11 2005 for simtheticlib by  doxygen 1.4.1