name: Instance
synopsis:

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

>     #include <Instance.h>

>     boolean setInstanceMode(INSTANCE_MODE arg);
>     boolean setInstanceState(INSTANCE_STATE arg);
>     boolean setScore(float score);
>     boolean setHistory(History& history);

quick start:

>     Instance* curr_instance;
>     Instance* next_instance;

>     next_instance = new Instance(*curr_instance);
>     next_instance->setBackPointer(curr_instance);

description:
The instance constitutes the primary structure that represents a path in the search space. The instance contains the search symbols corresponding to the path, the time at which the path was generated, the history of the path, and the likelihood score of the path.
dependencies:

- SearchLevel.h

public constants:

- define class name:

      static const String CLASS_NAME;

- define public constants:

      enum INSTANCE_MODE { DECODE = 0, TRAIN, DEF_INSTANCE_MODE = DECODE };

      enum INSTANCE_STATE { INACTIVE = 0, PSEUDO_ACTIVE, ACTIVE, DEF_INSTANCE_STATE = INACTIVE };

- define default values:

      static const float INACTIVE_SCORE = -11111111111111.0f;

      static const float DEF_SCORE = 0.0;

      static const ulong DEF_FRAME = 0;

      static const ulong DEF_COUNT = 0;

      static const ulong DEF_SKIP_LEVEL = 0;

      static const ulong DEF_REF_INCR = 1;

      static const ulong DEF_REF_DECR = 1;

error codes:

- none.

protected data:

- define a enum that determines the instance mode:

      INSTANCE_MODE instance_mode_d;

- define a enum that determines the instance internal state:

      INSTANCE_STATE instance_state_d;

- define a structure to maintain the previous n-symbols:

      Context** nsymbol_d;

- define a back pointer to the previous trace(s):

      Instance* back_ptr_d;

- define variables to maintain the skip contexts:

      ulong skip_symbol_d;

      ulong skip_level_d;

- define a structure to maintain the current location in the search space:

      History* history_d;

- define the current symbol and context at the current location:

      Context* symbol_d;

- define the history of previously generated context dependent symbols:

      History* symbol_stack_d;

- define the reference to the symbol graph node:

      SymbolGraphNode* symbol_node_d;

- define a back pointer to the previous trace(s):

      SingleLinkedList<Instance> back_ptr_d;

- define the likelihood score for the path in the search space that this instance represents:

      float score_d;

- define the lm score for the path in the search space that this instance represents

      float lm_score_d;

- define the time stamp (frame) associaed with this instance:

      ulong frame_d;

- define a reference count that says when this instance can be deleted:

      ulong reference_count_d;

- declare the debugging parameters:

      static Integral::DEBUG debug_level_d;

- declare the memory manager:

      static MemoryManager mgr_d;

required public methods:

- static methods:

      static const String& name();

- debug methods:

      static boolean diagnose(Integral::DEBUG debug_level);

      boolean debug(const unichar* message) const;

      static boolean setDebug(Integral::DEBUG debug_level);

- destructor/constructor(s):

      ~Instance();

      Instance(float arg = DEF_SCORE);

      Instance(const Instance& arg);

- assign methods:

      boolean assign(const Instance& arg);

- operator= method:

      not present.

- i/o methods:

      long sofSize() const;

      boolean read(Sof& sof, long tag, const String& cname = CLASS_NAME);

      boolean write(Sof& sof, long tag, const String& cname = CLASS_NAME) const;

      boolean readData(Sof& sof, const String& pname = String::EMPTY, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);

      boolean writeData(Sof& sof, const String& pname = String::EMPTY) const;

- equality methods:

      boolean eq(const Instance& 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 cmode = Integral::DEF_CMODE);

class-specific public methods:

- declare instance mode and state methods:

      boolean match(const Instance& instance_a) const;

      boolean setInstanceMode(INSTANCE_MODE arg);

      INSTANCE_MODE getInstanceMode();

      boolean setInstanceState(INSTANCE_STATE arg);

      INSTANCE_STATE getInstanceState();

- declare instance likelihood methods:

      boolean setScore(float score);

      float getScore() const;

      boolean setLMScore(float score);

      float getLMScore() const;

      SymbolGraphNode* getSymbolNode();

      boolean setSymbolNode(SymbolGraphNode* arg);

- declare n-symbol probability methods:

      Context**& getNSymbol() const;

      boolean setNSymbol(Context**& arg);

- declare instance skip symbol methods:

      boolean setSkipSymbol(ulong symbol);

      ulong getSkipSymbol();

      boolean setSkipLevel(ulong level);

      ulong getSkipLevel();

- declare instance history methods:

      boolean setHistory(History& history);

      History* getHistory() const;

      boolean setPrevHistory(History& history);

      History* getPrevHistory() const;

      boolean setBackPointer(Instance* back_ptr);

      Instance* getBackPointer() const;

      boolean printHistory(const History& history);

- declare instance context manipulation methods:

      boolean hasNextLevelContext();

      boolean ascend(boolean verbose = false);

      boolean descend(boolean verbose = false);

- declare instance reference count methods:

      ulong decrementRefCount(ulong decrement = DEF_REF_DECR);

      ulong incrementRefCount(ulong increment = DEF_REF_INCR);

      boolean setRefCount(ulong count);

      ulong getRefCount() const;

- declare instance time-stamp methods:

      boolean setFrame(ulong frame);

      ulong getFrame() const;

- declare instance activity methods:

      boolean setActive(boolean is_active);

      boolean isActive() const;

- declare instance clean-up methods:

      static boolean deleteInstance(Instance* in_instance, boolean is_recursive, HashTable<HashKey<Instance>, BiGraphVertex<TrainNode> >* mapping, boolean clean_search_node = false);

      static boolean deleteInstance(Instance* in_instance, boolean is_recursive, boolean clean_search_node = false);

      static boolean deleteBackInstances(Instance* in_instance, boolean is_recursive, HashTable<HashKey<Instance>, BiGraphVertex<TrainNode> >* mapping, boolean clean_search_node = false);

      static boolean deleteBackInstances(Instance* in_instance, boolean is_recursive, boolean clean_search_node = false);

private methods:

- none.

examples:

- none.

notes:

- none.