MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00009 //---------------------------------------------------------------------------------- 00010 00011 00012 #ifndef __mlDistantObject_H 00013 #define __mlDistantObject_H 00014 00015 00016 // Local includes 00017 #include "MLBackgroundTasksSystem.h" 00018 00019 ML_START_NAMESPACE 00020 00024 00029 template <typename T> 00030 class DistantObject 00031 { 00032 public: 00034 typedef T Type; 00035 00037 explicit DistantObject(T* obj):_object(obj) {} 00038 00040 DistantObject():_object(NULL) {} 00041 00043 DistantObject& operator=(T* obj) { 00044 _object = obj; 00045 return *this; 00046 } 00047 00049 bool isNull() const { return _object==NULL; } 00050 00051 bool operator==(const DistantObject<T>& other) const { 00052 return _object == other._object; 00053 } 00054 00055 bool operator!=(const DistantObject<T>& other) const { 00056 return _object != other._object; 00057 } 00058 00059 bool operator!() const 00060 { 00061 return _object==NULL; 00062 } 00063 00064 inline friend bool operator==(const DistantObject<T>& lhs, 00065 const T* rhs) 00066 { 00067 return lhs._object == rhs; 00068 } 00069 inline friend bool operator==(const T* lhs, 00070 const DistantObject<T>& rhs) 00071 { 00072 return lhs == rhs._object; 00073 } 00074 inline friend bool operator!=(const DistantObject<T>& lhs, 00075 const T* rhs) 00076 { 00077 return lhs._object != rhs; 00078 } 00079 00080 inline friend bool operator!=(const T* lhs, 00081 const DistantObject<T>& rhs) 00082 { 00083 return lhs != rhs._object; 00084 } 00085 00086 private: 00087 friend class DistantObjectAccessor; 00088 T* _object; 00089 }; 00090 00093 class DistantObjectAccessor 00094 { 00095 public: 00097 template <typename Distant> 00098 static typename Distant::Type* get(const Distant& distant) { return distant._object; } 00099 }; 00100 00101 ML_END_NAMESPACE 00102 00103 #endif 00104 00105