OW_NAMESPACE::Index Class Reference

The Index class is simply an interface class that helps facilitate a pluggable architecture for an indexing scheme on file. More...

#include <OW_Index.hpp>

Inheritance diagram for OW_NAMESPACE::Index:

Inheritance graph
[legend]
Collaboration diagram for OW_NAMESPACE::Index:

Collaboration graph
[legend]
List of all members.

Public Types

enum  EDuplicateKeysFlag { E_NO_DUPLICATES, E_ALLDUPLICATES }

Public Member Functions

virtual ~Index ()
 Destroy this Index object.
virtual void open (const char *fileName, EDuplicateKeysFlag allowDuplicates=E_NO_DUPLICATES)=0
 Open the given index file.
virtual void close ()=0
 Close the underlying index file if it is open.
virtual IndexEntry findFirst (const char *key=0)=0
 Position the cursor on the 1st entry in the index or the first record with a given key.
virtual IndexEntry findNext ()=0
 Position the cursor on the next entry in the index.
virtual IndexEntry findPrev ()=0
 Position the cursor on the previous entry in the index.
virtual IndexEntry find (const char *key)=0
 Position the cursor on the index entry associated a specified key.
virtual bool add (const char *key, Int32 offset)=0
 Add an entry to the index.
virtual bool remove (const char *key, Int32 offset=-1L)=0
 Remove an entry from the index.
virtual bool update (const char *key, Int32 newOffset)=0
 Update an index entry.
virtual void flush ()
 Flush all changes to the underlying index file.

Static Public Member Functions

static IndexRef createIndexObject ()
 Create dynamically allocated instances of a sub-class of Indexer.

Detailed Description

The Index class is simply an interface class that helps facilitate a pluggable architecture for an indexing scheme on file.

All Index objects will be used to maintain an index on some file. The only data ever associated with the key of the index will be a long value that will be used as an offset into a file. The implementor of the Index class must implement the createIndexObject class. This class will be called to get new Index objects that will later be deleted by the caller. The intention is for the implementor to create a sub-class of Index and have createIndexObject be the factory for those object.

Definition at line 61 of file OW_Index.hpp.


Member Enumeration Documentation

enum OW_NAMESPACE::Index::EDuplicateKeysFlag
 

Enumerator:
E_NO_DUPLICATES 
E_ALLDUPLICATES 

Definition at line 69 of file OW_Index.hpp.


Constructor & Destructor Documentation

OW_NAMESPACE::Index::~Index  )  [virtual]
 

Destroy this Index object.

This will close the index file if it is open.

Definition at line 43 of file OW_Index.cpp.


Member Function Documentation

virtual bool OW_NAMESPACE::Index::add const char *  key,
Int32  offset
[pure virtual]
 

Add an entry to the index.

Parameters:
key The key for the index entry to add.
offset The offset value for the index entry to add.
Returns:
true if an index entry was created in the index file. false if the index entry was already on file.
Exceptions:
IndexException If the index file hasn't been opened.

Implemented in OW_NAMESPACE::IndexImpl.

virtual void OW_NAMESPACE::Index::close  )  [pure virtual]
 

Close the underlying index file if it is open.

Implemented in OW_NAMESPACE::IndexImpl.

IndexRef OW_NAMESPACE::Index::createIndexObject  )  [static]
 

Create dynamically allocated instances of a sub-class of Indexer.

This method must be implemented by whomever desires to implement an Indexer sub-class.

Returns:
An instance of a sub-class of Indexer.

Definition at line 91 of file OW_IndexImpl.cpp.

Referenced by OW_NAMESPACE::HDB::checkFile(), OW_NAMESPACE::AssocDb::checkFile(), OW_NAMESPACE::HDB::createFile(), and OW_NAMESPACE::AssocDb::createFile().

virtual IndexEntry OW_NAMESPACE::Index::find const char *  key  )  [pure virtual]
 

Position the cursor on the index entry associated a specified key.

Returns:
An IndexEntry that contains information about the current entry in the index on success. On failure the returned IndexEntry will be null.
Exceptions:
IndexException If the index file hasn't been opened.

Implemented in OW_NAMESPACE::IndexImpl.

virtual IndexEntry OW_NAMESPACE::Index::findFirst const char *  key = 0  )  [pure virtual]
 

Position the cursor on the 1st entry in the index or the first record with a given key.

Parameters:
key The key to find the first occurence of. If NULL is given, the 1st entry of the index is returned, otherwise the first entry that has a key that is greater than or equal to the key parameter.
Returns:
An IndexEntry that contains information about the 1st entry in the index on success. On failure the returned IndexEntry will be null.
Exceptions:
IndexException If the index file hasn't been opened.

Implemented in OW_NAMESPACE::IndexImpl.

virtual IndexEntry OW_NAMESPACE::Index::findNext  )  [pure virtual]
 

Position the cursor on the next entry in the index.

Returns:
An IndexEntry that contains information about the current entry in the index on success. On failure the returned IndexEntry will be null.
Exceptions:
IndexException If the index file hasn't been opened.

Implemented in OW_NAMESPACE::IndexImpl.

virtual IndexEntry OW_NAMESPACE::Index::findPrev  )  [pure virtual]
 

Position the cursor on the previous entry in the index.

Returns:
An IndexEntry that contains information about the current entry in the index on success. On failure the returned IndexEntry will be null.
Exceptions:
IndexException If the index file hasn't been opened.

Implemented in OW_NAMESPACE::IndexImpl.

void OW_NAMESPACE::Index::flush  )  [virtual]
 

Flush all changes to the underlying index file.

Reimplemented in OW_NAMESPACE::IndexImpl.

Definition at line 48 of file OW_Index.cpp.

virtual void OW_NAMESPACE::Index::open const char *  fileName,
EDuplicateKeysFlag  allowDuplicates = E_NO_DUPLICATES
[pure virtual]
 

Open the given index file.

Parameters:
fileName The file name for the index file. If the file name has an extension, it will be removed. The name of the index file will be the base of fileName with the extension ".ndx".
Exceptions:
IndexException If the file cannot be created or opened.

virtual bool OW_NAMESPACE::Index::remove const char *  key,
Int32  offset = -1L
[pure virtual]
 

Remove an entry from the index.

Parameters:
key The key of the index entry to remove.
offset The value for the offset field of the index entry to remove. This parm is meaningless unless the index allows duplicate keys.
Returns:
true if the index entry was removed from the index file. false if the index entry could not be found.
Exceptions:
IndexException If the index file hasn't been opened.

Implemented in OW_NAMESPACE::IndexImpl.

virtual bool OW_NAMESPACE::Index::update const char *  key,
Int32  newOffset
[pure virtual]
 

Update an index entry.

Parameters:
key The key of the index entry to update.
newOffset The new value for the index entry.
Returns:
true if the record was updated. false if the record was not found.
Exceptions:
IndexException If the index file hasn't been opened.

Implemented in OW_NAMESPACE::IndexImpl.


The documentation for this class was generated from the following files:
Generated on Thu Feb 9 09:16:40 2006 for openwbem by  doxygen 1.4.6