Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

gramstore.c File Reference

Implements the module that stores Grams. More...

#include <assert.h>
#include <string.h>
#include <stddef.h>
#include "fret.h"
#include "gramstore.h"
#include "common.h"
#include "rbtree.c"

Include dependency graph for gramstore.c:


Data Structures

struct  GsBuffer
struct  GramStore

Typedefs

typedef rbtree GramTree

Functions

bool putGram (Gram *const pGram)
 Makes a local copy of a Gram and stores it in the Gram Store.
bool deleteBufferGrams (BufferId bufferId)
bool deleteAllGrams (void)
bool getBufferGrams (const BufferId bufferId, GramReport *const pReport)
 Retrive a list of Grams for a specific Buffer.
bool getGenericGrams (GramReport *const pReport)
 Retrieve a list of Grams that apply to all the Buffers.
bool getBufferStats (BufferId bufferId, GsStats *const pStats)
 Retrive a struct that decribes a specific Buffer.
const GramgetThisGram (const Gram *const pGram)
const GramgetPrevGram (const Gram *const pGram)
const GramgetNextGram (const Gram *const pGram)
bool deleteGram (const Gram *const pGram)

Detailed Description

Implements the module that stores Grams.

This file implements the Gram Store, the module that provides the storage and retrieval of Grams. Each Gram that is stored is associated with Group ID and may also be associated with a Buffer ID.


Typedef Documentation

typedef struct rbtree GramTree
 

GramTree is the name used within libfret for the rbtree Red-Black Tree struct.


Function Documentation

bool deleteAllGrams void   ) 
 

Deletes all Grams, both generic and Buffer Grams. Memory: Must delete all GsBuffer objects that were allocated to this Group.

bool deleteBufferGrams BufferId  bufferId  ) 
 

Deletes all the Grams for a specific Buffer. Memory: Frees the GsBuffer object for this buffer.

bool deleteGram const Gram *const   pGram  ) 
 

Delete a single Gram.

bool getBufferGrams const BufferId  bufferId,
GramReport *const   pReport
 

Retrive a list of Grams for a specific Buffer.

Retrives a list of Grams for the Buffer whose ID is passed as a parameter. Memory: Function allocates an array of Gram objects. This array must be deallocated by the client modue.

Parameters:
bufferId ID of the Buffer.
pReport A pointer to a GramReport struct that will store a pointer to the newly allocated array of Grams.
Returns:
bool FRET_OK if at least one Gram was retrieved, otherwise FRET_FAIL.

bool getBufferStats BufferId  bufferId,
GsStats *const   pStats
 

Retrive a struct that decribes a specific Buffer.

Retrives a GsStats object for the Buffer whose ID is passed as a parameter.

Parameters:
bufferId ID of the Buffer.
pStats A pointer to a struct that will store the information.
Returns:
bool FRET_OK if stats were retrieved, otherwise FRET_FAIL.

bool getGenericGrams GramReport *const   pReport  ) 
 

Retrieve a list of Grams that apply to all the Buffers.

Retrives a list of Grams that are generic to all the Buffers. Only generic Grams are returned, not Grams for all the Buffers. Memory: Function allocates an array of Gram objects. This array must be deallocated by the client module.

Parameters:
pReport A pointer to a GramReport struct that will store a pointer to the newly allocated array of Grams.
Returns:
bool FRET_OK if at least one Gram was retrieved, otherwise FRET_FAIL.

const Gram* getNextGram const Gram *const   pGram  ) 
 

Find if there is a Gram that follows this Gram.

const Gram* getPrevGram const Gram *const   pGram  ) 
 

Find if there is a Gram that preceeds this Gram.

const Gram* getThisGram const Gram *const   pGram  ) 
 

Find if there is a Gram that matches the specified parameters in the Gram that is passed.

bool putGram Gram *const   pGram  ) 
 

Makes a local copy of a Gram and stores it in the Gram Store.

Function is passed a pointer to a Gram. It stores this Gram in the Gram Store, if the confidence for this Gram is greater than that of all overlapping Grams. Memory: GsBuffer object is allocated dynamically for each new Buffer. This memory must be deallocated by this module.

Parameters:
pGram A pointer to the Gram object to be stored. If the Gram's bufferId is NON_BUFFER_ID then the Gram is generic.
Returns:
bool FRET_OK if the Gram was added to the Gram Store. FRET_FAIL if the Gram could not be added to the Gram Store. This may be because it had lower confidence or because memory is exhausted.
Todo:
  • add policy changing
Todo:
  • if this fails, adjust stats
Todo:
  • differentiate between memory exhaustion and not adding a Gram due to lower confidence


Generated on Thu Jan 19 18:59:22 2006 for FRET by  doxygen 1.4.4