ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkCSVArray2DDataObject.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 
00019 #ifndef __itkCSVArray2DDataObject_h
00020 #define __itkCSVArray2DDataObject_h
00021 
00022 #include "itkObjectFactory.h"
00023 #include "itkDataObject.h"
00024 #include "itkArray2D.h"
00025 #include "itkMacro.h"
00026 #include <vector>
00027 
00028 namespace itk
00029 {
00045 template <class TData>
00046 class ITK_EXPORT CSVArray2DDataObject:public DataObject
00047 {
00048 public:
00049   /* Standard class typedefs */
00050   typedef CSVArray2DDataObject        Self;
00051   typedef DataObject                  SuperClass;
00052   typedef SmartPointer<Self>          Pointer;
00053   typedef SmartPointer<const Self>    ConstPointer;
00054 
00056   itkNewMacro(Self);
00057 
00059   itkTypeMacro(Self,Superclass);
00060 
00061   /* Vector typedefs. */
00062   typedef typename std::vector<TData>              NumericVectorType;
00063   typedef typename std::vector<std::string>        StringVectorType;
00064 
00066   typedef typename itk::Array2D<TData>  MatrixType;
00067 
00069   itkSetMacro(HasColumnHeaders,bool);
00070   itkSetMacro(HasRowHeaders,bool);
00071   itkBooleanMacro(HasColumnHeaders);
00072   itkBooleanMacro(HasRowHeaders);
00074 
00076   itkGetConstMacro(HasColumnHeaders, bool);
00077   itkGetConstMacro(HasRowHeaders, bool);
00079 
00081   itkGetMacro(Matrix,MatrixType);
00082 
00084   StringVectorType GetColumnHeaders() const;
00085 
00087   StringVectorType GetRowHeaders() const;
00088 
00090   unsigned int GetRowIndexByName(const std::string &) const;
00091 
00093   unsigned int GetColumnIndexByName(const std::string &) const;
00094 
00096   NumericVectorType GetRow(const std::string &) const;
00097 
00099   NumericVectorType GetRow(const unsigned int & ) const;
00100 
00102   NumericVectorType GetColumn(const std::string & ) const;
00103 
00105   NumericVectorType GetColumn(const unsigned int &) const;
00106 
00109   TData GetData(const std::string &, const std::string &) const;
00110 
00113   TData GetData(const unsigned int &, const unsigned int &) const;
00114 
00117   TData GetColumnData(const std::string &, const unsigned int &) const;
00118 
00121   TData GetRowData(const std::string &, const unsigned int &) const;
00122 
00125   TData operator()(const std::string &, const std::string &) const;
00126 
00129   TData operator()(const unsigned int &, const unsigned int &) const;
00130 
00132   void SetMatrixSize(unsigned int, unsigned int);
00133 
00135   void FillMatrix(TData value);
00136 
00139   void SetMatrixData(unsigned int, unsigned int, TData);
00140 
00142   void RowHeadersPushBack(const std::string &);
00143 
00145   void ColumnHeadersPushBack(const std::string &);
00146 
00148   void EraseFirstColumnHeader();
00149 
00150 protected:
00151 
00152   CSVArray2DDataObject();
00153   virtual ~CSVArray2DDataObject() {}
00155   void PrintSelf(std::ostream & os, Indent indent) const;
00156 
00157 private:
00158   MatrixType             m_Matrix;
00159   StringVectorType       m_ColumnHeaders;
00160   StringVectorType       m_RowHeaders;
00161   bool                   m_HasRowHeaders;
00162   bool                   m_HasColumnHeaders;
00163 
00164   CSVArray2DDataObject(const Self &); //purposely not implemented
00165   void operator=(const Self &);       //purposely not implemented
00166 };
00167 
00168 } //end namespace itk
00169 
00170 #ifndef ITK_MANUAL_INSTANTIATION
00171 #include "itkCSVArray2DDataObject.hxx"
00172 #endif
00173 
00174 #endif
00175