cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
6  Author(s): Anton Deguet
7  Created on: 2009-04-13
8 
9  (C) Copyright 2009-2013 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 
28 #ifndef _mtsGenericObject_h
29 #define _mtsGenericObject_h
30 
35 
37 
38 #if CISST_HAS_JSON
40 #endif // CISST_HAS_JSON
41 
42 // Always include last!
44 
45 #include <string>
46 #include <iostream>
47 
48 
57 
58  typedef cmnGenericObject BaseType;
59 
63  CMN_DECLARE_MEMBER_AND_ACCESSORS(double, Timestamp);
64 
70  CMN_DECLARE_MEMBER_AND_ACCESSORS(bool, AutomaticTimestamp);
71 
76 
77 public:
78 
81  inline mtsGenericObject(void):
83  TimestampMember(0.0),
84  AutomaticTimestampMember(true),
85  ValidMember(false)
86  {}
87 
89  inline mtsGenericObject(double timestamp, bool automaticTimestamp, bool valid):
90  TimestampMember(timestamp),
91  AutomaticTimestampMember(automaticTimestamp),
92  ValidMember(valid)
93  {}
94 
96  inline mtsGenericObject(const mtsGenericObject & other):
97  cmnGenericObject(other),
98  TimestampMember(other.TimestampMember),
99  AutomaticTimestampMember(other.AutomaticTimestampMember),
100  ValidMember(other.ValidMember)
101  {}
102 
104  inline virtual ~mtsGenericObject(void)
105  {}
106 
112  bool SetTimestampIfAutomatic(double timestamp);
113 
118  virtual void ToStream(std::ostream & outputStream) const;
119 
121  virtual void ToStreamRaw(std::ostream & outputStream, const char delimiter = ' ',
122  bool headerOnly = false, const std::string & headerPrefix = "") const;
123 
126  virtual bool FromStreamRaw(std::istream & inputStream, const char delimiter = ' ');
127 
129  virtual void SerializeRaw(std::ostream & outputStream) const;
130 
132  virtual void DeSerializeRaw(std::istream & inputStream);
133 
134  /* documented in base class */
135  size_t ScalarNumber(void) const;
136  bool ScalarNumberIsFixed(void) const;
137 
138  /* documented in base class */
139  double Scalar(const size_t index) const throw (std::out_of_range);
140 
141  /* documented in base class */
142  std::string ScalarDescription(const size_t index, const std::string & userDescription = "") const throw (std::out_of_range);
143 };
144 
145 template <> void CISST_EXPORT cmnData<mtsGenericObject>::Copy(mtsGenericObject & data, const mtsGenericObject & source);
146 
147 template <> void CISST_EXPORT cmnData<mtsGenericObject>::SerializeBinary(const mtsGenericObject & data, std::ostream & outputStream) throw (std::runtime_error);
148 
149 template <> void CISST_EXPORT cmnData<mtsGenericObject>::DeSerializeBinary(mtsGenericObject & data, std::istream & inputStream,
150  const cmnDataFormat & localFormat, const cmnDataFormat & remoteFormat) throw (std::runtime_error);
151 
152 template <> void CISST_EXPORT cmnData<mtsGenericObject>::SerializeText(const mtsGenericObject & data, std::ostream & outputStream, const char delimiter) throw (std::runtime_error);
153 
154 template <> std::string CISST_EXPORT cmnData<mtsGenericObject>::SerializeDescription(const mtsGenericObject & data, const char delimiter, const std::string & userDescription);
155 
156 template <> void CISST_EXPORT cmnData<mtsGenericObject>::DeSerializeText(mtsGenericObject & data, std::istream & inputStream, const char delimiter) throw (std::runtime_error);
157 
158 template <> std::string CISST_EXPORT cmnData<mtsGenericObject>::HumanReadable(const mtsGenericObject & data);
159 
160 template <> bool CISST_EXPORT cmnData<mtsGenericObject>::ScalarNumberIsFixed(const mtsGenericObject & data);
161 
162 template <> size_t CISST_EXPORT cmnData<mtsGenericObject>::ScalarNumber(const mtsGenericObject & data);
163 
164 template <> double CISST_EXPORT cmnData<mtsGenericObject>::Scalar(const mtsGenericObject & data, const size_t index) throw (std::out_of_range);
165 
166 template <> std::string CISST_EXPORT cmnData<mtsGenericObject>::ScalarDescription(const mtsGenericObject & data, const size_t index, const std::string & userDescription) throw (std::out_of_range);
167 
168 #if CISST_HAS_JSON
169 template <> void CISST_EXPORT cmnDataJSON<mtsGenericObject>::SerializeText(const mtsGenericObject & data, Json::Value & jsonValue);
170 template <> void CISST_EXPORT cmnDataJSON<mtsGenericObject>::DeSerializeText(mtsGenericObject & data, const Json::Value & jsonValue) throw (std::runtime_error);
171 #endif // CISST_HAS_JSON
172 
173 #endif // _mtsGenericObject_h
174 
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Definition: cmnDataFormat.h:32
Declaration of cmnSerializer and functions cmnSerializeRaw.
virtual bool ScalarNumberIsFixed(void) const
Definition: cmnGenericObject.h:136
Base class for high level objects.
Definition: cmnGenericObject.h:51
virtual double Scalar(const size_t CMN_UNUSED(index)) const
Definition: cmnGenericObject.h:143
Base class for data object in cisstMultiTask.
Definition: mtsGenericObject.h:56
virtual ~mtsGenericObject(void)
Definition: mtsGenericObject.h:104
virtual std::string ScalarDescription(const size_t CMN_UNUSED(index), const std::string &CMN_UNUSED(userDescription)) const
Definition: cmnGenericObject.h:152
mtsGenericObject(void)
Definition: mtsGenericObject.h:81
mtsGenericObject(const mtsGenericObject &other)
Definition: mtsGenericObject.h:96
virtual void SerializeRaw(std::ostream &outputStream) const
virtual void ToStream(std::ostream &outputStream) const
Defines cmnGenericObject.
virtual size_t ScalarNumber(void) const
Definition: cmnGenericObject.h:127
Definition: cmnDataFunctions.h:53
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
Rules of exporting.
#define CMN_DECLARE_MEMBER_AND_ACCESSORS(memberType, memberName)
Definition: cmnAccessorMacros.h:70
Declaration of cmnDeSerializer and functions cmnDeSerializeRaw.
mtsGenericObject(double timestamp, bool automaticTimestamp, bool valid)
Definition: mtsGenericObject.h:89
virtual void DeSerializeRaw(std::istream &inputStream)
virtual bool FromStreamRaw(std::istream &inputStream, const char delimiter= ' ')