?? algorithm.h
字號:
// file: $isip/class/algo/Algorithm/Algorithm.h// version: $Id: Algorithm.h,v 1.31 2002/10/17 19:25:56 gao Exp $//// make sure definitions are only made once//#ifndef ISIP_ALGORITHM#define ISIP_ALGORITHM#ifndef ISIP_ALGORITHM_BASE#include <AlgorithmBase.h>#endif#ifndef ISIP_ALGORITHM_UNDEFINED#include <AlgorithmUndefined.h>#endif#ifndef ISIP_COEFFICIENT_LABEL#include <CoefficientLabel.h>#endif#ifndef ISIP_MEMORY_MANAGER#include <MemoryManager.h>#endif#ifndef ISIP_OUTOUT#include <Output.h>#endif#ifndef ISIP_NAME_MAP#include <NameMap.h>#endif// Algorithm: a class that transforms data using an abstract base// class having virtual functions. The virtual functions allow the// derived class to replace the functionality provided by the base// class. The class AlgorithmBase defines the interface contract for// all the Algorithms.//class Algorithm : public AlgorithmBase { //--------------------------------------------------------------------------- // // public constants // //---------------------------------------------------------------------------public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // other important constants // //---------------------------------------- // define the enumeration for data type // enum TYPES { ALGORITHM_CONTAINER = 0, CALCULUS, CEPSTRUM, COEFFICIENT_LABEL, CONNECTION, CONSTANT, CORRELATION, COVARIANCE, DISPLAY_DATA, ENERGY, FILTER, FILTER_BANK, FOURIER_TRANSFORM, GENERATOR, LOG_AREA_RATIO, MASK, MATH, OUTPUT, PREDICTION, REFLECTION, SPECTRUM, STATISTICS, WINDOW, DEF_TYPES = CALCULUS }; // define static NameMap objects // static const NameMap TYPES_MAP; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String PARAM_TYPES; //---------------------------------------- // // error codes // //---------------------------------------- static const long ERR = 70050; //--------------------------------------------------------------------------- // // protected data // //---------------------------------------------------------------------------protected: // pointer to the base class object // AlgorithmBase* virtual_algo_d; // define an empty object used for uninitialized things // static AlgorithmUndefined NO_ALGORITHM; // memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //---------------------------------------------------------------------------public: // method: name // static const String& name() { return CLASS_NAME; } // other static methods // static boolean diagnose(Integral::DEBUG debug_level); // method: debug // boolean debug(const unichar* msg) const { return virtual_algo_d->debug(msg); } // destructor/constructor(s) // ~Algorithm(); Algorithm(); Algorithm(const Algorithm& arg); // assign methods // boolean assign(const Algorithm& arg); // i/o methods // long sofSize() const; boolean read(Sof& sof, long tag, const String& name = CLASS_NAME); boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const; boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false); boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const; // method: eq // boolean eq(const Algorithm& arg) const { return virtual_algo_d->eq(*(arg.virtual_algo_d)); } // method: new // static void* operator new(size_t size) { return mgr_d.get(); } // method: new[] // static void* operator new[](size_t size) { return mgr_d.getBlock(size); } // method: delete // static void operator delete(void* ptr) { mgr_d.release(ptr); } // method: delete[] // static void operator delete[](void* ptr) { mgr_d.releaseBlock(ptr); } // method: setGrowSize // static boolean setGrowSize(long grow_size) { return mgr_d.setGrow(grow_size); } // method: clear // boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE) { if (virtual_algo_d != (AlgorithmBase*)&NO_ALGORITHM) { delete virtual_algo_d; virtual_algo_d = &NO_ALGORITHM; } return true; } //--------------------------------------------------------------------------- // // class-specific public methods: // set methods // // note: not all the set methods available in AlgorithmBase are // preserved here. // //--------------------------------------------------------------------------- // method: setBasename // boolean setBasename(String basename) { if (getType() == OUTPUT) (dynamic_cast< Output*>(virtual_algo_d))->setBasename(basename); return true; } // method: setOutputExtension // boolean setOutputExtension(String extension) { if (getType() == OUTPUT) dynamic_cast <Output*> (virtual_algo_d)->setOutputExtension(extension); return true; } // method: setOutputType // boolean setOutputType(File::TYPE type) { if (getType() == OUTPUT) dynamic_cast <Output*>(virtual_algo_d)->setOutputType(type); return true; } // method: setSampleFrequency // boolean setSampleFrequency(float sf) { return virtual_algo_d->setSampleFrequency(sf); } // method: setFrameDuration // boolean setFrameDuration(float dur) { return virtual_algo_d->setFrameDuration(dur); } // method: setSignalDuration // boolean setSignalDuration(float dur) { return virtual_algo_d->setSignalDuration(dur); } // method: setLeftoverSamps // boolean setLeftoverSamps(long samps) { return virtual_algo_d->setLeftoverSamps(samps); } // method: setFrameIndex // boolean setFrameIndex(long index) { return virtual_algo_d->setFrameIndex(index); } // configuration methods // boolean setType(TYPES type); //--------------------------------------------------------------------------- // // class-specific public methods: // get methods // // note: not all the get methods available in AlgorithmBase are // preserved here. // //--------------------------------------------------------------------------- // method: getBasename // boolean getBasename(String basename) const { if (getType() == OUTPUT) dynamic_cast <Output*> (virtual_algo_d)->getBasename(basename); return true; } // method: getOutputExtension // boolean getOutputExtension(String& extension) const { if (getType() == OUTPUT) return dynamic_cast <Output*> (virtual_algo_d)-> getOutputExtension(extension); else return true; } // configuration methods // TYPES getType() const; // methods used in the CoefficientLabel class // const String& getCLabelVariable() const; CoefficientLabel::TYPE getCLabelType() const; // methods used in Algorithm graph processing // long getContainerGraphTag() const; //--------------------------------------------------------------------------- // // class-specific public methods: // public methods required by the AlgorithmBase interface contract // //--------------------------------------------------------------------------- // assign methods // boolean assign(const AlgorithmBase& arg); // method: eq // boolean eq(const AlgorithmBase& arg) const { return virtual_algo_d->eq(arg); } // method: className // const String& className() const { return virtual_algo_d->className(); } // method: init // boolean init() { return virtual_algo_d->init(); } // method: apply // boolean apply(Vector<AlgorithmData>& output, const Vector< CircularBuffer<AlgorithmData> >& input); // method: getLeadingPad // long getLeadingPad() const { return virtual_algo_d->getLeadingPad(); } // method: getTrailingPad // long getTrailingPad() const { return virtual_algo_d->getTrailingPad(); } //--------------------------------------------------------------------------- // // private methods // //---------------------------------------------------------------------------private:};// end of include file// #endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -