// file: $isip/class/algo/AlgorithmContainer/AlgorithmContainer.h // version: $Id: AlgorithmContainer.h 8252 2002-06-29 18:05:02Z picone $ // // make sure definitions are only made once // #ifndef ISIP_ALGORITHM_CONTAINER #define ISIP_ALGORITHM_CONTAINER // 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 // forward class definitions // class AlgorithmData; // AlgorithmContainer: a class used as a placeholder for subgraphs. this // class allows container objects to be specified in a recipe // (via transform_builder) and to be read by isip_transform. // class AlgorithmContainer : public AlgorithmBase { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // other important constants // //---------------------------------------- // define the algorithm choices // enum ALGORITHM { SUB_PROCESS = 0, DEF_ALGORITHM = SUB_PROCESS }; // define the implementation choices // enum IMPLEMENTATION { EXPAND = 0, DEF_IMPLEMENTATION = EXPAND }; // define static NameMap objects // static const NameMap ALGO_MAP; static const NameMap IMPL_MAP; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String PARAM_ALGORITHM; static const String PARAM_IMPLEMENTATION; static const String PARAM_GRAPH_TAG; static const String PARAM_VARIABLE; //---------------------------------------- // // default values and arguments // //---------------------------------------- // default value for the class data // static const int32 DEF_GRAPH_TAG = -1; //---------------------------------------- // // error codes // //---------------------------------------- static const int32 ERR = 73200; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // algorithm name // ALGORITHM algorithm_d; // implementation name // IMPLEMENTATION implementation_d; // the variable name and type // Long graph_tag_d; // the container variable name // String variable_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 // ~AlgorithmContainer() {} // method: constructor // AlgorithmContainer(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, int32 graph_tag = DEF_GRAPH_TAG) { algorithm_d = algorithm; implementation_d = implementation; graph_tag_d = graph_tag; } // method: copy constructor // AlgorithmContainer(const AlgorithmContainer& arg) { assign(arg); } // method: assign // bool8 assign(const AlgorithmContainer& arg); // method: operator= // AlgorithmContainer& operator= (const AlgorithmContainer& 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 AlgorithmContainer& arg) const { return ((algorithm_d == arg.algorithm_d) && (implementation_d == arg.implementation_d) && (graph_tag_d == arg.graph_tag_d) && (variable_d.eq(arg.variable_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& arg) { return variable_d.assign(arg); } // method: setGraphTag // bool8 setGraphTag(int32 arg) { return graph_tag_d.assign(arg); } // method: set // bool8 set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, int32 graph_tag = DEF_GRAPH_TAG) { algorithm_d = algorithm; implementation_d = implementation; graph_tag_d = graph_tag; 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: getGraphTag // const int32 getGraphTag() const { return graph_tag_d; } // method: get // bool8 get(ALGORITHM& algorithm, IMPLEMENTATION& implementation, int32& graph_tag) const { algorithm = algorithm_d; implementation = implementation_d; graph_tag = graph_tag_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; } // method: apply // bool8 apply(Vector& output, const Vector< CircularBuffer >& input) { return false; } // parser methods // bool8 setParser(SofParser* parser); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: }; // end of include file // #endif