cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsGenericObjectProxy.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): Ankur Kapoor, Anton Deguet, Peter Kazanzides
7  Created on: 2006-05-05
8 
9  (C) Copyright 2006-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 #ifndef _mtsGenericObjectProxy_h
21 #define _mtsGenericObjectProxy_h
22 
28 
32 
35 
36 // Always include last!
38 
39 typedef std::vector<std::string> stdStringVec;
40 typedef std::vector<double> stdDoubleVec;
41 typedef std::vector<char> stdCharVec;
42 
43 // Forward declarations
44 template <class _elementType> class mtsGenericObjectProxyBase;
45 template <class _elementType> class mtsGenericObjectProxy;
46 template <class _elementType> class mtsGenericObjectProxyRef;
47 template <typename _elementType> class mtsGenericTypes;
48 
49 template <typename _elementType, bool>
51 {
52  // _elementType does not have cmnData<_elementType> static methods, so use the "old" way
53 public:
54  static void CISST_DEPRECATED ToStream(std::ostream & outputStream, const _elementType & data) {
55  outputStream << data;
56  }
57  static void CISST_DEPRECATED ToStreamRaw(std::ostream & outputStream, const char CMN_UNUSED(delimiter), const _elementType & data) {
58  outputStream << data;
59  }
60  static bool CISST_DEPRECATED FromStreamRaw(std::istream & CMN_UNUSED(inputStream), const char CMN_UNUSED(delimiter), _elementType & CMN_UNUSED(data)) {
61  // Could try the "stream in" operator
62  return false;
63  }
64 };
65 
66 template <typename _elementType>
67 class cmnDataProxy<_elementType, true>
68 {
69  // _elementType has the cmnData<_elementType> static methods
70 public:
71  static void ToStream(std::ostream & outputStream, const _elementType & data) {
72  outputStream << cmnData<_elementType>::HumanReadable(data);
73  }
74  static void ToStreamRaw(std::ostream & outputStream, const char delimiter, const _elementType & data) {
75  cmnData<_elementType>::SerializeText(data, outputStream, delimiter);
76  }
77  static bool FromStreamRaw(std::istream & inputStream, const char delimiter, _elementType & data) {
78  try {
79  cmnDataDeSerializeTextDelimiter(inputStream, delimiter, "mtsGenericObjectProxy");
80  cmnData<_elementType>::DeSerializeText(data, inputStream, delimiter);
81  } catch (...) {
82  return false;
83  }
84  if (inputStream.fail()) {
85  inputStream.clear();
86  return false;
87  }
88  return true;
89  }
90 };
91 
92 #ifndef SWIG
93 // Class services specialization for proxy objects. We assume that we always want dynamic creation.
94 // The specialization is that if the dynamic_cast to the Proxy type fails, we also try to dynamic_cast
95 // to the ProxyRef type.
96 template <typename _elementType>
98 public:
101  typedef value_type * pointer;
102 
103  inline static cmnGenericObject * Create(const cmnGenericObject & other) {
104  const value_type * otherPointer = dynamic_cast<const value_type *>(&other);
105  if (otherPointer)
106  return new value_type(*otherPointer);
107  const value_reftype * otherRefPointer = dynamic_cast<const value_reftype *>(&other);
108  if (otherRefPointer)
109  return new value_type(otherRefPointer->GetData());
110  return 0;
111  }
112 
113  inline static bool Create(cmnGenericObject * existing, const cmnGenericObject & other) {
114  // If they already point to the same memory, just return
115  if (existing == &other)
116  return true;
117  const value_type * otherPointer = dynamic_cast<const value_type *>(&other);
118  if (otherPointer) {
119  new(existing) value_type(*otherPointer);
120  return true;
121  }
122  const value_reftype * otherRefPointer = dynamic_cast<const value_reftype *>(&other);
123  if (otherRefPointer) {
124  new(existing) value_type(otherRefPointer->GetData());
125  return true;
126  }
127  return false;
128  }
129 
130  inline static cmnGenericObject * CreateArray(size_t size, const cmnGenericObject & other) {
131  const value_type * otherPointer = dynamic_cast<const value_type *>(&other);
132  pointer data;
133  size_t index;
134  if (otherPointer) {
135  data = static_cast<pointer>(::operator new(sizeof(value_type) * size));
136  for (index = 0; index < size; index++) {
137  new(&(data[index])) value_type(*otherPointer); // placement new with copy constructor
138  }
139  return data;
140  }
141  const value_reftype * otherRefPointer = dynamic_cast<const value_reftype *>(&other);
142  if (otherRefPointer) {
143  data = static_cast<pointer>(::operator new(sizeof(value_type) * size));
144  for (index = 0; index < size; index++) {
145  new(&(data[index])) value_type(otherRefPointer->GetData()); // placement new with copy constructor
146  }
147  return data;
148  }
149  return 0;
150  }
151 
152  inline static bool CopyConstructorAvailable(void) { return true; }
153 };
154 
155 template<typename _class, typename _elementType>
157 {
158 public:
159  typedef _class value_type;
161 
163  inline static _class * Create(const cmnGenericObject & arg) {
164  const mtsGenericObject *mts = dynamic_cast<const mtsGenericObject *>(&arg);
165  if (mts) return new value_type(*mtsGenericTypes<_elementType>::CastArg(*mts));
166  CMN_LOG_INIT_WARNING << "cmnConditionalObjectFactoryOneArg::Create for proxy could not create object" << std::endl;
167  return 0;
168  }
169 
170  inline static bool OneArgConstructorAvailable(void) { return true; }
171 
172  inline static const cmnClassServicesBase *GetConstructorArgServices(void) {
173  return argTypeWrapped::ClassServices();
174  }
175 };
176 
182 template<typename _class, typename _elementType>
184 {
185 public:
186  typedef _class value_type;
188 
190  inline static _class * Create(const cmnGenericObject & arg) {
191  const mtsGenericObject *mts = dynamic_cast<const mtsGenericObject *>(&arg);
192  if (mts) {
193  const _elementType *name = mtsGenericTypes<_elementType>::CastArg(*mts);
194  if (name) {
195  _class *obj = new value_type;
196  obj->SetName(*name);
197  return obj;
198  }
199  CMN_LOG_INIT_WARNING << "cmnConditionalObjectFactoryOneArg::Create for string proxy could not get string" << std::endl;
200  return 0;
201  }
202  CMN_LOG_INIT_WARNING << "cmnConditionalObjectFactoryOneArg::Create for string proxy could not create object" << std::endl;
203  return 0;
204  }
205 
206  inline static bool OneArgConstructorAvailable(void) { return true; }
207 
208  inline static const cmnClassServicesBase *GetConstructorArgServices(void) {
209  return argTypeWrapped::ClassServices();
210  }
211 };
212 
213 template<typename _elementType>
215 {
218  typedef value_type * pointer;
220 public:
221  inline static bool DeleteArray(generic_pointer & data, size_t & size) {
222  pointer typedData = dynamic_cast<pointer>(data);
223  if (typedData) {
224  size_t index;
225  for (index = 0; index < size; index++) {
226  typedData[index].~value_type();
227  }
228  delete typedData;
229  data = 0;
230  size = 0;
231  return true;
232  }
233  return false;
234  }
235 
236  inline static bool Delete(cmnGenericObject * existing) {
237  value_type * existingPointer = dynamic_cast<value_type *>(existing);
238  if (existingPointer) {
239  existingPointer->~value_type();
240  return true;
241  }
242  const value_reftype * existingRefPointer = dynamic_cast<const value_reftype *>(existing);
243  if (existingRefPointer) {
244  existingRefPointer->~value_reftype();
245  return true;
246  }
247  return false;
248  }
249 };
250 #endif // !SWIG
251 
314 template <class _elementType>
316 {
317 public:
322 
323  typedef _elementType value_type;
324 
325  // CMN_DECLARE_SERVICES_EXPORT(CMN_DYNAMIC_CREATION, CMN_LOG_LOD_RUN_ERROR);
326  // Dirty Trick: this class uses the class services of the dereferenced (derived) type
327  //enum {HAS_DYNAMIC_CREATION = DeRefType::HAS_DYNAMIC_CREATION};
328  //enum {InitialLoD = DeRefType::InitialLoD};
329  enum {HAS_DYNAMIC_CREATION = true};
332  virtual const cmnClassServicesBase * Services(void) const
333  {
334  return DeRefType::ClassServices();
335  }
336 
340  {}
341 
343  inline mtsGenericObjectProxyBase(const ThisType & other) :
344  BaseType(other)
345  {}
346 
348 
350  virtual value_type & GetData(void) = 0;
351  virtual const value_type & GetData(void) const = 0;
352 
354  ThisType & operator=(const ThisType &data) {
355  this->Assign(data);
356  return *this;
357  }
358 
359  virtual void Assign(const ThisType &other) {
360  this->GetData() = other.GetData();
361  this->SetValid(other.Valid());
362  this->SetTimestamp(other.Timestamp());
363  }
364 
365 };
366 
367 
368 template <class _elementType>
369 class mtsGenericObjectProxy: public mtsGenericObjectProxyBase<_elementType>
370 {
371  CMN_DECLARE_SERVICES_EXPORT_ALWAYS(CMN_DYNAMIC_CREATION, CMN_LOG_ALLOW_DEFAULT);
372 
373 public:
380 
383  inline mtsGenericObjectProxy(void):
384  BaseType(),
385  Data()
386  {}
387 
389  inline mtsGenericObjectProxy(const ThisType & other) :
390  BaseType(other), Data(other.Data)
391  {}
392 
396  inline mtsGenericObjectProxy(const value_type & data):
397  Data(data)
398  {
399  this->SetValid(true);
400  }
401 
402  inline ~mtsGenericObjectProxy(void) {}
403 
405  value_type& GetData(void) { return Data; }
406  const value_type& GetData(void) const { return Data; }
407 
409  ThisType & operator=(const BaseType &data) {
410  this->Assign(data);
411  return *this;
412  }
413 
417  inline ThisType & operator=(value_type data) {
418  this->Data = data;
419  this->SetValid(true);
420  return *this;
421  }
422 
427  inline operator value_type & (void) {
428  return this->Data;
429  }
430  inline operator const value_type & (void) const {
431  return this->Data;
432  }
434 
436  inline void SerializeRaw(std::ostream & outputStream) const {
437  mtsGenericObject::SerializeRaw(outputStream);
438  cmnSerializeRaw(outputStream, this->Data);
439  }
440 
442  inline void DeSerializeRaw(std::istream & inputStream) {
444  cmnDeSerializeRaw(inputStream, this->Data);
445  }
446 
449  inline virtual void ToStream(std::ostream & outputStream) const {
450  BaseType::ToStream(outputStream);
451  outputStream << " Value: ";
453  }
454 
456  inline virtual void ToStreamRaw(std::ostream & outputStream, const char delimiter = ' ',
457  bool headerOnly = false, const std::string & headerPrefix = "") const {
458  if (headerOnly) {
459  BaseType::ToStreamRaw(outputStream, delimiter, headerOnly, headerPrefix);
460  outputStream << delimiter << headerPrefix << "-data";
461  } else {
462  BaseType::ToStreamRaw(outputStream, delimiter);
463  outputStream << delimiter;
465  }
466  }
467 
469  inline virtual bool FromStreamRaw(std::istream & inputStream, const char delimiter = ' ') {
470  BaseType::FromStreamRaw(inputStream, delimiter);
472  }
473 };
474 
475 
476 template <class _elementType>
477 class mtsGenericObjectProxyRef: public mtsGenericObjectProxyBase<_elementType>
478 {
480  inline mtsGenericObjectProxyRef(void)
481  {}
482 
483 public:
489 
491 
493  inline mtsGenericObjectProxyRef(const ThisType & other) :
494  BaseType(other), rData(other.rData)
495  {}
496 
500  {
501  this->SetValid(true);
502  }
503  // The const_cast can be eliminated by defining an mtsGenericObjectProxyConstRef,
504  // or by specializing mtsGenericObjectProxyRef for const objects,
505  // e.g., template <typename _elementType>
506  // class mtsGenericObjectProxyRef<const _elementType>
507  inline mtsGenericObjectProxyRef(const value_type & data):
508  rData(*const_cast<value_type*>(&data))
509  {
510  this->SetValid(true);
511  }
512 
514 
516  value_type& GetData(void) { return rData; }
517  const value_type& GetData(void) const { return rData; }
518 
520  ThisType & operator=(const BaseType &data) {
521  this->Assign(data);
522  return *this;
523  }
524 
528  inline ThisType & operator=(value_type data) {
529  this->rData = data;
530  this->SetValid(true);
531  return *this;
532  }
533 
538  inline operator value_type & (void) {
539  return this->rData;
540  }
541  inline operator const value_type & (void) const {
542  return this->rData;
543  }
545 
547  inline void SerializeRaw(std::ostream & outputStream) const {
548  mtsGenericObject::SerializeRaw(outputStream);
549  cmnSerializeRaw(outputStream, this->rData);
550  }
551 
553  inline void DeSerializeRaw(std::istream & inputStream) {
555  cmnDeSerializeRaw(inputStream, this->rData);
556  }
557 
560  inline virtual void ToStream(std::ostream & outputStream) const {
561  BaseType::ToStream(outputStream);
562  outputStream << " Value(ref): ";
564  }
565 
567  inline virtual void ToStreamRaw(std::ostream & outputStream, const char delimiter = ' ',
568  bool headerOnly = false, const std::string & headerPrefix = "") const {
569  if (headerOnly) {
570  BaseType::ToStreamRaw(outputStream, delimiter, headerOnly, headerPrefix);
571  outputStream << delimiter << headerPrefix << "-data(ref)";
572  } else {
573  BaseType::ToStreamRaw(outputStream, delimiter);
574  outputStream << delimiter;
576  }
577  }
578 
580  inline virtual bool FromStreamRaw(std::istream & inputStream, const char delimiter = ' ') {
581  BaseType::FromStreamRaw(inputStream, delimiter);
583  }
584 };
585 
586 
587 #ifndef SWIG
588 
590 template<typename T, bool>
592 {
593  // T is not derived from mtsGenericObject, so wrap it
594 public:
598  static FinalRefType *ConditionalWrap(T &obj) { return new FinalRefType(obj); }
599  static bool IsEqual(const T &obj1, const mtsGenericObject &obj2) {
600  const FinalRefType *p2 = dynamic_cast<const FinalRefType *>(&obj2);
601  return (p2?(&obj1 == &p2->rData):false); }
602  static void ConditionalFree(const FinalRefType *obj) { delete obj;}
603  static mtsGenericObject* ConditionalCreate(const T &arg, const std::string &)
604  {
605  return new FinalType(arg);
606  }
607 
608  static T* CastArg(mtsGenericObject &arg) {
609  FinalBaseType *tmp = dynamic_cast<FinalBaseType *>(&arg);
610  if (!tmp) {
611  CMN_LOG_INIT_ERROR << "CastArg could not cast from " << typeid(arg).name()
612  << " to " << typeid(FinalBaseType).name() << std::endl;
613  return 0;
614  }
615  return &(tmp->GetData());
616  }
617  static const T* CastArg(const mtsGenericObject &arg) {
618  const FinalBaseType *tmp = dynamic_cast<const FinalBaseType *>(&arg);
619  if (!tmp) {
620  CMN_LOG_INIT_ERROR << "CastArg could not cast from const " << typeid(arg).name()
621  << " to const " << typeid(FinalBaseType).name() << std::endl;
622  return 0;
623  }
624  return &(tmp->GetData());
625  }
626 };
627 
628 template<typename T>
629 class mtsGenericTypesImpl<T, true>
630 {
631  // T is derived from mtsGenericObject
632 public:
633  typedef T FinalBaseType;
634  typedef T FinalType;
635  typedef T FinalRefType;
636  static FinalRefType *ConditionalWrap(T &obj) { return &obj; }
637  static bool IsEqual(const T &obj1, const mtsGenericObject &obj2) { return &obj1 == &obj2; }
638  static void ConditionalFree(const FinalRefType *) {}
639  static mtsGenericObject* ConditionalCreate(const T &arg, const std::string &name) {
640  if (typeid(T) != *arg.Services()->TypeInfoPointer()) {
641  CMN_LOG_INIT_ERROR << "ConditionalCreate: argument prototype is wrong type for command \"" << name << "\" (expected \""
642  << typeid(T).name() << "\", got \""
643  << arg.Services()->TypeInfoPointer()->name() << "\")" << std::endl;
644  }
645  return new FinalType(arg);
646  }
647 
648  static T* CastArg(mtsGenericObject &arg) {
649  T* temp = dynamic_cast<T * >(&arg);
650  if (!temp)
651  CMN_LOG_INIT_ERROR << "CastArg for mts, could not cast from " << arg.Services()->GetName()
652  << " to " << T::ClassServices()->GetName() << std::endl;
653  return temp;
654  }
655 
656  static const T* CastArg(const mtsGenericObject &arg) {
657  const T* temp = dynamic_cast<const T * >(&arg);
658  if (!temp)
659  CMN_LOG_INIT_ERROR << "CastArg for mts, could not cast from const " << arg.Services()->GetName()
660  <<" to " << T::ClassServices()->GetName() << std::endl;
661  return temp;
662  }
663 };
664 
665 template<typename T>
666 class mtsGenericTypes
667 {
669 public:
673  static FinalRefType *ConditionalWrap(T &obj) { return impl::ConditionalWrap(obj); }
674  static bool IsEqual(const T &obj1, const mtsGenericObject &obj2) { return impl::IsEqual(obj1, obj2); }
675  static void ConditionalFree(const FinalRefType *obj) { impl::ConditionalFree(obj); }
676  static mtsGenericObject* ConditionalCreate(const T &arg, const std::string &name) {
677  mtsGenericObject *tmp = impl::ConditionalCreate(arg, name);
678  if (!tmp)
679  CMN_LOG_INIT_ERROR << "ConditionalCreate returning NULL for " << name << " (maybe you should use CMN_DECLARE_SERVICES with CMN_DYNAMIC_CREATION)" << std::endl;
680  return tmp;
681  }
682 
683  static T* CastArg(mtsGenericObject &arg) {
684  return impl::CastArg(arg);
685  }
686  static const T* CastArg(const mtsGenericObject &arg) {
687  return impl::CastArg(arg);
688  }
689 };
690 
691 template<typename T, bool>
693 {
694  // T is not a proxy type
695 public:
696  typedef T RefType;
697  typedef T BaseType;
698 };
699 
700 template<typename T>
702 {
703  // T is a proxy type
704 public:
705  typedef typename T::RefType RefType;
706  typedef typename T::BaseType BaseType;
707 };
708 
709 template<typename T>
711 {
713 public:
716 };
717 
718 // Some macros for creating class services
719 
720 #define CMN_IMPLEMENT_SERVICES_DERIVED_ONEARG(className, parentName, argType) \
721  CMN_IS_DERIVED_FROM_ASSERT(className, parentName) \
722  CMN_IMPLEMENT_SERVICES_INTERNAL(className, parentName::ClassServices(), mtsGenericTypes<argType>::FinalType)
723 
724 #define CMN_IMPLEMENT_SERVICES_DERIVED_ONEARG_TEMPLATED(className, parentName, argType) \
725  CMN_IS_DERIVED_FROM_ASSERT(className, parentName) \
726  CMN_IMPLEMENT_SERVICES_TEMPLATED_INTERNAL(className, parentName::ClassServices(), mtsGenericTypes<argType>::FinalType)
727 #endif
728 
729 /* Some basic types defined here for now, could move somewhere else. */
732 
735 
738 
741 
744 
747 
750 
753 
756 
759 
762 
765 
768 
769 // Add Proxy to name to distinguish this from mtsVector<std::string>
771 CMN_DECLARE_SERVICES_INSTANTIATION(mtsStdStringVecProxy);
772 
774 CMN_DECLARE_SERVICES_INSTANTIATION(mtsStdDoubleVecProxy);
775 
777 CMN_DECLARE_SERVICES_INSTANTIATION(mtsStdCharVecProxy);
778 
779 // Now, define proxies for cisstVector classes (see also
780 // mtsFixedSizeVectorTypes.h, which uses multiple inheritance,
781 // rather than proxies).
802 
803 // Define proxy for std::vector<vct3>
804 typedef std::vector<vct3> stdVct3Vec;
806 CMN_DECLARE_SERVICES_INSTANTIATION(mtsStdVct3VecProxy);
807 
826 
845 
864 
883 
902 
921 
940 
959 
978 
997 
998 // Define a few fixed size matrices
999 #include <cisstVector/vctFixedSizeMatrixTypes.h>
1007 
1008 // Transformation types (see also mtsTransformationTypes.h,
1009 // which uses multiple inheritance).
1010 #include <cisstVector/vctTransformationTypes.h>
1018 
1019 // Dynamic vectors (see also mtsVector.h, which uses
1020 // multiple inheritance)
1021 #include <cisstVector/vctDynamicVectorTypes.h>
1024 CMN_DECLARE_SERVICES_INSTANTIATION(mtsVctDoubleVec)
1026 CMN_DECLARE_SERVICES_INSTANTIATION(mtsVctFloatVec)
1034 CMN_DECLARE_SERVICES_INSTANTIATION(mtsVctUCharVec)
1038 CMN_DECLARE_SERVICES_INSTANTIATION(mtsVctShortVec)
1040 CMN_DECLARE_SERVICES_INSTANTIATION(mtsVctUShortVec)
1044 CMN_DECLARE_SERVICES_INSTANTIATION(mtsVctULongVec)
1045 
1046 // Dynamic matrices (see also mtsMatrix.h, which uses
1047 // multiple inheritance)
1048 #include <cisstVector/vctDynamicMatrixTypes.h>
1051 CMN_DECLARE_SERVICES_INSTANTIATION(mtsVctDoubleMat)
1053 CMN_DECLARE_SERVICES_INSTANTIATION(mtsVctFloatMat)
1056 
1057 #endif
static const T * CastArg(const mtsGenericObject &arg)
Definition: mtsGenericObjectProxy.h:656
static void ConditionalFree(const FinalRefType *obj)
Definition: mtsGenericObjectProxy.h:675
Definition: mtsGenericObjectProxy.h:692
static T * CastArg(mtsGenericObject &arg)
Definition: mtsGenericObjectProxy.h:648
Definition: mtsGenericObjectProxy.h:44
mtsGenericObjectProxyBase< _elementType >::RefType RefType
Definition: mtsGenericObjectProxy.h:378
value_type Data
Definition: mtsGenericObjectProxy.h:379
static const cmnClassServicesBase * GetConstructorArgServices(void)
Definition: mtsGenericObjectProxy.h:208
static bool Create(cmnGenericObject *existing, const cmnGenericObject &other)
Definition: mtsGenericObjectProxy.h:113
#define CISST_DEPRECATED
Definition: cmnPortability.h:310
static bool FromStreamRaw(std::istream &inputStream, const char delimiter, _elementType &data)
Definition: mtsGenericObjectProxy.h:77
void SerializeRaw(std::ostream &outputStream) const
Definition: mtsGenericObjectProxy.h:436
static bool IsEqual(const T &obj1, const mtsGenericObject &obj2)
Definition: mtsGenericObjectProxy.h:637
mtsGenericObjectProxyRef< _elementType > value_reftype
Definition: mtsGenericObjectProxy.h:100
mtsGenericObjectProxyBase< _elementType >::value_type value_type
Definition: mtsGenericObjectProxy.h:376
mtsGenericObjectProxyRef< T > FinalRefType
Definition: mtsGenericObjectProxy.h:597
mtsGenericObjectProxyBase< _elementType >::DeRefType DeRefType
Definition: mtsGenericObjectProxy.h:487
static bool IsEqual(const T &obj1, const mtsGenericObject &obj2)
Definition: mtsGenericObjectProxy.h:674
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
Definition: mtsGenericObjectProxy.h:567
Portability across compilers and operating systems tools.
mtsGenericObjectProxy< double > mtsDouble
Definition: mtsGenericObjectProxy.h:730
#define CMN_UNUSED(argument)
Definition: cmnPortability.h:479
virtual value_type & GetData(void)=0
mtsGenericObjectProxy(const value_type &data)
Definition: mtsGenericObjectProxy.h:396
Declaration of cmnSerializer and functions cmnSerializeRaw.
~mtsGenericObjectProxyRef(void)
Definition: mtsGenericObjectProxy.h:513
mtsGenericObjectProxy< float > mtsFloat
Definition: mtsGenericObjectProxy.h:733
mtsGenericObjectProxyBase(void)
Definition: mtsGenericObjectProxy.h:339
static const cmnClassServicesBase * GetConstructorArgServices(void)
Definition: mtsGenericObjectProxy.h:172
mtsGenericObjectProxyBase< _elementType >::value_type value_type
Definition: mtsGenericObjectProxy.h:486
virtual void SerializeRaw(std::ostream &outputStream) const
static FinalRefType * ConditionalWrap(T &obj)
Definition: mtsGenericObjectProxy.h:636
virtual void DeSerializeRaw(std::istream &inputStream)
mtsGenericObjectProxy< _elementType > ThisType
Definition: mtsGenericObjectProxy.h:374
mtsGenericObjectProxy< vctDoubleVec > mtsVctDoubleVec
Definition: mtsGenericObjectProxy.h:1023
mtsGenericObjectProxy(void)
Definition: mtsGenericObjectProxy.h:383
mtsGenericObjectProxy< short > mtsShort
Definition: mtsGenericObjectProxy.h:751
virtual void ToStream(std::ostream &outputStream) const
mtsGenericTypesImpl< T, cmnIsDerivedFrom< T, mtsGenericObject >::IS_DERIVED >::FinalBaseType FinalBaseType
Definition: mtsGenericObjectProxy.h:670
virtual void Assign(const ThisType &other)
Definition: mtsGenericObjectProxy.h:359
static T * CastArg(mtsGenericObject &arg)
Definition: mtsGenericObjectProxy.h:608
const std::string & GetName(void) const
const value_type & GetData(void) const
Definition: mtsGenericObjectProxy.h:517
std::vector< std::string > stdStringVec
Definition: mtsGenericObjectProxy.h:39
mtsGenericObjectProxyBase< T > FinalBaseType
Definition: mtsGenericObjectProxy.h:595
mtsGenericObjectProxy< char > mtsChar
Definition: mtsGenericObjectProxy.h:757
Typedef for fixed size vectors.
mtsGenericObjectProxy< unsigned int > mtsUInt
Definition: mtsGenericObjectProxy.h:748
Base class for high level objects.
Definition: cmnGenericObject.h:51
static bool CopyConstructorAvailable(void)
Definition: mtsGenericObjectProxy.h:152
Class register definitions and log macros.
#define CMN_LOG_INIT_ERROR
Definition: cmnLogger.h:162
mtsGenericObjectProxyBase(const ThisType &other)
Definition: mtsGenericObjectProxy.h:343
Base class for data object in cisstMultiTask.
Definition: mtsGenericObject.h:56
static void ToStreamRaw(std::ostream &outputStream, const char delimiter, const _elementType &data)
Definition: mtsGenericObjectProxy.h:74
const int CMN_DYNAMIC_CREATION_ONEARG
Definition: cmnClassRegisterMacros.h:333
virtual bool FromStreamRaw(std::istream &inputStream, const char delimiter= ' ')
virtual const cmnClassServicesBase * Services(void) const =0
static mtsGenericObject * ConditionalCreate(const T &arg, const std::string &name)
Definition: mtsGenericObjectProxy.h:639
mtsGenericObjectProxyBase< _elementType > BaseType
Definition: mtsGenericObjectProxy.h:375
const value_type & GetData(void) const
Definition: mtsGenericObjectProxy.h:406
static FinalRefType * ConditionalWrap(T &obj)
Definition: mtsGenericObjectProxy.h:673
mtsGenericObjectProxy< stdDoubleVec > mtsStdDoubleVecProxy
Definition: mtsGenericObjectProxy.h:773
static void ConditionalFree(const FinalRefType *obj)
Definition: mtsGenericObjectProxy.h:602
~mtsGenericObjectProxy(void)
Definition: mtsGenericObjectProxy.h:402
Definition: mtsGenericObjectProxy.h:710
static const T * CastArg(const mtsGenericObject &arg)
Definition: mtsGenericObjectProxy.h:617
static _class * Create(const cmnGenericObject &arg)
Definition: mtsGenericObjectProxy.h:190
static cmnGenericObject * Create(const cmnGenericObject &other)
Definition: mtsGenericObjectProxy.h:103
mtsGenericObject BaseType
Definition: mtsGenericObjectProxy.h:319
CMN_DECLARE_SERVICES_INSTANTIATION(mtsDouble)
T::RefType RefType
Definition: mtsGenericObjectProxy.h:705
Definition: mtsGenericObjectProxy.h:47
mtsGenericObjectProxy< _elementType > value_type
Definition: mtsGenericObjectProxy.h:99
static void ToStream(std::ostream &outputStream, const _elementType &data)
Definition: mtsGenericObjectProxy.h:71
ThisType & operator=(const BaseType &data)
Definition: mtsGenericObjectProxy.h:409
static void SerializeText(const DataType &data, std::ostream &outputStream, const char delimiter= ',')
mtsGenericObjectProxy< _elementType > argTypeWrapped
Definition: mtsGenericObjectProxy.h:160
mtsGenericTypesUnwrapImpl< T, cmnIsDerivedFromTemplated< T, mtsGenericObjectProxyBase >::IS_DERIVED >::BaseType BaseType
Definition: mtsGenericObjectProxy.h:715
mtsGenericObjectProxy< long > mtsLong
Definition: mtsGenericObjectProxy.h:736
static cmnGenericObject * CreateArray(size_t size, const cmnGenericObject &other)
Definition: mtsGenericObjectProxy.h:130
Definition: cmnClassServices.h:252
Definition: mtsGenericObjectProxy.h:330
std::vector< double > stdDoubleVec
Definition: mtsGenericObjectProxy.h:40
static cmnClassServicesBase * ClassServices(void)
Definition: mtsGenericObjectProxy.h:331
Definition: cmnClassServices.h:200
mtsGenericTypesImpl< T, cmnIsDerivedFrom< T, mtsGenericObject >::IS_DERIVED >::FinalType FinalType
Definition: mtsGenericObjectProxy.h:671
ThisType & operator=(value_type data)
Definition: mtsGenericObjectProxy.h:417
static bool IsEqual(const T &obj1, const mtsGenericObject &obj2)
Definition: mtsGenericObjectProxy.h:599
Definition: mtsGenericObjectProxy.h:591
virtual const cmnClassServicesBase * Services(void) const
Definition: mtsGenericObjectProxy.h:332
mtsGenericObjectProxy< long long > mtsLongLong
Definition: mtsGenericObjectProxy.h:739
static _class * Create(const cmnGenericObject &arg)
Definition: mtsGenericObjectProxy.h:163
mtsGenericObjectProxyRef(const value_type &data)
Definition: mtsGenericObjectProxy.h:507
Forward declarations and #define for cisstMultiTask.
Declaration of the class cmnTypeTraits.
void cmnDeSerializeRaw(std::istream &inputStream, _elementType &data)
Definition: cmnDeSerializer.h:82
mtsGenericObjectProxy< T > FinalType
Definition: mtsGenericObjectProxy.h:596
mtsGenericObjectProxyBase< _elementType >::RefType RefType
Definition: mtsGenericObjectProxy.h:488
static bool CISST_DEPRECATED FromStreamRaw(std::istream &CMN_UNUSED(inputStream), const char CMN_UNUSED(delimiter), _elementType &CMN_UNUSED(data))
Definition: mtsGenericObjectProxy.h:60
mtsGenericObjectProxy< _elementType > DeRefType
Definition: mtsGenericObjectProxy.h:320
static void ConditionalFree(const FinalRefType *)
Definition: mtsGenericObjectProxy.h:638
Definition: mtsGenericObjectProxy.h:329
void cmnSerializeRaw(std::ostream &outputStream, const _elementType &data)
Definition: cmnSerializer.h:78
Definition: mtsGenericObjectProxy.h:50
mtsGenericObjectProxyBase< _elementType >::DeRefType DeRefType
Definition: mtsGenericObjectProxy.h:377
mtsGenericTypesImpl< T, cmnIsDerivedFrom< T, mtsGenericObject >::IS_DERIVED >::FinalRefType FinalRefType
Definition: mtsGenericObjectProxy.h:672
T FinalRefType
Definition: mtsGenericObjectProxy.h:635
Defines mtsGenericObject.
static FinalRefType * ConditionalWrap(T &obj)
Definition: mtsGenericObjectProxy.h:598
Definition: mtsGenericObjectProxy.h:46
mtsGenericTypesUnwrapImpl< T, cmnIsDerivedFromTemplated< T, mtsGenericObjectProxyBase >::IS_DERIVED >::RefType RefType
Definition: mtsGenericObjectProxy.h:714
value_type & rData
Definition: mtsGenericObjectProxy.h:490
static T * CastArg(mtsGenericObject &arg)
Definition: mtsGenericObjectProxy.h:683
virtual void ToStream(std::ostream &outputStream) const
Definition: mtsGenericObjectProxy.h:560
value_type & GetData(void)
Definition: mtsGenericObjectProxy.h:516
static void CISST_DEPRECATED ToStream(std::ostream &outputStream, const _elementType &data)
Definition: mtsGenericObjectProxy.h:54
ThisType & operator=(const BaseType &data)
Definition: mtsGenericObjectProxy.h:520
static const T * CastArg(const mtsGenericObject &arg)
Definition: mtsGenericObjectProxy.h:686
void DeSerializeRaw(std::istream &inputStream)
Definition: mtsGenericObjectProxy.h:442
mtsGenericObjectProxy< int > mtsInt
Definition: mtsGenericObjectProxy.h:745
T BaseType
Definition: mtsGenericObjectProxy.h:697
mtsGenericObjectProxyRef(const ThisType &other)
Definition: mtsGenericObjectProxy.h:493
mtsGenericObjectProxyBase< _elementType > ThisType
Definition: mtsGenericObjectProxy.h:318
static bool Delete(cmnGenericObject *existing)
Definition: mtsGenericObjectProxy.h:236
mtsGenericObjectProxy< unsigned long > mtsULong
Definition: mtsGenericObjectProxy.h:742
mtsGenericObjectProxyRef< _elementType > ThisType
Definition: mtsGenericObjectProxy.h:484
T FinalBaseType
Definition: mtsGenericObjectProxy.h:633
Base class for class services.
Definition: cmnClassServicesBase.h:45
mtsGenericObjectProxy(const ThisType &other)
Definition: mtsGenericObjectProxy.h:389
ThisType & operator=(const ThisType &data)
Definition: mtsGenericObjectProxy.h:354
mtsGenericObjectProxy< stdCharVec > mtsStdCharVecProxy
Definition: mtsGenericObjectProxy.h:776
mtsGenericObjectProxy< stdStringVec > mtsStdStringVecProxy
Definition: mtsGenericObjectProxy.h:770
mtsGenericObjectProxy< _elementType > argTypeWrapped
Definition: mtsGenericObjectProxy.h:187
T::BaseType BaseType
Definition: mtsGenericObjectProxy.h:706
static void DeSerializeText(DataType &data, std::istream &inputStream, const char delimiter= ',')
mtsGenericObjectProxy< std::string > mtsStdString
Definition: mtsGenericObjectProxy.h:766
T FinalType
Definition: mtsGenericObjectProxy.h:634
value_type * pointer
Definition: mtsGenericObjectProxy.h:101
T RefType
Definition: mtsGenericObjectProxy.h:696
mtsGenericObjectProxy< bool > mtsBool
Definition: mtsGenericObjectProxy.h:763
Rules of exporting.
std::vector< char > stdCharVec
Definition: mtsGenericObjectProxy.h:41
static bool DeleteArray(generic_pointer &data, size_t &size)
Definition: mtsGenericObjectProxy.h:221
mtsGenericObjectProxy< unsigned char > mtsUChar
Definition: mtsGenericObjectProxy.h:760
Declaration of cmnDeSerializer and functions cmnDeSerializeRaw.
virtual bool FromStreamRaw(std::istream &inputStream, const char delimiter= ' ')
Definition: mtsGenericObjectProxy.h:469
std::vector< vct3 > stdVct3Vec
Definition: mtsGenericObjectProxy.h:804
virtual void ToStream(std::ostream &outputStream) const
Definition: mtsGenericObjectProxy.h:449
#define CMN_LOG_INIT_WARNING
Definition: cmnLogger.h:163
Definition: mtsGenericObjectProxy.h:45
~mtsGenericObjectProxyBase(void)
Definition: mtsGenericObjectProxy.h:347
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
Definition: mtsGenericObjectProxy.h:456
const int CMN_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:331
virtual bool FromStreamRaw(std::istream &inputStream, const char delimiter= ' ')
Definition: mtsGenericObjectProxy.h:580
_elementType value_type
Definition: mtsGenericObjectProxy.h:323
virtual void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
Definition: cmnClassServices.h:103
static void CISST_DEPRECATED ToStreamRaw(std::ostream &outputStream, const char CMN_UNUSED(delimiter), const _elementType &data)
Definition: mtsGenericObjectProxy.h:57
mtsGenericObjectProxy< vct1 > mtsVct1
Definition: mtsGenericObjectProxy.h:784
mtsGenericObjectProxyRef(value_type &data)
Definition: mtsGenericObjectProxy.h:499
static mtsGenericObject * ConditionalCreate(const T &arg, const std::string &)
Definition: mtsGenericObjectProxy.h:603
mtsGenericObjectProxyBase< _elementType > BaseType
Definition: mtsGenericObjectProxy.h:485
mtsGenericObjectProxy< vctMatRot3 > mtsVctMatRot3
Definition: mtsGenericObjectProxy.h:1012
const int CMN_DYNAMIC_CREATION_SETNAME
Definition: cmnClassRegisterMacros.h:332
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76
ThisType & operator=(value_type data)
Definition: mtsGenericObjectProxy.h:528
mtsGenericObjectProxy< vctDoubleMat > mtsVctDoubleMat
Definition: mtsGenericObjectProxy.h:1050
void CISST_EXPORT cmnDataDeSerializeTextDelimiter(std::istream &inputStream, const char delimiter, const char *className)
void DeSerializeRaw(std::istream &inputStream)
Definition: mtsGenericObjectProxy.h:553
static mtsGenericObject * ConditionalCreate(const T &arg, const std::string &name)
Definition: mtsGenericObjectProxy.h:676
mtsGenericObjectProxyRef< _elementType > RefType
Definition: mtsGenericObjectProxy.h:321
mtsGenericObjectProxy< unsigned short > mtsUShort
Definition: mtsGenericObjectProxy.h:754
mtsGenericObjectProxy< vct2x2 > mtsVct2x2
Definition: mtsGenericObjectProxy.h:1001
value_type & GetData(void)
Definition: mtsGenericObjectProxy.h:405
void SerializeRaw(std::ostream &outputStream) const
Definition: mtsGenericObjectProxy.h:547