NCBI C++ ToolKit
igraph_data.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: igraph_data.cpp 23997 2011-07-05 15:20:35Z wuliangs $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrey Yazhuk
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
34 
36 
37 #define ASSERT_ARRAY_INDEX(iArray) _ASSERT((iArray) < m_vpArrays.size())
38 
39 ////////////////////////////////////////////////////////////////////////////////
40 /// IDataArray
41 
43 {
44 };
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 /// class CSeriesBase
49 : m_Length(0)
50 {
51 }
52 
54 : m_Length(Length)
55 {
56 }
57 
59 {
61 }
62 
63 
65 {
66  return m_Length;
67 }
69 {
70  return m_vpArrays.size();
71 }
72 
74 {
75  ASSERT_ARRAY_INDEX(iArray);
76  return m_vpArrays[iArray]->GetType();
77 }
78 
79 //*string GetArrayName(int iArray) const
80 
81 IDataArray* CSeriesBase::GetArray(size_t iArray) const
82 {
83  ASSERT_ARRAY_INDEX(iArray);
84  return m_vpArrays[iArray];
85 }
86 
87 //int GetIndexByName(const string& Name);
88 
90 {
92 }
93 
94 void CSeriesBase::CreateArrays(int Length)
95 {
96  m_Length = Length;
97  CreateArrays();
98 }
99 
100 void CSeriesBase::AddArray(/*const string& Name,*/ IDataArray* pArray)
101 {
102  //###_ASSERT(pArray && pArray->GetSize()==m_Length);
103  m_vpArrays.push_back(pArray);
104 }
105 
106 void CSeriesBase::InsertArray(size_t iArray,/* const string& Name,*/ IDataArray* pArray)
107 {
108  _ASSERT(pArray && pArray->GetSize() == (size_t)m_Length);
109  ASSERT_ARRAY_INDEX(iArray);
110  m_vpArrays.insert(m_vpArrays.begin() + iArray, pArray);
111 }
112 
114 {
115  NON_CONST_ITERATE(vector<IDataArray*>, it, m_vpArrays) {
116  delete *it;
117  }
118 }
119 
120 // type-safe functions returning specialized arrays
122 {
123  ASSERT_ARRAY_INDEX(iArray);
124  IDataArray* pAr = m_vpArrays[iArray];
125  return dynamic_cast<INumericArray*>(pAr);
126 }
127 
129 {
130  ASSERT_ARRAY_INDEX(iArray);
131  IDataArray* pAr = m_vpArrays[iArray];
132  return dynamic_cast<IStringArray*>(pAr);
133 }
134 
136 {
137  ASSERT_ARRAY_INDEX(iArray);
138  IDataArray* pAr = m_vpArrays[iArray];
139  return dynamic_cast<IColorArray*>(pAr);
140 }
141 
143 {
144  ASSERT_ARRAY_INDEX(iArray);
145  IDataArray* pAr = m_vpArrays[iArray];
146  return dynamic_cast<IPointerArray*>(pAr);
147 }
148 
interface IDataArray
Definition: igraph_data.hpp:50
class ITypedDataArray<Type>
Definition: igraph_data.hpp:90
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
void AddArray(IDataArray *pArray)
size_t GetArraysCount() const
Definition: igraph_data.cpp:68
EDataType GetArrayType(size_t iArray) const
Definition: igraph_data.cpp:73
int GetLength() const
Definition: igraph_data.cpp:64
virtual size_t GetSize()=0
vector< IDataArray * > m_vpArrays
virtual void CreateArrays()
Definition: igraph_data.cpp:89
CSeriesBase()
class CSeriesBase
Definition: igraph_data.cpp:48
void InsertArray(size_t iArray, IDataArray *pArray)
virtual ~IDataArray()
IDataArray.
Definition: igraph_data.cpp:42
IStringArray * x_GetStringArray(size_t iArray)
virtual ~CSeriesBase()
Definition: igraph_data.cpp:58
IPointerArray * x_GetPointerArray(size_t iArray)
IDataArray * GetArray(size_t iArray) const
Definition: igraph_data.cpp:81
INumericArray * x_GetNumericArray(size_t iArray)
IColorArray * x_GetColorArray(size_t iArray)
void RemoveAllArrays()
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define ASSERT_ARRAY_INDEX(iArray)
Definition: igraph_data.cpp:37
#define _ASSERT
Modified on Sat Jun 15 11:53:06 2024 by modify_doxy.py rev. 669887