📄 igraph_data.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: igraph_data.hpp,v $ * PRODUCTION Revision 1000.2 2004/06/01 19:48:12 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.10 * PRODUCTION * =========================================================================== */#ifndef GUI_GRAPH___IGRAPH_DATA__HPP#define GUI_GRAPH___IGRAPH_DATA__HPP/* $Id: igraph_data.hpp,v 1000.2 2004/06/01 19:48:12 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: Andrey Yazhuk * * File Description: * */#include <corelib/ncbistl.hpp>#include <gui/graph/igraph.hpp>/** @addtogroup GUI_GRAPH * * @{ */BEGIN_NCBI_SCOPE////////////////////////////////////////////////////////////////////////////////// interface IDataArrayclass NCBI_GUIGRAPH_EXPORT IDataArray{public: enum EDataType { eNumeric, eString, eColor, ePointer }; virtual ~IDataArray(); virtual EDataType GetType() = 0; virtual int GetSize() = 0;};////////////////////////////////////////////////////////////////////////////////// class STypeSelector// this class is used to define TValueType based on EDataTypetemplate <IDataArray::EDataType Type>struct STypeSelector {};template<> struct STypeSelector<IDataArray::eNumeric> { typedef TModelUnit TValueType;};template<> struct STypeSelector<IDataArray::eString> { typedef string TValueType;};template<> struct STypeSelector<IDataArray::eColor> { typedef CGlColor TValueType;};template<> struct STypeSelector<IDataArray::ePointer> { typedef void* TValueType;};////////////////////////////////////////////////////////////////////////////////// class ITypedDataArray<Type>template <IDataArray::EDataType Type>class ITypedDataArray : public IDataArray{public: typedef typename STypeSelector<Type>::TValueType TValueType; virtual EDataType GetType() { return Type; } virtual int GetSize() = 0; virtual TValueType GetElem(int i) = 0; // returns value of specialized type};// specialization for various EDataTypestypedef ITypedDataArray<IDataArray::eNumeric> INumericArray;typedef ITypedDataArray<IDataArray::eString> IStringArray;typedef ITypedDataArray<IDataArray::eColor> IColorArray;typedef ITypedDataArray<IDataArray::ePointer> IPointerArray;////////////////////////////////////////////////////////////////////////////////// class CTypedArrayAdapter<Type, TBase>template <IDataArray::EDataType Type, typename TBase =#ifndef NCBI_COMPILER_MSVC typename#endif ITypedDataArray<Type>::TValueType > class CTypedArrayAdapter : public ITypedDataArray<Type>{public: typedef typename ITypedDataArray<Type>::TValueType TValueType; typedef vector<TBase> TCont; CTypedArrayAdapter() {} CTypedArrayAdapter(int Length) { m_vValues.resize(Length); } // ITypedDataArray<Type> implementation virtual int GetSize() { return m_vValues.size(); } virtual TValueType GetElem(int i) { _ASSERT(i >= 0 && (size_t)i < m_vValues.size()); return (TValueType) m_vValues[i]; }; TCont& GetContainer() { return m_vValues; } const TCont& GetContainer() const { return m_vValues; } protected: TCont m_vValues;}; ////////////////////////////////////////////////////////////////////////////////// class CSeriesBase/// CSeries represents a set of colinear IDataArrays and provides basic access and management./// All arrays must have the same length.class NCBI_GUIGRAPH_EXPORT CSeriesBase{public: typedef IDataArray::EDataType EDataType; virtual ~CSeriesBase(); // user interface for accessing data int GetLength() const; int GetArraysCount() const; EDataType GetArrayType(int iArray) const; IDataArray* GetArray(int iArray) const; //string GetArrayName(int iArray) const; //int GetIndexByName(const string& Name);protected: // DataArray management interface provided for derived classes CSeriesBase(); CSeriesBase(int Length); virtual void CreateArrays(); virtual void CreateArrays(int Length); // CSeriesBase owns IDataArray-s added to series, destructor will destroy them void AddArray(/*const string& Name,*/ IDataArray* pArray); void InsertArray(int iArray,/*const string& Name,*/ IDataArray* pArray); //void RemoveArray(int iArray); void RemoveAllArrays(); // type-safe functions returning specialized arrays INumericArray* x_GetNumericArray(int iArray); IStringArray* x_GetStringArray(int iArray); IColorArray* x_GetColorArray(int iArray); IPointerArray* x_GetPointerArray(int iArray); inline void AssertArrayIndex(int iArray) const { _ASSERT(iArray >=0 && (size_t)iArray < m_vpArrays.size()); }protected: vector<IDataArray*> m_vpArrays; map<string, int> m_mpNameToIndex; int m_Length;};END_NCBI_SCOPE/* * =========================================================================== * $Log: igraph_data.hpp,v $ * Revision 1000.2 2004/06/01 19:48:12 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.10 * * Revision 1.10 2004/05/11 18:54:43 dicuccio * Added doxygen modules info * * Revision 1.9 2004/03/24 20:33:42 gorelenk * Added missed export prefixes. * * Revision 1.8 2003/10/08 14:11:30 dicuccio * Code clean-up. Use <> instead of "" for #includes. Moved CGlPane into opengl. * Moved CGlPoint and CGlRect into opengl. * * Revision 1.7 2003/09/10 21:51:24 yazhuk * GCC compilation fixes * * Revision 1.6 2003/09/04 13:58:42 dicuccio * Added export specifiers. Inlined destructors of interface classes * * Revision 1.5 2003/08/12 21:12:01 ucko * Give up on reaching a compromise and simply conditionalize the use of * "typename" at one point on the compiler in use; MIPSpro, in * particular, still needed it. * * Revision 1.4 2003/08/11 19:17:09 yazhuk * Compilation fix for MSVC * * Revision 1.3 2003/08/11 16:08:26 yazhuk * Compilation fixes for GCC. * * Revision 1.2 2003/08/10 14:11:18 dicuccio * Compilation fixes for gcc * * Revision 1.1 2003/08/08 16:01:35 yazhuk * Initial revision. * * =========================================================================== */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -