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 
28 namespace itk
29 {
46 template <typename TData>
47 class ITK_TEMPLATE_EXPORT CSVArray2DDataObject : public DataObject
48 {
49 public:
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 
69  using MatrixType = typename itk::Array2D<TData>;
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 
88  GetColumnHeaders() const;
89 
92  GetRowHeaders() const;
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
171  EraseFirstColumnHeader();
172 
173 protected:
174  CSVArray2DDataObject() = default;
175  ~CSVArray2DDataObject() override = default;
177  void
178  PrintSelf(std::ostream & os, Indent indent) const override;
179 
180 private:
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
itkObjectFactory.h
itk::CSVArray2DDataObject
Stores parsed data from csv files.
Definition: itkCSVArray2DDataObject.h:47
itk::CSVArray2DDataObject::MatrixType
typename itk::Array2D< TData > MatrixType
Definition: itkCSVArray2DDataObject.h:69
itk::CSVArray2DDataObject::NumericVectorType
typename std::vector< TData > NumericVectorType
Definition: itkCSVArray2DDataObject.h:65
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkDataObject.h
itkMacro.h
itk::DataObject
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:42
itk::Matrix
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:52
itkArray2D.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::CSVArray2DDataObject::StringVectorType
typename std::vector< std::string > StringVectorType
Definition: itkCSVArray2DDataObject.h:66
itk::Array2D< TData >
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293