ITK  4.2.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 <class TData>
46 class ITK_EXPORT CSVArray2DDataObject:public DataObject
47 {
48 public:
49  /* Standard class typedefs */
54 
56  itkNewMacro(Self);
57 
59  itkTypeMacro(Self,Superclass);
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 
155  void PrintSelf(std::ostream & os, Indent indent) const;
156 
157 private:
163 
164  CSVArray2DDataObject(const Self &); //purposely not implemented
165  void operator=(const Self &); //purposely not implemented
166 };
167 
168 } //end namespace itk
169 
170 #ifndef ITK_MANUAL_INSTANTIATION
171 #include "itkCSVArray2DDataObject.hxx"
172 #endif
173 
174 #endif
175