ITK  6.0.0
Insight Toolkit
itkCSVArray2DDataObject.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18
19#ifndef itkCSVArray2DDataObject_h
20#define itkCSVArray2DDataObject_h
21
22#include "itkObjectFactory.h"
23#include "itkDataObject.h"
24#include "itkArray2D.h"
25#include "itkMacro.h"
26#include <vector>
27
28namespace itk
29{
46template <typename TData>
47class ITK_TEMPLATE_EXPORT CSVArray2DDataObject : public DataObject
48{
49public:
50 ITK_DISALLOW_COPY_AND_MOVE(CSVArray2DDataObject);
51
52 /* Standard class type aliases */
57
59 itkNewMacro(Self);
60
62 itkOverrideGetNameOfClassMacro(CSVArray2DDataObject);
63
64 /* Vector type alias. */
65 using NumericVectorType = typename std::vector<TData>;
66 using StringVectorType = typename std::vector<std::string>;
67
70
72 itkSetMacro(HasColumnHeaders, bool);
73 itkSetMacro(HasRowHeaders, bool);
74 itkBooleanMacro(HasColumnHeaders);
75 itkBooleanMacro(HasRowHeaders);
79 itkGetConstMacro(HasColumnHeaders, bool);
80 itkGetConstMacro(HasRowHeaders, bool);
84 itkGetMacro(Matrix, MatrixType);
85
89
93
95 unsigned int
96 GetRowIndexByName(const std::string &) const;
97
99 unsigned int
100 GetColumnIndexByName(const std::string &) const;
101
104 GetRow(const std::string &) const;
105
108 GetRow(const unsigned int) const;
109
112 GetColumn(const std::string &) const;
113
116 GetColumn(const unsigned int) const;
117
120 TData
121 GetData(const std::string &, const std::string &) const;
122
125 TData
126 GetData(const unsigned int, const unsigned int) const;
127
130 TData
131 GetColumnData(const std::string &, const unsigned int) const;
132
135 TData
136 GetRowData(const std::string &, const unsigned int) const;
137
140 TData
141 operator()(const std::string &, const std::string &) const;
142
145 TData
146 operator()(const unsigned int, const unsigned int) const;
147
149 void
150 SetMatrixSize(unsigned int, unsigned int);
151
153 void
154 FillMatrix(TData value);
155
158 void
159 SetMatrixData(unsigned int, unsigned int, TData);
160
162 void
163 RowHeadersPushBack(const std::string &);
164
166 void
167 ColumnHeadersPushBack(const std::string &);
168
170 void
172
173protected:
175 ~CSVArray2DDataObject() override = default;
177 void
178 PrintSelf(std::ostream & os, Indent indent) const override;
179
180private:
181 MatrixType m_Matrix{};
182 StringVectorType m_ColumnHeaders{};
183 StringVectorType m_RowHeaders{};
184 bool m_HasRowHeaders{ false };
185 bool m_HasColumnHeaders{ false };
186};
187
188} // end namespace itk
189
190#ifndef ITK_MANUAL_INSTANTIATION
191# include "itkCSVArray2DDataObject.hxx"
192#endif
193
194#endif
Stores parsed data from csv files.
unsigned int GetColumnIndexByName(const std::string &) const
TData GetColumnData(const std::string &, const unsigned int) const
unsigned int GetRowIndexByName(const std::string &) const
TData GetRowData(const std::string &, const unsigned int) const
typename itk::Array2D< TData > MatrixType
void PrintSelf(std::ostream &os, Indent indent) const override
NumericVectorType GetColumn(const unsigned int) const
NumericVectorType GetRow(const std::string &) const
TData operator()(const unsigned int, const unsigned int) const
typename std::vector< TData > NumericVectorType
TData GetData(const unsigned int, const unsigned int) const
TData GetData(const std::string &, const std::string &) const
StringVectorType GetRowHeaders() const
NumericVectorType GetColumn(const std::string &) const
typename std::vector< std::string > StringVectorType
void SetMatrixData(unsigned int, unsigned int, TData)
void FillMatrix(TData value)
~CSVArray2DDataObject() override=default
void ColumnHeadersPushBack(const std::string &)
StringVectorType GetColumnHeaders() const
void RowHeadersPushBack(const std::string &)
NumericVectorType GetRow(const unsigned int) const
TData operator()(const std::string &, const std::string &) const
void SetMatrixSize(unsigned int, unsigned int)
Base class for all data objects in ITK.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:53
Base class for most ITK classes.
Definition: itkObject.h:62
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:42