Changeset 369 for XIOS/trunk/src/type/type.hpp
- Timestamp:
- 10/16/12 13:04:44 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/type/type.hpp
r352 r369 12 12 { 13 13 14 template <typename T> class CType_ref ; 15 14 16 template <typename T> 15 class CType : public CBaseType17 class CType : public virtual CBaseType 16 18 { 17 19 public: … … 19 21 CType(void) ; 20 22 CType(const T& val) ; 21 CType(T& val) ;22 23 CType(const CType& type) ; 24 CType(const CType_ref<T>& type) ; 25 virtual ~CType() { _reset() ; } 23 26 24 ~CType() {} ; 27 T& get(void) ; 28 const T& get(void) const; 25 29 26 void fromString(const string& str) ; 27 string toString(void) const; 30 void set(const T& val) ; 31 void set(const CType& val) ; 32 void set(const CType_ref<T>& val) ; 33 CType& operator = (const T& val) ; 34 CType& operator = (const CType& val) ; 35 CType& operator = (const CType_ref<T>& val) ; 36 operator T&() ; 28 37 29 bool fromBuffer(CBufferIn& buffer) ; 30 bool toBuffer(CBufferOut& buffer) const; 31 void destroy(void) ; 38 virtual CType* clone(void) const { return _clone(); } 39 virtual void fromString(const string& str) { _fromString(str); } 40 virtual string toString(void) const { return _toString(); } 41 virtual bool fromBuffer(CBufferIn& buffer) { return _fromBuffer(buffer) ; } 42 virtual bool toBuffer(CBufferOut& buffer) const { return _toBuffer(buffer); } 43 virtual void reset(void) { _reset(); } 44 virtual bool isEmpty() const { return _isEmpty(); } 45 virtual size_t size(void) const { return _size(); } 32 46 33 size_t size(void) const; 34 CBaseType* duplicate(void) const; 35 36 void checkAccess(void) const; 47 void allocate(void) ; 48 void checkEmpty(void) const; 49 37 50 T* ptrValue ; 38 39 bool clone ; 40 T value ; 51 bool empty ; 52 53 friend class CType_ref<T> ; 54 55 private : 56 57 CType* _clone(void) const; 58 void _fromString(const string& str) ; 59 string _toString(void) const; 60 bool _fromBuffer(CBufferIn& buffer) ; 61 bool _toBuffer(CBufferOut& buffer) const; 62 void _reset(void) ; 63 bool _isEmpty() const ; 64 size_t _size(void) const ; 65 41 66 } ; 42 67 68 69 template<typename T> class CType ; 70 71 template <typename T> 72 class CType_ref : public virtual CBaseType 73 { 74 public: 75 76 CType_ref(void) ; 77 CType_ref(T& val) ; 78 CType_ref(CType<T>& type) ; 79 CType_ref(const CType_ref& type) ; 80 virtual ~CType_ref() {}; 81 82 T& get(void) const; 83 84 void set(const T& val) const ; 85 void set(const CType<T>& val) const ; 86 void set(const CType_ref& val) const ; 87 88 void set_ref(T& val) ; 89 void set_ref(CType<T>& val) ; 90 void set_ref(const CType_ref& val) ; 91 92 const CType_ref& operator = (T& val) const ; 93 const CType_ref& operator = (CType<T>& val) const ; 94 const CType_ref& operator = (const CType_ref& val) const; 95 operator T&() const; 96 97 virtual CType_ref* clone(void) const { return _clone(); } 98 virtual void fromString(const string& str) { _fromString(str); } 99 virtual void fromString(const string& str) const { _fromString(str); } 100 virtual string toString(void) const { return _toString(); } 101 virtual bool fromBuffer(CBufferIn& buffer) { return _fromBuffer(buffer) ; } 102 virtual bool fromBuffer(CBufferIn& buffer) const { return _fromBuffer(buffer); } 103 virtual bool toBuffer(CBufferOut& buffer) const { return _toBuffer(buffer); } 104 virtual void reset(void) { _reset(); } 105 virtual bool isEmpty() const { return _isEmpty(); } 106 virtual size_t size(void) const { return _size(); } 107 108 void checkEmpty(void) const; 109 110 111 T mutable * ptrValue ; 112 bool empty ; 113 friend class CType<T> ; 114 115 private : 116 117 CType_ref* _clone(void) const; 118 void _fromString(const string& str) ; 119 void _fromString(const string& str) const; 120 string _toString(void) const; 121 bool _fromBuffer(CBufferIn& buffer) ; 122 bool _fromBuffer(CBufferIn& buffer) const ; 123 bool _toBuffer(CBufferOut& buffer) const; 124 void _reset(void) ; 125 bool _isEmpty() const ; 126 size_t _size(void) const ; 127 } ; 128 129 43 130 class CMessage ; 44 131 45 132 template <typename T> 46 133 CBufferOut& operator<<(CBufferOut& buffer, const CType<T>& type) ; 47 48 134 49 135 template <typename T> 50 CBufferOut& operator<<(CBufferOut& buffer, T& type) ;136 CBufferOut& operator<<(CBufferOut& buffer, const CType_ref<T>& type) ; 51 137 52 138 template <typename T> … … 54 140 55 141 template <typename T> 56 CBufferIn& operator>>(CBufferIn& buffer, const CType<T>& type) ; 57 58 template <typename T> 59 CBufferIn& operator>>(CBufferIn& buffer, T& type) ; 60 142 CBufferOut& operator<<(CBufferOut& buffer, T& type) ; 61 143 62 144 63 145 template <typename T> 146 CBufferIn& operator>>(CBufferIn& buffer, CType<T>& type) ; 147 148 template <typename T> 149 CBufferIn& operator>>(CBufferIn& buffer, const CType_ref<T>& type) ; 150 151 template <typename T> 152 CBufferIn& operator>>(CBufferIn& buffer, T& type) ; 153 154 template <typename T> 64 155 CMessage& operator<<(CMessage& msg, const CType<T>& type) ; 156 157 template <typename T> 158 CMessage& operator<<(CMessage& msg, const CType_ref<T>& type) ; 65 159 66 template <typename T>67 CMessage& operator<<(CMessage& msg,CType<T>& type) ;68 160 69 161 template <typename T> 70 162 CMessage& operator<<(CMessage& msg, const T& type) ; 71 163 72 164 template <typename T> 73 165 CMessage& operator<<(CMessage& msg, T& type) ; 74 166 75 167 } 76 168 77 169 78 //#include "t ype_impl.hpp"79 //#include "t ype_specialisation.hpp"170 //#include "test_type_impl.hpp" 171 //#include "test_type_specialisation.hpp" 80 172 81 173 #endif 174
Note: See TracChangeset
for help on using the changeset viewer.