cisst-saw
Loading...
Searching...
No Matches
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 Author(s): Anton Deguet
6 Created on: 2008-02-05
7
8 (C) Copyright 2008-2023 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17*/
18
19
20#ifndef _mtsVector_h
21#define _mtsVector_h
22
26
27// Always include last
29
30template <class _elementType>
32 public vctDynamicVector<_elementType> {
33 // declare services, requires dynamic creation
34 CMN_DECLARE_SERVICES_EXPORT(CMN_DYNAMIC_CREATION, CMN_LOG_ALLOW_DEFAULT);
35public:
36 /* defines useful types */
38
41
44
46 inline mtsVector(void):
48 VectorType(0)
49 {}
50
53 inline mtsVector(size_type size):
56 {
57 VectorType::Zeros();
58 }
59
61 inline ThisType & operator = (const ThisType & other) {
63 VectorType::operator = (other);
64 return *this;
65 }
66
70 inline ThisType & operator = (const VectorType & data) {
71 VectorType::SetSize(data.size());
72 VectorType::Assign(data);
73 return *this;
74 }
75
77 inline mtsVector(const ThisType & otherVector):
78 mtsGenericObject(otherVector),
79 VectorType(otherVector)
80 {}
81
83 inline mtsVector(const VectorType & otherVector):
85 VectorType(otherVector)
86 {}
87
90 inline ~mtsVector() {}
91
93 virtual std::string ToString(void) const {
94 std::stringstream outputStream;
95 this->ToStream(outputStream);
96 return outputStream.str();
97 }
98
100 void ToStream(std::ostream & outputStream) const override {
101 mtsGenericObject::ToStream(outputStream);
102 outputStream << std::endl;
103 VectorType::ToStream(outputStream);
104 }
105
107 void ToStreamRaw(std::ostream & outputStream, const char delimiter = ' ',
108 bool headerOnly = false, const std::string & headerPrefix = "") const override {
109 mtsGenericObject::ToStreamRaw(outputStream, delimiter, headerOnly, headerPrefix);
110 outputStream << delimiter;
111 VectorType::ToStreamRaw(outputStream, delimiter, headerOnly, headerPrefix);
112 }
113
115 void SerializeRaw(std::ostream & outputStream) const override
116 {
117 mtsGenericObject::SerializeRaw(outputStream);
118 VectorType::SerializeRaw(outputStream);
119 }
120
122 void DeSerializeRaw(std::istream & inputStream) override
123 {
125 VectorType::DeSerializeRaw(inputStream);
126 }
127};
128
129
130// define some basic vectors
133
136
139
142
145
148
151
154
157
160
163
166
167#endif // _mtsVector_h
virtual void SerializeRaw(std::ostream &outputStream) const
virtual void ToStream(std::ostream &outputStream) const
mtsGenericObject & operator=(const mtsGenericObject &other)
Definition mtsGenericObject.h:104
mtsGenericObject(void)
Definition mtsGenericObject.h:77
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter=' ', bool headerOnly=false, const std::string &headerPrefix="") const
virtual void DeSerializeRaw(std::istream &inputStream)
Definition mtsVector.h:32
ThisType & operator=(const ThisType &other)
Definition mtsVector.h:61
VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType)
virtual std::string ToString(void) const
Definition mtsVector.h:93
mtsVector(size_type size)
Definition mtsVector.h:53
mtsVector< value_type > ThisType
Definition mtsVector.h:40
~mtsVector()
Definition mtsVector.h:90
void DeSerializeRaw(std::istream &inputStream) override
Definition mtsVector.h:122
mtsVector(const VectorType &otherVector)
Definition mtsVector.h:83
vctDynamicVector< value_type > VectorType
Definition mtsVector.h:43
void ToStream(std::ostream &outputStream) const override
Definition mtsVector.h:100
mtsVector(void)
Definition mtsVector.h:46
void SerializeRaw(std::ostream &outputStream) const override
Definition mtsVector.h:115
void ToStreamRaw(std::ostream &outputStream, const char delimiter=' ', bool headerOnly=false, const std::string &headerPrefix="") const override
Definition mtsVector.h:107
mtsVector(const ThisType &otherVector)
Definition mtsVector.h:77
Definition vctForwardDeclarations.h:131
Class register definitions and log macros.
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition cmnClassRegisterMacros.h:199
const int CMN_DYNAMIC_CREATION
Definition cmnClassRegisterMacros.h:328
#define CMN_LOG_ALLOW_DEFAULT
Definition cmnLogLoD.h:76
Rules of exporting.
Forward declarations and #define for cisstMultiTask.
mtsVector< char > mtsCharVec
Definition mtsVector.h:155
mtsVector< bool > mtsBoolVec
Definition mtsVector.h:161
mtsVector< int > mtsIntVec
Definition mtsVector.h:143
mtsVector< long > mtsLongVec
Definition mtsVector.h:137
mtsVector< short > mtsShortVec
Definition mtsVector.h:149
mtsVector< unsigned short > mtsUShortVec
Definition mtsVector.h:152
mtsVector< std::string > mtsStdStringVec
Definition mtsVector.h:164
mtsVector< unsigned long > mtsULongVec
Definition mtsVector.h:140
mtsVector< unsigned int > mtsUIntVec
Definition mtsVector.h:146
mtsVector< float > mtsFloatVec
Definition mtsVector.h:134
mtsVector< double > mtsDoubleVec
Definition mtsVector.h:131
mtsVector< unsigned char > mtsUCharVec
Definition mtsVector.h:158
size_type size(void) const
Definition vctDynamicConstMatrixBase.h:228
Declaration of vctDynamicVector.