ITK  4.13.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  /* Standard class typedefs */
54 
56  itkNewMacro(Self);
57 
60 
61  /* Vector typedefs. */
62  typedef typename std::vector<TData> NumericVectorType;
63  typedef typename std::vector<std::string> StringVectorType;
64 
66  typedef typename itk::Array2D<TData> MatrixType;
67 
69  itkSetMacro(HasColumnHeaders,bool);
70  itkSetMacro(HasRowHeaders,bool);
71  itkBooleanMacro(HasColumnHeaders);
72  itkBooleanMacro(HasRowHeaders);
74 
76  itkGetConstMacro(HasColumnHeaders, bool);
77  itkGetConstMacro(HasRowHeaders, bool);
79 
81  itkGetMacro(Matrix,MatrixType);
82 
84  StringVectorType GetColumnHeaders() const;
85 
87  StringVectorType GetRowHeaders() const;
88 
90  unsigned int GetRowIndexByName(const std::string &) const;
91 
93  unsigned int GetColumnIndexByName(const std::string &) const;
94 
96  NumericVectorType GetRow(const std::string &) const;
97 
99  NumericVectorType GetRow(const unsigned int & ) const;
100 
102  NumericVectorType GetColumn(const std::string & ) const;
103 
105  NumericVectorType GetColumn(const unsigned int &) const;
106 
109  TData GetData(const std::string &, const std::string &) const;
110 
113  TData GetData(const unsigned int &, const unsigned int &) const;
114 
117  TData GetColumnData(const std::string &, const unsigned int &) const;
118 
121  TData GetRowData(const std::string &, const unsigned int &) const;
122 
125  TData operator()(const std::string &, const std::string &) const;
126 
129  TData operator()(const unsigned int &, const unsigned int &) const;
130 
132  void SetMatrixSize(unsigned int, unsigned int);
133 
135  void FillMatrix(TData value);
136 
139  void SetMatrixData(unsigned int, unsigned int, TData);
140 
142  void RowHeadersPushBack(const std::string &);
143 
145  void ColumnHeadersPushBack(const std::string &);
146 
148  void EraseFirstColumnHeader();
149 
150 protected:
151 
153  virtual ~CSVArray2DDataObject() ITK_OVERRIDE {}
155  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
156 
157 private:
163 
164  ITK_DISALLOW_COPY_AND_ASSIGN(CSVArray2DDataObject);
165 };
166 
167 } //end namespace itk
168 
169 #ifndef ITK_MANUAL_INSTANTIATION
170 #include "itkCSVArray2DDataObject.hxx"
171 #endif
172 
173 #endif
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:53
std::vector< std::string > StringVectorType
Stores parsed data from csv files.
SmartPointer< const Self > ConstPointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
std::vector< TData > NumericVectorType
itk::Array2D< TData > MatrixType
Base class for all data objects in ITK.
virtual ~CSVArray2DDataObject() override