ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkCSVArray2DDataObject.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 {
45 template <typename TData>
46 class ITK_TEMPLATE_EXPORT CSVArray2DDataObject:public DataObject
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_ASSIGN(CSVArray2DDataObject);
50 
51  /* Standard class type aliases */
56 
58  itkNewMacro(Self);
59 
61  itkTypeMacro(CSVArray2DDataObject, DataObject);
62 
63  /* Vector type alias. */
64  using NumericVectorType = typename std::vector<TData>;
65  using StringVectorType = typename std::vector<std::string>;
66 
68  using MatrixType = typename itk::Array2D<TData>;
69 
71  itkSetMacro(HasColumnHeaders,bool);
72  itkSetMacro(HasRowHeaders,bool);
73  itkBooleanMacro(HasColumnHeaders);
74  itkBooleanMacro(HasRowHeaders);
76 
78  itkGetConstMacro(HasColumnHeaders, bool);
79  itkGetConstMacro(HasRowHeaders, bool);
81 
83  itkGetMacro(Matrix,MatrixType);
84 
86  StringVectorType GetColumnHeaders() const;
87 
89  StringVectorType GetRowHeaders() const;
90 
92  unsigned int GetRowIndexByName(const std::string &) const;
93 
95  unsigned int GetColumnIndexByName(const std::string &) const;
96 
98  NumericVectorType GetRow(const std::string &) const;
99 
101  NumericVectorType GetRow(const unsigned int & ) const;
102 
104  NumericVectorType GetColumn(const std::string & ) const;
105 
107  NumericVectorType GetColumn(const unsigned int &) const;
108 
111  TData GetData(const std::string &, const std::string &) const;
112 
115  TData GetData(const unsigned int &, const unsigned int &) const;
116 
119  TData GetColumnData(const std::string &, const unsigned int &) const;
120 
123  TData GetRowData(const std::string &, const unsigned int &) const;
124 
127  TData operator()(const std::string &, const std::string &) const;
128 
131  TData operator()(const unsigned int &, const unsigned int &) const;
132 
134  void SetMatrixSize(unsigned int, unsigned int);
135 
137  void FillMatrix(TData value);
138 
141  void SetMatrixData(unsigned int, unsigned int, TData);
142 
144  void RowHeadersPushBack(const std::string &);
145 
147  void ColumnHeadersPushBack(const std::string &);
148 
150  void EraseFirstColumnHeader();
151 
152 protected:
153 
155  ~CSVArray2DDataObject() override = default;
157  void PrintSelf(std::ostream & os, Indent indent) const override;
158 
159 private:
165 
166 };
167 
168 } //end namespace itk
169 
170 #ifndef ITK_MANUAL_INSTANTIATION
171 #include "itkCSVArray2DDataObject.hxx"
172 #endif
173 
174 #endif
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:49
typename std::vector< std::string > StringVectorType
Stores parsed data from csv files.
typename itk::Array2D< TData > MatrixType
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:41
typename std::vector< TData > NumericVectorType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for most ITK classes.
Definition: itkObject.h:60
Base class for all data objects in ITK.