cisst-saw
Loading...
Searching...
No Matches
mtsGenericObject.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: 2009-04-13
7
8 (C) Copyright 2009-2020 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
23
24#ifndef _mtsGenericObject_h
25#define _mtsGenericObject_h
26
31
33
34#if CISST_HAS_JSON
36#endif // CISST_HAS_JSON
37
38// Always include last!
40
41#include <string>
42#include <iostream>
43
44
53
54 typedef cmnGenericObject BaseType;
55
59 CMN_DECLARE_MEMBER_AND_ACCESSORS(double, Timestamp);
60
66 CMN_DECLARE_MEMBER_AND_ACCESSORS(bool, AutomaticTimestamp);
67
71 CMN_DECLARE_MEMBER_AND_ACCESSORS(bool, Valid);
72
73public:
74
77 inline mtsGenericObject(void):
79 TimestampMember(0.0),
80 AutomaticTimestampMember(true),
81 ValidMember(false)
82 {}
83
85 inline mtsGenericObject(double timestamp, bool automaticTimestamp, bool valid):
86 TimestampMember(timestamp),
87 AutomaticTimestampMember(automaticTimestamp),
88 ValidMember(valid)
89 {}
90
92 inline mtsGenericObject(const mtsGenericObject & other):
93 cmnGenericObject(other),
94 TimestampMember(other.TimestampMember),
95 AutomaticTimestampMember(other.AutomaticTimestampMember),
96 ValidMember(other.ValidMember)
97 {}
98
100 inline virtual ~mtsGenericObject(void)
101 {}
102
106 TimestampMember = other.TimestampMember;
107 AutomaticTimestampMember = other.AutomaticTimestampMember;
108 ValidMember = other.ValidMember;
109 return *this;
110 }
111
117 bool SetTimestampIfAutomatic(double timestamp);
118
123 virtual void ToStream(std::ostream & outputStream) const;
124
126 virtual void ToStreamRaw(std::ostream & outputStream, const char delimiter = ' ',
127 bool headerOnly = false, const std::string & headerPrefix = "") const;
128
131 virtual bool FromStreamRaw(std::istream & inputStream, const char delimiter = ' ');
132
134 virtual void SerializeRaw(std::ostream & outputStream) const;
135
137 virtual void DeSerializeRaw(std::istream & inputStream);
138
139 /* documented in base class */
140 size_t ScalarNumber(void) const;
141 bool ScalarNumberIsFixed(void) const;
142
143 /* documented in base class */
144 double Scalar(const size_t index) const CISST_THROW(std::out_of_range);
145
146 /* documented in base class */
147 std::string ScalarDescription(const size_t index, const std::string & userDescription = "") const CISST_THROW(std::out_of_range);
148};
149
151
152template <> void CISST_EXPORT cmnData<mtsGenericObject>::SerializeBinary(const mtsGenericObject & data, std::ostream & outputStream) CISST_THROW(std::runtime_error);
153
154template <> void CISST_EXPORT cmnData<mtsGenericObject>::DeSerializeBinary(mtsGenericObject & data, std::istream & inputStream,
155 const cmnDataFormat & localFormat, const cmnDataFormat & remoteFormat) CISST_THROW(std::runtime_error);
156
157template <> void CISST_EXPORT cmnData<mtsGenericObject>::SerializeText(const mtsGenericObject & data, std::ostream & outputStream, const char delimiter) CISST_THROW(std::runtime_error);
158
159template <> std::string CISST_EXPORT cmnData<mtsGenericObject>::SerializeDescription(const mtsGenericObject & data, const char delimiter, const std::string & userDescription);
160
161template <> void CISST_EXPORT cmnData<mtsGenericObject>::DeSerializeText(mtsGenericObject & data, std::istream & inputStream, const char delimiter) CISST_THROW(std::runtime_error);
162
164
166
168
169template <> double CISST_EXPORT cmnData<mtsGenericObject>::Scalar(const mtsGenericObject & data, const size_t index) CISST_THROW(std::out_of_range);
170
171template <> std::string CISST_EXPORT cmnData<mtsGenericObject>::ScalarDescription(const mtsGenericObject & data, const size_t index, const std::string & userDescription) CISST_THROW(std::out_of_range);
172
173#if CISST_HAS_JSON
174template <> void CISST_EXPORT cmnDataJSON<mtsGenericObject>::SerializeText(const mtsGenericObject & data, Json::Value & jsonValue);
175template <> void CISST_EXPORT cmnDataJSON<mtsGenericObject>::DeSerializeText(mtsGenericObject & data, const Json::Value & jsonValue) CISST_THROW(std::runtime_error);
176#endif // CISST_HAS_JSON
177
178#endif // _mtsGenericObject_h
static size_t ScalarNumber(const_pointer data)
Definition cmnDataFunctionsArray.h:134
static std::string ScalarDescription(const_pointer data, const size_t index, const std::string &userDescription="v") CISST_THROW(std
Definition cmnDataFunctionsArray.h:147
static bool ScalarNumberIsFixed(const_pointer data)
Definition cmnDataFunctionsArray.h:129
static void DeSerializeBinary(pointer data, std::istream &inputStream, const cmnDataFormat &localFormat, const cmnDataFormat &remoteFormat) CISST_THROW(std
Definition cmnDataFunctionsArray.h:117
static double Scalar(const_pointer data, const size_t index) CISST_THROW(std
Definition cmnDataFunctionsArray.h:163
static void DeSerializeText(pointer data, std::istream &inputStream, const char delimiter) CISST_THROW(std
Definition cmnDataFunctionsArray.h:75
static std::string SerializeDescription(const_pointer data, const char delimiter, const std::string &userDescription="v")
Definition cmnDataFunctionsArray.h:88
static void SerializeBinary(const_pointer data, std::ostream &outputStream) CISST_THROW(std
Definition cmnDataFunctionsArray.h:108
static void SerializeText(const_pointer data, std::ostream &outputStream, const char delimiter) CISST_THROW(std
Definition cmnDataFunctionsArray.h:62
static void Copy(pointer data, const_pointer source)
Definition cmnDataFunctionsArray.h:38
Definition cmnDataFormat.h:30
Definition cmnDataFunctions.h:51
Base class for high level objects.
Definition cmnGenericObject.h:53
virtual std::string ScalarDescription(const size_t CMN_UNUSED(index), const std::string &CMN_UNUSED(userDescription)) const
Definition cmnGenericObject.h:154
virtual double Scalar(const size_t CMN_UNUSED(index)) const CISST_THROW(std
Definition cmnGenericObject.h:145
Base class for data object in cisstMultiTask.
Definition mtsGenericObject.h:52
virtual void SerializeRaw(std::ostream &outputStream) const
virtual ~mtsGenericObject(void)
Definition mtsGenericObject.h:100
virtual void ToStream(std::ostream &outputStream) const
size_t ScalarNumber(void) const
mtsGenericObject(double timestamp, bool automaticTimestamp, bool valid)
Definition mtsGenericObject.h:85
mtsGenericObject(void)
Definition mtsGenericObject.h:77
virtual bool FromStreamRaw(std::istream &inputStream, const char delimiter=' ')
bool SetTimestampIfAutomatic(double timestamp)
bool ScalarNumberIsFixed(void) const
mtsGenericObject(const mtsGenericObject &other)
Definition mtsGenericObject.h:92
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter=' ', bool headerOnly=false, const std::string &headerPrefix="") const
virtual void DeSerializeRaw(std::istream &inputStream)
ThisType & operator=(const vctDynamicConstNArrayBase< __nArrayOwnerType, __elementType, DIMENSION > &other)
Definition vctDynamicNArrayBase.h:401
Declaration of cmnDeSerializer and functions cmnDeSerializeRaw.
#define CISST_EXPORT
Definition cmnExportMacros.h:50
Defines cmnGenericObject.
#define CISST_THROW(exceptionParameter)
Somewhat portable compilation warning message. This works with very recent versions of gcc (4....
Definition cmnPortability.h:559
Declaration of cmnSerializer and functions cmnSerializeRaw.
Rules of exporting.
void CISST_EXPORT cmnData< mtsGenericObject >::DeSerializeText(mtsGenericObject &data, std::istream &inputStream, const char delimiter) CISST_THROW(std std::string CISST_EXPORT cmnData< mtsGenericObject >::HumanReadable(const mtsGenericObject &data)
Definition mtsGenericObject.h:163
STL namespace.
ThisType & operator=(const vctDynamicConstMatrixBase< __matrixOwnerType, __elementType > &otherMatrix)
Definition vctDynamicMatrix.h:255