cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsMatrix.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Anton Deguet
7  Created on: 2009-04-29
8 
9  (C) Copyright 2009-2014 Johns Hopkins University (JHU), All Rights Reserved.
10 
11 --- begin cisst license - do not edit ---
12 
13 This software is provided "as is" under an open source license, with
14 no warranty. The complete license can be found in license.txt and
15 http://www.cisst.org/cisst/license.txt.
16 
17 --- end cisst license ---
18 */
19 
20 
21 #ifndef _mtsMatrix_h
22 #define _mtsMatrix_h
23 
28 
29 // Always include last
31 
32 template <class _elementType>
34  public vctDynamicMatrix<_elementType> {
35  // declare services, requires dynamic creation
36  CMN_DECLARE_SERVICES_EXPORT(CMN_DYNAMIC_CREATION, CMN_LOG_ALLOW_DEFAULT);
37 public:
38  /* defines useful types */
39  VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType);
40  enum {DIMENSION = 2};
42 
45 
48 
50  inline mtsMatrix(void):
52  MatrixType(0, 0)
53  {}
54 
58  MatrixType(rows, cols)
59  {
61  }
62 
63  inline mtsMatrix(const nsize_type & size):
65  MatrixType(size)
66  {
68  }
69 
73  inline ThisType & operator = (const MatrixType & data) {
74  MatrixType::SetSize(data.rows(), data.cols(), data.StorageOrder());
75  MatrixType::Assign(data);
76  return *this;
77  }
78 
80  inline mtsMatrix(const ThisType & otherMatrix):
81  mtsGenericObject(otherMatrix),
82  MatrixType(otherMatrix)
83  {}
84 
86  inline mtsMatrix(const MatrixType & otherMatrix):
88  MatrixType(otherMatrix)
89  {}
90 
93  inline ~mtsMatrix() {}
94 
96  virtual std::string ToString(void) const {
97  std::stringstream outputStream;
98  this->ToStream(outputStream);
99  return outputStream.str();
100  }
101 
103  virtual void ToStream(std::ostream & outputStream) const {
104  mtsGenericObject::ToStream(outputStream);
105  outputStream << std::endl;
106  MatrixType::ToStream(outputStream);
107  }
108 
110  inline virtual void ToStreamRaw(std::ostream & outputStream, const char delimiter = ' ',
111  bool headerOnly = false, const std::string & headerPrefix = "") const {
112  mtsGenericObject::ToStreamRaw(outputStream, delimiter, headerOnly, headerPrefix);
113  outputStream << delimiter;
114  MatrixType::ToStreamRaw(outputStream, delimiter, headerOnly, headerPrefix);
115  }
116 
118  void SerializeRaw(std::ostream & outputStream) const
119  {
120  mtsGenericObject::SerializeRaw(outputStream);
121  MatrixType::SerializeRaw(outputStream);
122  }
123 
125  void DeSerializeRaw(std::istream & inputStream)
126  {
128  MatrixType::DeSerializeRaw(inputStream);
129  }
130 
131 };
132 
133 
134 // define some basic vectors
137 
140 
143 
146 
149 
152 
155 
158 
161 
164 
167 
168 #endif // _mtsMatrix_h
vctDynamicMatrix< value_type > MatrixType
Definition: mtsMatrix.h:47
Declaration of vctDynamicMatrix.
VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType)
virtual void SerializeRaw(std::ostream &outputStream) const
void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
Definition: vctDynamicConstMatrixBase.h:1043
Definition: mtsMatrix.h:33
virtual void DeSerializeRaw(std::istream &inputStream)
size_type size(void) const
Definition: vctDynamicConstMatrixBase.h:228
mtsMatrix< value_type > ThisType
Definition: mtsMatrix.h:44
virtual void ToStream(std::ostream &outputStream) const
A matrix object of dynamic size.
Definition: vctDynamicMatrix.h:136
size_t size_type
Definition: vctContainerTraits.h:35
Class register definitions and log macros.
bool StorageOrder(void) const
Definition: vctDynamicConstMatrixBase.h:656
Base class for data object in cisstMultiTask.
Definition: mtsGenericObject.h:56
mtsMatrix< unsigned char > mtsUCharMat
Definition: mtsMatrix.h:162
CMN_DECLARE_SERVICES_INSTANTIATION(mtsDoubleMat)
ThisType & operator=(const MatrixType &data)
Definition: mtsMatrix.h:73
Definition: vctDynamicConstMatrixBase.h:77
void SerializeRaw(std::ostream &outputStream) const
Definition: vctDynamicConstMatrixBase.h:1107
void DeSerializeRaw(std::istream &inputStream)
Definition: vctDynamicMatrix.h:382
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
Definition: mtsMatrix.h:110
void SerializeRaw(std::ostream &outputStream) const
Definition: mtsMatrix.h:118
mtsMatrix< unsigned int > mtsUIntMat
Definition: mtsMatrix.h:150
mtsMatrix(const ThisType &otherMatrix)
Definition: mtsMatrix.h:80
mtsMatrix(void)
Definition: mtsMatrix.h:50
mtsMatrix< unsigned short > mtsUShortMat
Definition: mtsMatrix.h:156
mtsMatrix< unsigned long > mtsULongMat
Definition: mtsMatrix.h:144
Forward declarations and #define for cisstMultiTask.
size_type rows() const
Definition: vctDynamicConstMatrixBase.h:238
size_type cols() const
Definition: vctDynamicConstMatrixBase.h:243
mtsMatrix< int > mtsIntMat
Definition: mtsMatrix.h:147
mtsMatrix< float > mtsFloatMat
Definition: mtsMatrix.h:138
mtsMatrix< double > mtsDoubleMat
Definition: mtsMatrix.h:135
void SetSize(size_type rows, size_type cols, bool storageOrder)
Definition: vctDynamicMatrix.h:364
mtsMatrix(size_type rows, size_type cols)
Definition: mtsMatrix.h:56
void ToStream(std::ostream &outputStream) const
Definition: vctDynamicConstMatrixBase.h:1014
mtsMatrix(const nsize_type &size)
Definition: mtsMatrix.h:63
mtsMatrix(const MatrixType &otherMatrix)
Definition: mtsMatrix.h:86
Definition: mtsMatrix.h:40
mtsMatrix< long > mtsLongMat
Definition: mtsMatrix.h:141
~mtsMatrix()
Definition: mtsMatrix.h:93
ThisType & Assign(const vctDynamicConstMatrixBase< __matrixOwnerType, value_type > &other)
Definition: vctDynamicMatrixBase.h:509
VCT_NARRAY_TRAITS_TYPEDEFS(DIMENSION)
mtsMatrix< short > mtsShortMat
Definition: mtsMatrix.h:153
virtual std::string ToString(void) const
Definition: mtsMatrix.h:96
mtsMatrix< bool > mtsBoolMat
Definition: mtsMatrix.h:165
Rules of exporting.
virtual void ToStream(std::ostream &outputStream) const
Definition: mtsMatrix.h:103
void DeSerializeRaw(std::istream &inputStream)
Definition: mtsMatrix.h:125
const int CMN_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:331
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76
mtsMatrix< char > mtsCharMat
Definition: mtsMatrix.h:159