NCBI C++ ToolKit
Implementing the BlastSeqSrc interface

Implementations of this interface should provide life-cycle functions as well as functions which satisfy the BlastSeqSrc interface.

These functions must have C linkage, as these functions are invoked by the BlastSeqSrc framework. An initialization function must also be provided, this is intended to be invoked by client code which wants to use a specific BlastSeqSrc implementation through the BlastSeqSrc interface. For example, MyDatabaseFormat implementation would define the following functions:

  • Initialization function
    // Calls BlastSeqSrcNew in behalf of client code, client should free using
    // BlastSeqSrcFree
    BlastSeqSrc* MyDatabaseFormatBlastSeqSrcInit(...);
    Complete type definition of Blast Sequence Source ADT.
    Definition: blast_seqsrc.c:43
  • Life-cycle functions
    extern "C" {
    // required signature: BlastSeqSrcConstructor
    BlastSeqSrc* MyDatabaseFormatNew(BlastSeqSrc*, void*);
    // required signature: BlastSeqSrcDestructor
    BlastSeqSrc* MyDatabaseFormatFree(BlastSeqSrc*);
    // required signature: BlastSeqSrcCopier
    BlastSeqSrc* MyDatabaseFormatCopy(BlastSeqSrc*);
    }
  • BlastSeqSrc interface
    extern "C" {
    // required signature: SetInt4FnPtr
    void MyDatabaseFormatSetNumberOfThreads(int);
    // required signature: GetInt4FnPtr
    Int4 MyDatabaseFormatGetNumSeqs(void*, void*);
    // required signature: GetInt4FnPtr
    Int4 MyDatabaseFormatGetNumSeqsStats(void*, void*);
    // required signature: GetInt4FnPtr
    Int4 MyDatabaseFormatGetMaxSeqLen(void*, void*);
    // required signature: GetInt4FnPtr
    Int4 MyDatabaseFormatGetMinSeqLen(void*, void*);
    // required signature: GetInt4FnPtr
    Int4 MyDatabaseFormatGetAvgSeqLen(void*, void*);
    // required signature: GetInt8FnPtr
    Int8 MyDatabaseFormatGetTotLen(void*, void*);
    // required signature: GetInt8FnPtr
    Int8 MyDatabaseFormatGetTotLenStats(void*, void*);
    // required signature: GetStrFnPtr
    const char* MyDatabaseFormatGetName(void*, void*);
    // required signature: GetBoolFnPtr
    Boolean MyDatabaseFormatGetIsProt(void*, void*);
    // required signature: GetSeqBlkFnPtr
    Int2 MyDatabaseFormatGetSequence(void*, BlastSeqSrcGetSeqArg*);
    // required signature: GetInt4FnPtr
    Int4 MyDatabaseFormatGetSeqLen(void*, void*);
    // required signature: ReleaseSeqBlkFnPtr
    void MyDatabaseFormatReleaseSequence(void*, BlastSeqSrcGetSeqArg*);
    // required signature: AdvanceIteratorFnPtr
    Int4 MyDatabaseFormatItrNext(void*, BlastSeqSrcIterator* itr);
    // required signature: ResetChunkIteratorFnPtr
    Int4 MyDatabaseFormatResetChunkIterator(void*);
    }
    int16_t Int2
    2-byte (16-bit) signed integer
    Definition: ncbitype.h:100
    int32_t Int4
    4-byte (32-bit) signed integer
    Definition: ncbitype.h:102
    int64_t Int8
    8-byte (64-bit) signed integer
    Definition: ncbitype.h:104
    Uint1 Boolean
    bool replacment for C
    Definition: ncbi_std.h:94
    Structure used as the second argument to functions satisfying the GetSeqBlkFnPtr signature,...
    Definition: blast_seqsrc.h:257
    Complete type definition of Blast Sequence Source Iterator.

Since the life-cycle and BlastSeqSrc interface functions above are called by the BlastSeqSrc framework (BlastSeqSrc* functions declared in blast_seqsrc.h), no exceptions should be thrown in C++ implementations. When not obvious, please see the required signature's documentation for determining what to implement (see blast_seqsrc_impl.h).

For ease of maintenance, please follow the following conventions:

  • Client implementations' initialization function should be called XBlastSeqSrcInit, where X is the name of the implementation
  • Client implementations should reside in a file named seqsrc_X.[hc] or seqsrc_X.[ch]pp, where X is the name of the implementation.
Modified on Sun Jun 02 05:18:02 2024 by modify_doxy.py rev. 669887