OW_NAMESPACE::IndexImpl Class Reference

Inheritance diagram for OW_NAMESPACE::IndexImpl:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

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

Private Attributes

DB * m_pDB
String m_dbFileName

Detailed Description

Definition at line 67 of file OW_IndexImpl.cpp.


Constructor & Destructor Documentation

OW_NAMESPACE::IndexImpl::IndexImpl  ) 
 

Definition at line 96 of file OW_IndexImpl.cpp.

OW_NAMESPACE::IndexImpl::~IndexImpl  )  [virtual]
 

Definition at line 101 of file OW_IndexImpl.cpp.

References close().


Member Function Documentation

bool OW_NAMESPACE::IndexImpl::add const char *  key,
Int32  offset
[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.

Implements OW_NAMESPACE::Index.

Definition at line 262 of file OW_IndexImpl.cpp.

References OW_THROW, and OW_NAMESPACE::ThreadImpl::theKey.

void OW_NAMESPACE::IndexImpl::close  )  [virtual]
 

Close the underlying index file if it is open.

Implements OW_NAMESPACE::Index.

Definition at line 201 of file OW_IndexImpl.cpp.

Referenced by open(), reopen(), and ~IndexImpl().

IndexEntry OW_NAMESPACE::IndexImpl::find const char *  key  )  [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.

Implements OW_NAMESPACE::Index.

Definition at line 239 of file OW_IndexImpl.cpp.

References openIfClosed(), OW_THROW, and OW_NAMESPACE::ThreadImpl::theKey.

Referenced by update().

IndexEntry OW_NAMESPACE::IndexImpl::findFirst const char *  key = NULL  )  [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.

Implements OW_NAMESPACE::Index.

Definition at line 325 of file OW_IndexImpl.cpp.

References openIfClosed(), OW_THROW, and OW_NAMESPACE::ThreadImpl::theKey.

Referenced by remove().

IndexEntry OW_NAMESPACE::IndexImpl::findNext  )  [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.

Implements OW_NAMESPACE::Index.

Definition at line 353 of file OW_IndexImpl.cpp.

References openIfClosed(), OW_THROW, and OW_NAMESPACE::ThreadImpl::theKey.

Referenced by remove().

IndexEntry OW_NAMESPACE::IndexImpl::findPrev  )  [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.

Implements OW_NAMESPACE::Index.

Definition at line 371 of file OW_IndexImpl.cpp.

References openIfClosed(), OW_THROW, and OW_NAMESPACE::ThreadImpl::theKey.

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

Flush all changes to the underlying index file.

Reimplemented from OW_NAMESPACE::Index.

Definition at line 211 of file OW_IndexImpl.cpp.

References reopen().

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

Definition at line 114 of file OW_IndexImpl.cpp.

References OW_NAMESPACE::FileSystem::canRead(), OW_NAMESPACE::FileSystem::canWrite(), close(), OW_NAMESPACE::Index::E_ALLDUPLICATES, m_dbFileName, m_pDB, OW_THROW, and recCompare().

void OW_NAMESPACE::IndexImpl::openIfClosed  ) 
 

Definition at line 177 of file OW_IndexImpl.cpp.

References OW_NAMESPACE::String::c_str(), m_dbFileName, OW_THROW, and recCompare().

Referenced by find(), findFirst(), findNext(), and findPrev().

bool OW_NAMESPACE::IndexImpl::remove const char *  key,
Int32  offset = -1L
[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.

Implements OW_NAMESPACE::Index.

Definition at line 278 of file OW_IndexImpl.cpp.

References findFirst(), findNext(), OW_THROW, and OW_NAMESPACE::ThreadImpl::theKey.

void OW_NAMESPACE::IndexImpl::reopen  ) 
 

Definition at line 155 of file OW_IndexImpl.cpp.

References OW_NAMESPACE::String::c_str(), close(), m_dbFileName, OW_THROW, and recCompare().

Referenced by flush().

bool OW_NAMESPACE::IndexImpl::update const char *  key,
Int32  newOffset
[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.

Implements OW_NAMESPACE::Index.

Definition at line 305 of file OW_IndexImpl.cpp.

References find(), OW_THROW, and OW_NAMESPACE::ThreadImpl::theKey.


Member Data Documentation

String OW_NAMESPACE::IndexImpl::m_dbFileName [private]
 

Definition at line 86 of file OW_IndexImpl.cpp.

Referenced by open(), openIfClosed(), and reopen().

DB* OW_NAMESPACE::IndexImpl::m_pDB [private]
 

Definition at line 85 of file OW_IndexImpl.cpp.

Referenced by open().


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