// file: $isip/class/algo/CoefficientLabel/CoefficientLabel.h // version: $Id: CoefficientLabel.h 8251 2002-06-29 18:02:58Z picone $ // // make sure definitions are only made once // #ifndef ISIP_COEFFICIENT_LABEL #define ISIP_COEFFICIENT_LABEL // isip include files // #ifndef ISIP_ALGORITHM_BASE #include #endif #ifndef ISIP_ALGORITHM_DATA #include #endif #ifndef ISIP_MEMORY_MANAGER #include #endif // CoefficientLabel: a class that is used to label feature streams, and // to change the type of a parameter. this is an internal class used by // isip_transform that is normally not used by programmers in conventional // algorithm programming. // class CoefficientLabel : public AlgorithmBase { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; static const String CNAME; //---------------------------------------- // // other important constants // //---------------------------------------- // define the algorithm choices // enum ALGORITHM { DATA = 0, DEF_ALGORITHM = DATA }; // define the implementation choices // enum IMPLEMENTATION { COPY = 0, DEF_IMPLEMENTATION = COPY }; // define the type // enum TYPE { INPUT = 0, OUTPUT, INTERNAL, DEF_TYPE = INTERNAL }; // define the static NameMap objects // static const NameMap ALGO_MAP; static const NameMap IMPL_MAP; static const NameMap TYPE_MAP; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String PARAM_ALGORITHM; static const String PARAM_IMPLEMENTATION; static const String PARAM_TYPE; static const String PARAM_VARIABLE; static const String PARAM_COEF_TYPE; //---------------------------------------- // // default values and arguments // //---------------------------------------- // define the default value(s) of the class data // static const AlgorithmData::COEF_TYPE DEF_COEF_TYPE = AlgorithmData::PROPAGATE; //---------------------------------------- // // error codes // //---------------------------------------- static const int32 ERR = 71500; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // algorithm name // ALGORITHM algorithm_d; // implementation name // IMPLEMENTATION implementation_d; // the variable name and type // String variable_d; TYPE type_d; // the output coefficient type // AlgorithmData::COEF_TYPE coef_type_d; // memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } // other static methods // static bool8 diagnose(Integral::DEBUG debug_level); // debug methods: // setDebug method is inherited from the base class // bool8 debug(const unichar* msg) const; // method: destructor // ~CoefficientLabel() {} // method: constructor // CoefficientLabel(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, AlgorithmData::COEF_TYPE coef_type = DEF_COEF_TYPE, TYPE type = DEF_TYPE) { algorithm_d = algorithm; implementation_d = implementation; coef_type_d = coef_type; type_d = type; } // method: copy constructor // CoefficientLabel(const CoefficientLabel& arg) { assign(arg); } // method: assign // bool8 assign(const CoefficientLabel& arg); // method: operator= // CoefficientLabel& operator= (const CoefficientLabel& arg) { assign(arg); return *this; } // i/o methods // int32 sofSize() const; bool8 read(Sof& sof, int32 tag, const String& name = CLASS_NAME); bool8 write(Sof& sof, int32 tag, const String& name = CLASS_NAME) const; bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // method: eq // bool8 eq(const CoefficientLabel& arg) const { return (variable_d.eq(arg.variable_d) && (algorithm_d == arg.algorithm_d) && (implementation_d == arg.implementation_d) && (coef_type_d == arg.coef_type_d) && (type_d == arg.type_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 bool8 setGrowSize(int32 grow_size) { return mgr_d.setGrow(grow_size); } // other memory management methods // bool8 clear(Integral::CMODE ctype = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods: // set methods // //--------------------------------------------------------------------------- // method: setAlgorithm // bool8 setAlgorithm(ALGORITHM algorithm) { algorithm_d = algorithm; is_valid_d = false; return true; } // method: setImplementation // bool8 setImplementation(IMPLEMENTATION implementation) { implementation_d = implementation; is_valid_d = false; return true; } // method: setVariable // bool8 setVariable(const String& variable) { return variable_d.assign(variable); } // method: setType // bool8 setType(TYPE arg) { type_d = arg; is_valid_d = false; return true; } // method: setCoefType // bool8 setType(AlgorithmData::COEF_TYPE arg) { coef_type_d = arg; is_valid_d = false; return true; } // method: set // bool8 set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, AlgorithmData::COEF_TYPE coef_type = DEF_COEF_TYPE, TYPE type = DEF_TYPE) { algorithm_d = algorithm; implementation_d = implementation; coef_type_d = coef_type; type_d = type; is_valid_d = false; return true; } //--------------------------------------------------------------------------- // // class-specific public methods: // get methods // //--------------------------------------------------------------------------- // method: getAlgorithm // ALGORITHM getAlgorithm() const { return algorithm_d; } // method: getImplementation // IMPLEMENTATION getImplementation() const { return implementation_d; } // method: getVariable // const String& getVariable() const { return variable_d; } // method: getType // TYPE getType() const { return type_d; } // method: getCoefType // AlgorithmData::COEF_TYPE getCoefType() const { return coef_type_d; } // method: get // bool8 get(ALGORITHM& algorithm, IMPLEMENTATION& implementation, AlgorithmData::COEF_TYPE& coef_type, TYPE& type) const { algorithm = algorithm_d; implementation = implementation_d; coef_type = coef_type_d; type = type_d; return true; } //--------------------------------------------------------------------------- // // class-specific public methods: // AlgorithmBase interface contract methods // //--------------------------------------------------------------------------- // assign method // bool8 assign(const AlgorithmBase& arg); // equality method // bool8 eq(const AlgorithmBase& arg) const; // method: className // const String& className() const { return CLASS_NAME; } // apply method // bool8 apply(Vector& output, const Vector< CircularBuffer >& input); // parser methods // bool8 setParser(SofParser* parser); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: }; // end of include file // #endif