NCBI C++ ToolKit
Public Types | Public Member Functions | List of all members
IBlobStorage Class Referenceabstract

Search Toolkit Book for IBlobStorage

Blob Storage interface. More...

#include <corelib/blob_storage.hpp>

+ Inheritance diagram for IBlobStorage:

Public Types

enum  ELockMode { eLockWait , eLockNoWait }
 

Public Member Functions

virtual ~IBlobStorage ()
 
virtual bool IsKeyValid (const string &str)=0
 Check if a given string is a valid key. More...
 
virtual string GetBlobAsString (const string &blob_key)=0
 Get a blob content as a string. More...
 
virtual CNcbiIstreamGetIStream (const string &blob_key, size_t *blob_size=NULL, ELockMode lock_mode=eLockWait)=0
 Get an input stream to a blob. More...
 
virtual CNcbiOstreamCreateOStream (string &blob_key, ELockMode lock_mode=eLockNoWait)=0
 Get an output stream to a blob. More...
 
virtual string CreateEmptyBlob ()=0
 Create a new empty blob. More...
 
virtual void DeleteBlob (const string &data_id)=0
 Delete a blob. More...
 
virtual void Reset ()=0
 Reset this object's data. More...
 
virtual void DeleteStorage (void)
 Delete the storage with all its data. More...
 

Detailed Description

Blob Storage interface.

Definition at line 47 of file blob_storage.hpp.

Member Enumeration Documentation

◆ ELockMode

Enumerator
eLockWait 

waits for BLOB to become available

eLockNoWait 

throws an exception immediately if BLOB locked

Definition at line 50 of file blob_storage.hpp.

Constructor & Destructor Documentation

◆ ~IBlobStorage()

IBlobStorage::~IBlobStorage ( )
virtual

Definition at line 45 of file blob_storage.cpp.

Member Function Documentation

◆ CreateEmptyBlob()

virtual string IBlobStorage::CreateEmptyBlob ( )
pure virtual

Create a new empty blob.

Returns
Newly create blob key

Implemented in CBlobStorage_Null, and CBlobStorage_NetCache.

◆ CreateOStream()

virtual CNcbiOstream& IBlobStorage::CreateOStream ( string blob_key,
ELockMode  lock_mode = eLockNoWait 
)
pure virtual

Get an output stream to a blob.

Parameters
blob_keyBlob key to write to. If a blob with a given key does not exist a new blob will be created and its key will be assigned to blob_key
lock_modeBlob locking mode

Implemented in CBlobStorage_NetCache, and CBlobStorage_Null.

◆ DeleteBlob()

virtual void IBlobStorage::DeleteBlob ( const string data_id)
pure virtual

Delete a blob.

Parameters
blob_keyBlob key to delete

Implemented in CBlobStorage_NetCache, and CBlobStorage_Null.

◆ DeleteStorage()

void IBlobStorage::DeleteStorage ( void  )
virtual

Delete the storage with all its data.

Note
The default implementation just throws "eNotImplemented" exception.

Definition at line 48 of file blob_storage.cpp.

References NCBI_THROW.

◆ GetBlobAsString()

virtual string IBlobStorage::GetBlobAsString ( const string blob_key)
pure virtual

Get a blob content as a string.

Parameters
blob_keyBlob key to read from

Implemented in CBlobStorage_NetCache, and CBlobStorage_Null.

◆ GetIStream()

virtual CNcbiIstream& IBlobStorage::GetIStream ( const string blob_key,
size_t *  blob_size = NULL,
ELockMode  lock_mode = eLockWait 
)
pure virtual

Get an input stream to a blob.

Parameters
blob_keyBlob key to read from
blob_sizeif blob_size if not NULL the size of a blob is returned
lock_modeBlob locking mode

Implemented in CBlobStorage_NetCache, and CBlobStorage_Null.

◆ IsKeyValid()

virtual bool IBlobStorage::IsKeyValid ( const string str)
pure virtual

Check if a given string is a valid key.

The implementation should not make any connection to the storage, it just checks the str structure.

Implemented in CBlobStorage_NetCache, and CBlobStorage_Null.

◆ Reset()

virtual void IBlobStorage::Reset ( )
pure virtual

Reset this object's data.

Note
The implementation of this method should close all opened streams and connections

Implemented in CBlobStorage_Null, and CBlobStorage_NetCache.


The documentation for this class was generated from the following files:
Modified on Fri Sep 20 14:57:44 2024 by modify_doxy.py rev. 669887