📄 shi_loader.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: shi_loader.hpp,v $ * PRODUCTION Revision 1000.0 2004/04/12 18:27:00 gouriano * PRODUCTION PRODUCTION: IMPORTED [CATCHUP_003] Dev-tree R1.4 * PRODUCTION * =========================================================================== */#ifndef GUI_WIDGETS_GRAPH_3D___SHI_LOADER__HPP#define GUI_WIDGETS_GRAPH_3D___SHI_LOADER__HPP/* $Id: shi_loader.hpp,v 1000.0 2004/04/12 18:27:00 gouriano Exp $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors: Vladimir Tereshkov * * File Description: * Shi file format loader header. Code ported from shi/shipr.c CGI. */#include <corelib/ncbistd.hpp>#include <corelib/ncbi_bswap.hpp>#include <gui/widgets/taxplot3d/taxplot3d_ds.hpp>#include <gui/widgets/taxplot3d/shi_loader_events.hpp>#include <memory>BEGIN_NCBI_SCOPE// one record in Taxplot file formatstruct SShiRecord { public: int m_Nqugi, m_Dagi, m_Taxid, m_Score, m_Orgclass, m_Symmet, m_Chromosome, m_Pdb; SShiRecord(){}; ~SShiRecord(){};};// complete shi fileclass CShiFile { private: string m_FileName; CT_POS_TYPE m_FileSize; CT_OFF_TYPE m_FileCursor; CNcbiIfstream m_FileStream; SShiRecord m_Record; auto_ptr<unsigned char> m_Buff; int length,jbuf,value,no_more,last_gi,nshi; int getNextInt(void); public: CShiFile(){} ~CShiFile(){} // get access string & getFileName(void) { return m_FileName; } CT_POS_TYPE & getFileSize(void) { return m_FileSize; } CT_OFF_TYPE & getFileCursor(void) { return m_FileCursor; } CNcbiIfstream & getFileStream(void) { return m_FileStream; } // checks int isEof(void) const; int isLastGi(void) const; // actions void openFile(const string name); int getNextRecord(SShiRecord & rec);};inline int CShiFile::isEof(void) const{ return (m_FileCursor*4) >= m_FileSize - CT_POS_TYPE(0);}inline int CShiFile::isLastGi(void) const {return last_gi; }inline int CShiFile::getNextInt(void){ unsigned char * ptr = m_Buff.get() + m_FileCursor*4; Int4 ret = (Int4(ptr[3]) << 24) | (Int4(ptr[2]) << 16) | (Int4(ptr[1]) << 8) | (Int4(ptr[0])); m_FileCursor += 1; return ret;}// loader wrapperclass ShiLoader {private: // simplified cache typedef map <int, int> TSMAP; // tax&score vect for 1 gi typedef vector <TSMAP> GIVECTOR; // all cachable gi's GIVECTOR m_Cache; // datasource CTaxplot3dDataSource * m_DS; // callbacks IShiLoaderEvents * m_Handle; public: ShiLoader() { m_DS = new CTaxplot3dDataSource(); m_Cache.clear(); m_Handle = NULL; } ~ShiLoader() { if (m_DS) delete m_DS; m_Cache.clear(); } int loadFileNew(const char * file); CTaxplot3dDataSource * getData(int gi1, int gi2, int gi3); void setConnectionPoint(IShiLoaderEvents * handle) {m_Handle = handle;}; };END_NCBI_SCOPE/* * =========================================================================== * $Log: shi_loader.hpp,v $ * Revision 1000.0 2004/04/12 18:27:00 gouriano * PRODUCTION: IMPORTED [CATCHUP_003] Dev-tree R1.4 * * Revision 1.4 2004/02/20 20:03:27 ucko * Fix to compile with stricter implementations of CT_POS_TYPE * * Revision 1.3 2004/01/15 13:09:09 ucko * Use CT_POS_TYPE macro rather than pos_type typedef, which GCC 2.95 lacks. * * Revision 1.2 2004/01/15 01:15:20 ucko * +<memory> for auto_ptr<> * * Revision 1.1 2004/01/05 16:22:03 tereshko * Initial revision * * =========================================================================== */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -