// file: $isip/class/algo/DisplayData/DisplayData.h // version: $Id: DisplayData.h 8259 2002-07-01 20:56:00Z picone $ // // make sure definitions are only made once // #ifndef ISIP_DISPLAY_DATA #define ISIP_DISPLAY_DATA // isip include files // #ifndef ISIP_ALGORITHM_BASE #include #endif #ifndef ISIP_LONG #include #endif #ifndef ISIP_STRING #include #endif #ifndef ISIP_MEMORY_MANAGER #include #endif // DisplayData: a class used to display data as it is processed through // a recipe in isip_transform. this class is mainly used as a diagnostic // tool - it lets users obtain debugging output at any point in a recipe. // class DisplayData : public AlgorithmBase { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // other important constants // //---------------------------------------- // define the algorithm choices // enum ALGORITHM { EVERY = 0, FIRST, LAST, ONCE, DEF_ALGORITHM = EVERY }; // define the implementation choices // enum IMPLEMENTATION { CONSOLE = 0, DEF_IMPLEMENTATION = CONSOLE }; // define the static NameMap objects // static const NameMap ALGO_MAP; static const NameMap IMPL_MAP; //---------------------------------------- // // constants for building the output // //---------------------------------------- static const String ELEMENT_HEADER_00; static const String ELEMENT_HEADER_01; static const String LABEL_DELIM; static const String EMPTY_MATRIX; static const String MATRIX_START; static const String MATRIX_DELIM; static const String MATRIX_END; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String PARAM_ALGORITHM; static const String PARAM_IMPLEMENTATION; static const String PARAM_NUMBER; static const String PARAM_LABEL; static const String PARAM_PREFIX; static const String PARAM_SUFFIX; //---------------------------------------- // // default values and arguments // //---------------------------------------- // define the default value(s) of the class data // static const int32 DEF_NUMBER = 0; static const Integral::DEBUG DEF_DEBUG_LEVEL = Integral::BRIEF; static const String DEF_LABEL; static const String DEF_PREFIX; static const String DEF_SUFFIX; //---------------------------------------- // // error codes // //---------------------------------------- static const int32 ERR = 73100; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // algorithm name // ALGORITHM algorithm_d; // implementation name // IMPLEMENTATION implementation_d; // the number // Long number_d; // strings that define the output // String label_d; String prefix_d; String suffix_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 // ~DisplayData() {} // method: constructor // DisplayData(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, Long number = DEF_NUMBER, Integral::DEBUG debug_level = DEF_DEBUG_LEVEL) { algorithm_d = algorithm; implementation_d = implementation; number_d = number; debug_level_d = debug_level; } // method: copy constructor // DisplayData(const DisplayData& arg) { debug_level_d = DEF_DEBUG_LEVEL; assign(arg); } // method: assign // bool8 assign(const DisplayData& arg); // method: operator= // DisplayData& operator= (const DisplayData& 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 DisplayData& arg) const { return ((algorithm_d == arg.algorithm_d) && (implementation_d == arg.implementation_d) && (number_d == arg.number_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: setNumber // bool8 setNumber(int32 arg) { return number_d.assign(arg); is_valid_d = false; } // method: setLabel // bool8 setLabel(const String& arg) { return label_d.assign(arg); } // method: setPrefix // bool8 setPrefix(const String& arg) { return prefix_d.assign(arg); } // method: setSuffix // bool8 setSuffix(const String& arg) { return suffix_d.assign(arg); } // method: set // bool8 set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, Long number = DEF_NUMBER, Integral::DEBUG debug_level = DEF_DEBUG_LEVEL) { algorithm_d = algorithm; implementation_d = implementation; number_d = number; debug_level_d = debug_level; 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: getNumber // int32 getNumber() const { return number_d; } // method: getLabel // const String& getLabel() const { return label_d; } // method: getPrefix // const String& getPrefix() const { return prefix_d; } // method: getSuffix // const String& getSuffix() const { return suffix_d; } // method: get // bool8 get(ALGORITHM& algorithm, IMPLEMENTATION& implementation, int32& number, Integral::DEBUG& debug_level) const { algorithm = algorithm_d; implementation = implementation_d; number = number_d; debug_level = debug_level_d; return true; } //--------------------------------------------------------------------------- // // class-specific public methods: // computational methods // //--------------------------------------------------------------------------- bool8 compute(AlgorithmData& output, const AlgorithmData& input); //--------------------------------------------------------------------------- // // 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: // method to determine if this frame's data should be displayed // bool8 shouldDisplayFrame() const; // method to create a nice display for anything but a combination // bool8 displayObject(const AlgorithmData& input) const; }; // end of include file // #endif