// file: $isip/class/algo/Connection/Connection.h // version: $Id: Connection.h 8269 2002-07-02 19:14:33Z gao $ // // make sure definitions are only made once // #ifndef ISIP_CONNECTION #define ISIP_CONNECTION // isip include files // #ifndef ISIP_ALGORITHM_BASE #include #endif #ifndef ISIP_LONG #include #endif #ifndef ISIP_MEMORY_MANAGER #include #endif // Connection: a class that allows users to combine and manipulate // multiple feature streams. // class Connection : public AlgorithmBase { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // other important constants // //---------------------------------------- // define algorithm types // enum ALGORITHM { CHANNEL = 0, STREAM, DEF_ALGORITHM = CHANNEL }; // define implementation types // enum IMPLEMENTATION { CONCATENATE = 0, INTERLEAVE, SELECT, DEF_IMPLEMENTATION = CONCATENATE }; // define a static NameMap object to get the name of algorithm // 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_CHANNEL; //---------------------------------------- // // default values and arguments // //---------------------------------------- // define the default value(s) of the class data // // default arguments to methods // //---------------------------------------- // // error codes // //---------------------------------------- static const int32 ERR = 72100; static const int32 ERR_LENGTH = 72101; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // algorithm name // ALGORITHM algorithm_d; // implementation name // IMPLEMENTATION implementation_d; // channel specification // Long channel_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 is inherited from the base class // bool8 debug(const unichar* msg) const; // method: destructor // ~Connection() {} // method: default constructor // Connection(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION) { algorithm_d = algorithm; implementation_d = implementation; } // method: copy constructor // Connection(const Connection& arg) { algorithm_d = DEF_ALGORITHM; implementation_d = DEF_IMPLEMENTATION; assign(arg); } // method: assign // bool8 assign(const Connection& arg) { algorithm_d = arg.algorithm_d; implementation_d = arg.implementation_d; return AlgorithmBase::assign(arg); } // method: operator= // Connection& operator= (const Connection& 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 Connection& arg) const { return ((algorithm_d == arg.algorithm_d) && (implementation_d == arg.implementation_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); } // method: clear // bool8 clear(Integral::CMODE ctype = Integral::DEF_CMODE) { if (ctype != Integral::RETAIN) { algorithm_d = DEF_ALGORITHM; implementation_d = DEF_IMPLEMENTATION; } return AlgorithmBase::clear(ctype); } //--------------------------------------------------------------------------- // // 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: set // bool8 set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION) { algorithm_d = algorithm; implementation_d = implementation; is_valid_d = false; return true; } // method: setChannel // bool8 setChannel(int32 channel) { channel_d = channel; 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: get // bool8 get(ALGORITHM& algorithm, IMPLEMENTATION& implementation) const { algorithm = algorithm_d; implementation = implementation_d; return true; } // method: getChannel // int32 getChannel() const { return channel_d; } //--------------------------------------------------------------------------- // // public methods required by the AlgorithmBase interface contract // //--------------------------------------------------------------------------- // method: assign // bool8 assign(const AlgorithmBase& arg) { if (typeid(arg) == typeid(Connection)) { return assign((Connection&)arg); } else { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } } // method: eq // bool8 eq(const AlgorithmBase& arg) const { if (typeid(arg) == typeid(Connection)) { return eq((Connection&)arg); } else { return Error::handle(name(), L"eq", Error::ARG, __FILE__, __LINE__); } } // method: className // const String& className() const { return CLASS_NAME; } // computational methods // bool8 apply(Vector& output, const Vector< CircularBuffer >& input); // method to get the parser from the parent object // bool8 setParser(SofParser* parser); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // algorithm-specific computation methods: operate on channels // bool8 computeChannelConcatenate(VectorFloat& output, const Vector& input); bool8 computeChannelInterleave(VectorFloat& output, const Vector& input); bool8 computeStreamConcatenate(AlgorithmData& output, const AlgorithmData& input); bool8 computeStreamSelect(AlgorithmData& output, const Vector& input); }; // end of include file // #endif