name: Component
synopsis:

>     g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_sp.a

>     #include <Component.h>

>     Component(ALGORITHM algorithm = DEF_ALGORITHM);
>     Component(const Component& arg);
>     boolean setAlgorithm(const Algorithm& arg);
>     boolean getOutputName(const String& oname);

quick start:

>     Component mfcc;
>     Window win;
>     win.setSize(12);
>     win.setAlgorithm(Window::HAMMING);
>     mfcc.setAlgorithm(win);

description:
Signal flow graphs in isip_transform are represented using a graph of algorithm objects. This class is used to represent a block in this graph. Each component object holds an object. A related class, Recipe, is used to represent the entire graph (as a graph of Component objects).
dependencies:

- String
- Long
- Vector
- Algorithm

public constants:

- define the class name:

      static const String CLASS_NAME = L"Component";

- define i/o related constants:

      static const String DEF_PARAM = L"";

      static const String PARAM_INPUT_NAMES = L"input";

      static const String PARAM_OUTPUT_NAME = L"output";

      static const String PARAM_COMPONENT = L"algo";

- define default values of the class data:

      static const Char DELIM = L'+';

error codes:

- general error codes:

      static const long ERR = 80100;

protected data:

- start with this data: note that each component can have multiple inputs and one output.

      Vector<String> input_names_d;

      Vector<Long> input_offsets_d;

- transformation algorithm:

      Algorithm algo_d;

- end up with this data: note that each component can have only one output.

      String output_name_d;

- add a debug level:

      static Integral::DEBUG debug_level_d;

- and a Memory Manager:

      static MemoryManager mgr_d;

required public methods:

- static methods:

      static const String& name();

      static boolean diagnose(Integral::DEBUG debug_level);

- debug methods: the setDebug method is inherited from base class

      boolean debug(const unichar* message) const;

- destructor/constructor(s):

      ~Component();

      Component();

      Component(const Component& arg);

- assign methods:

      boolean assign(const Component& 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;

- equality methods:

      boolean eq(const Component& arg) const;

- memory management methods:

      static void* operator new(size_t size);

      static void* operator new[](size_t size);

      static void operator delete(void* ptr);

      static void operator delete[](void* ptr);

      static boolean setGrowSize(long grow_size);

      boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE);

class-specific public methods:

- set methods:

      boolean setAlgorithm(const Algorithm& arg);

      boolean setInputName(const String& str);

      boolean setInputName(long index, const String& str);

      boolean setOutputName(const String& oname);

      boolean setSampleFrequency(float sf);

      boolean setFrameDuration(float sf);

      boolean setLeftoverSamps(long dur);

      boolean setFrameIndex(long index);

      boolean setSignalDuration(float dur);

      boolean setInputFilename(Filename& basename);

      boolean setOutputDirectory(String& directory);

      boolean setOutputBasename(String& basename);

      boolean setOutputExtension(String& extension);

      boolean setOutputPreserve(long new_pres_level);

      boolean setOutputSuffix(String& suffix);

      boolean setOutputType(File::TYPE type);

- get methods:

      const Algorithm& getAlgorithm() const;

      const String& getInputName(long index) const;

      const String& getOutputName() const;

      long getInputOffset(long index) const;

      long getNumInputs() const;

      boolean isInput(const Component& arg) const;

      boolean isCoefficientLabel(const Component& arg) const;

      boolean isCoefficientLabel(const Component& arg) const;

      boolean getGenSampleFrequency(Float& sf)  const;

- methods related to the AlgorithmBase interface contract:

      boolean init();

      boolean apply(Vector<AlgorithmData>& output, const Vector< CircularBuffer<AlgorithmData> >& input);

      long getLeadingPad() const;

      long getTrailingPad() const;

- special getInputFilename method to get the input filename from Constant class:

       boolean const getInputFilename(String& filename) const;

- special getOutputFilename method to get the input filename from Constant and Output class:

       boolean const getOutputFilename(String& filename) const;

private methods:

- methods to manipulate names:

      boolean splitName(String& base_name, Long& offset, const String& str) const;

      boolean joinName(String& output) const;

examples:

- This example shows how to use the Component:

      Vector signal(1);
      signal(0).makeVector().assign(L"0,48,-32,0,-16,-48,-32,-32,16,-48,00,-16,16");
      Component mfcc;
      Window win;

      win.setSize(12);
      win.setAlgorithm(Window::HAMMING);
      mfcc.setAlgorithm(win);
      mfcc.apply(output, signal);

notes:

- This class, as are most of the signal processing library classes, are mainly used to support the isip_transform infrastructure. It is not a class that your typical research or application programmer will use in doing custom software development.