cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsVector.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: 2008-02-05
8 
9  (C) Copyright 2008 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 */
20 
21 
22 #ifndef _mtsVector_h
23 #define _mtsVector_h
24 
28 
29 // Always include last
31 
32 template <class _elementType>
34  public vctDynamicVector<_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 
43 
46 
48  inline mtsVector(void):
50  VectorType(0)
51  {}
52 
57  VectorType(size)
58  {
60  }
61 
65  inline ThisType & operator = (const VectorType & data) {
66  VectorType::SetSize(data.size());
67  VectorType::Assign(data);
68  return *this;
69  }
70 
72  inline mtsVector(const ThisType & otherVector):
73  mtsGenericObject(otherVector),
74  VectorType(otherVector)
75  {}
76 
78  inline mtsVector(const VectorType & otherVector):
80  VectorType(otherVector)
81  {}
82 
85  inline ~mtsVector() {}
86 
88  virtual std::string ToString(void) const {
89  std::stringstream outputStream;
90  this->ToStream(outputStream);
91  return outputStream.str();
92  }
93 
95  virtual void ToStream(std::ostream & outputStream) const {
96  mtsGenericObject::ToStream(outputStream);
97  outputStream << std::endl;
98  VectorType::ToStream(outputStream);
99  }
100 
102  inline virtual void ToStreamRaw(std::ostream & outputStream, const char delimiter = ' ',
103  bool headerOnly = false, const std::string & headerPrefix = "") const {
104  mtsGenericObject::ToStreamRaw(outputStream, delimiter, headerOnly, headerPrefix);
105  outputStream << delimiter;
106  VectorType::ToStreamRaw(outputStream, delimiter, headerOnly, headerPrefix);
107  }
108 
110  void SerializeRaw(std::ostream & outputStream) const
111  {
112  mtsGenericObject::SerializeRaw(outputStream);
113  VectorType::SerializeRaw(outputStream);
114  }
115 
117  void DeSerializeRaw(std::istream & inputStream)
118  {
120  VectorType::DeSerializeRaw(inputStream);
121  }
122 };
123 
124 
125 // define some basic vectors
128 
131 
134 
137 
140 
143 
146 
149 
152 
155 
158 
161 
162 #endif // _mtsVector_h
A vector object of dynamic size.
Definition: vctDynamicVector.h:127
mtsVector< unsigned char > mtsUCharVec
Definition: mtsVector.h:153
mtsVector(void)
Definition: mtsVector.h:48
mtsVector< bool > mtsBoolVec
Definition: mtsVector.h:156
mtsVector(size_type size)
Definition: mtsVector.h:55
virtual void SerializeRaw(std::ostream &outputStream) const
virtual void DeSerializeRaw(std::istream &inputStream)
ThisType & Assign(const vctDynamicConstVectorBase< __vectorOwnerType, value_type > &other)
Definition: vctDynamicVectorBase.h:242
virtual void ToStream(std::ostream &outputStream) const
size_t size_type
Definition: vctContainerTraits.h:35
mtsVector< long > mtsLongVec
Definition: mtsVector.h:132
Class register definitions and log macros.
Base class for data object in cisstMultiTask.
Definition: mtsGenericObject.h:56
mtsVector(const VectorType &otherVector)
Definition: mtsVector.h:78
mtsVector< unsigned int > mtsUIntVec
Definition: mtsVector.h:141
void SetSize(size_type size)
Definition: vctDynamicVector.h:315
void SerializeRaw(std::ostream &outputStream) const
Definition: mtsVector.h:110
void DeSerializeRaw(std::istream &inputStream)
Definition: vctDynamicVector.h:357
virtual void ToStream(std::ostream &outputStream) const
Definition: mtsVector.h:95
virtual std::string ToString(void) const
Definition: mtsVector.h:88
Declaration of vctDynamicVector.
Definition: mtsVector.h:33
size_type size(void) const
Definition: vctDynamicConstVectorBase.h:164
mtsVector(const ThisType &otherVector)
Definition: mtsVector.h:72
void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
Definition: vctDynamicConstVectorBase.h:973
void SerializeRaw(std::ostream &outputStream) const
Definition: vctDynamicConstVectorBase.h:996
Forward declarations and #define for cisstMultiTask.
mtsVector< unsigned short > mtsUShortVec
Definition: mtsVector.h:147
bool Zeros(void)
Definition: vctDynamicVectorBase.h:225
mtsVector< value_type > ThisType
Definition: mtsVector.h:42
mtsVector< unsigned long > mtsULongVec
Definition: mtsVector.h:135
VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType)
void DeSerializeRaw(std::istream &inputStream)
Definition: mtsVector.h:117
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
Definition: mtsVector.h:102
void ToStream(std::ostream &outputStream) const
Definition: vctDynamicConstVectorBase.h:950
mtsVector< char > mtsCharVec
Definition: mtsVector.h:150
Definition: vctDynamicConstVectorBase.h:77
mtsVector< float > mtsFloatVec
Definition: mtsVector.h:129
mtsVector< double > mtsDoubleVec
Definition: mtsVector.h:126
ThisType & operator=(const VectorType &data)
Definition: mtsVector.h:65
CMN_DECLARE_SERVICES_INSTANTIATION(mtsDoubleVec)
Rules of exporting.
mtsVector< int > mtsIntVec
Definition: mtsVector.h:138
const int CMN_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:331
mtsVector< short > mtsShortVec
Definition: mtsVector.h:144
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
vctDynamicVector< value_type > VectorType
Definition: mtsVector.h:45
mtsVector< std::string > mtsStdStringVec
Definition: mtsVector.h:159
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76
~mtsVector()
Definition: mtsVector.h:85