37 #if !defined(THEOLIZER_INTERNAL_UNIQUE_PTR_H) 38 #define THEOLIZER_INTERNAL_UNIQUE_PTR_H 40 #ifndef THEOLIZER_INTERNAL_DOXYGEN 60 THEOLIZER_TEMPLATE_PARAMETER_TEMPLATE((template<class T>),
61 std::default_delete, (T),
62 default_deleteTheolizer);
68 THEOLIZER_NON_INTRUSIVE_TEMPLATE_ORDER((template<class T, class D>),
69 (std::unique_ptr<T, D>), 1,
78 template<
class T,
class D>
79 template<
class tM
idSerializer,
class tTheolizerVersion>
80 struct TheolizerNonIntrusive<std::unique_ptr<T, D>>::
81 TheolizerUserDefine<tMidSerializer, tTheolizerVersion, 1>
84 static void saveClassManual
86 tMidSerializer& iSerializer,
87 typename tTheolizerVersion::TheolizerTarget
const*
const& iInstance
90 static_assert(!std::is_array<T>::value,
91 "[Theolizer] Can not support array type for std::unique_ptr<>.");
92 THEOLIZER_REGISTER_TEMPLATE_PARAMETER(D);
98 static void loadClassManual
100 tMidSerializer& iSerializer,
101 typename tTheolizerVersion::TheolizerTarget*& oInstance
104 static_assert(!std::is_array<T>::value,
105 "[Theolizer] Can not support array type for std::unique_ptr<>.");
107 THEOLIZER_REGISTER_TEMPLATE_PARAMETER(D);
110 if (!oInstance) oInstance=
new typename tTheolizerVersion::TheolizerTarget();
112 typedef typename tTheolizerVersion::TheolizerTarget TheolizerTarget;
113 typedef typename TheolizerTarget::element_type ElementType;
118 TheolizerTarget& mUniquePtr;
119 ElementType* mInstance;
120 AuteRestore(TheolizerTarget& iUniquePtr) :
121 mUniquePtr(iUniquePtr),
122 mInstance(mUniquePtr.release())
126 mUniquePtr.reset(mInstance);
128 } aAutoRestore(*oInstance);
137 #ifdef THEOLIZER_WRITE_CODE // ###### std::unique_ptr<T,D> ###### 139 #define THEOLIZER_GENERATED_LAST_VERSION_NO THEOLIZER_INTERNAL_DEFINE(kLastVersionNo,1) 140 #define THEOLIZER_GENERATED_CLASS_TYPE THEOLIZER_INTERNAL_UNPAREN(std::unique_ptr<T, D>) 141 #define THEOLIZER_GENERATED_PARAMETER_LIST template<class T, class D> 142 #define THEOLIZER_GENERATED_UNIQUE_NAME unique_ptrTheolizer 146 #define THEOLIZER_GENERATED_VERSION_NO THEOLIZER_INTERNAL_DEFINE(kVersionNo,1) 147 #define THEOLIZER_GENERATED_CLASS_NAME()\ 148 THEOLIZER_INTERNAL_TEMPLATE_NAME((u8"std::unique_ptr",T,D)) 149 #include <theolizer/internal/version_manual.inc> 150 #undef THEOLIZER_GENERATED_VERSION_NO 152 #endif//THEOLIZER_WRITE_CODE // ###### std::unique_ptr<T,D> ###### 162 THEOLIZER_NON_INTRUSIVE_TEMPLATE_ORDER((template<class T>),
163 (std::shared_ptr<T>), 1,
164 shared_ptrTheolizer);
170 struct shared_ptrTheolizer;
175 template<
class tM
idSerializer,
class tTheolizerVersion>
176 struct TheolizerNonIntrusive<std::shared_ptr<T>>::
177 TheolizerUserDefine<tMidSerializer, tTheolizerVersion, 1>
180 static void saveClassManual
182 tMidSerializer& iSerializer,
183 typename tTheolizerVersion::TheolizerTarget
const*
const& iInstance
190 static void loadClassManual
192 tMidSerializer& iSerializer,
193 typename tTheolizerVersion::TheolizerTarget*& oInstance
197 if (!oInstance) oInstance=
new typename tTheolizerVersion::TheolizerTarget();
199 typedef typename tTheolizerVersion::TheolizerTarget TheolizerTarget;
200 typedef typename TheolizerTarget::element_type ElementType;
201 ElementType* aInstance=oInstance->get();
203 theolizer::internal::AutoRestoreIsShared aAutoRestoreIsShared(iSerializer,
true);
216 typedef std::map<void const*, std::shared_ptr<void const> > SharedPtrMap;
217 SharedPtrMap& aSharedPtrMap=
218 iSerializer.template getSharedPtrTable<SharedPtrMap>(
typeid(shared_ptrTheolizer));
221 void const* aDerivedPointer=theolizer::internal::getDerivedPointer(aInstance);
224 auto aFound=aSharedPtrMap.find(aDerivedPointer);
225 if (aFound != aSharedPtrMap.end())
227 *oInstance=std::shared_ptr<ElementType>(aFound->second, aInstance);
233 if (aInstance != oInstance->get())
235 oInstance->reset(aInstance);
237 std::shared_ptr<void const> temp(*oInstance, aDerivedPointer);
238 aSharedPtrMap.insert(aFound, std::make_pair(aDerivedPointer, temp));
247 #ifdef THEOLIZER_WRITE_CODE // ###### std::shared_ptr<T> ###### 249 #define THEOLIZER_GENERATED_LAST_VERSION_NO THEOLIZER_INTERNAL_DEFINE(kLastVersionNo,1) 250 #define THEOLIZER_GENERATED_CLASS_TYPE THEOLIZER_INTERNAL_UNPAREN(std::shared_ptr<T>) 251 #define THEOLIZER_GENERATED_PARAMETER_LIST template<class T> 252 #define THEOLIZER_GENERATED_UNIQUE_NAME shared_ptrTheolizer 256 #define THEOLIZER_GENERATED_VERSION_NO THEOLIZER_INTERNAL_DEFINE(kVersionNo,1) 257 #define THEOLIZER_GENERATED_CLASS_NAME()\ 258 THEOLIZER_INTERNAL_TEMPLATE_NAME((u8"std::shared_ptr",T)) 259 #include <theolizer/internal/version_manual.inc> 260 #undef THEOLIZER_GENERATED_VERSION_NO 262 #endif//THEOLIZER_WRITE_CODE // ###### std::shared_ptr<T> ###### 272 THEOLIZER_NON_INTRUSIVE_TEMPLATE_ORDER((template<class T>),
273 (std::weak_ptr<T>), 1,
280 struct weak_ptrTheolizer;
285 template<
class tM
idSerializer,
class tTheolizerVersion>
286 struct TheolizerNonIntrusive<std::weak_ptr<T>>::
287 TheolizerUserDefine<tMidSerializer, tTheolizerVersion, 1>
290 static void saveClassManual
292 tMidSerializer& iSerializer,
293 typename tTheolizerVersion::TheolizerTarget
const*
const& iInstance
300 static void loadClassManual
302 tMidSerializer& iSerializer,
303 typename tTheolizerVersion::TheolizerTarget*& oInstance
307 if (!oInstance) oInstance=
new typename tTheolizerVersion::TheolizerTarget();
309 typedef typename tTheolizerVersion::TheolizerTarget TheolizerTarget;
310 typedef typename TheolizerTarget::element_type ElementType;
312 std::shared_ptr<ElementType> aShared(oInstance->lock());
322 #ifdef THEOLIZER_WRITE_CODE // ###### std::weak_ptr<T> ###### 324 #define THEOLIZER_GENERATED_LAST_VERSION_NO THEOLIZER_INTERNAL_DEFINE(kLastVersionNo,1) 325 #define THEOLIZER_GENERATED_CLASS_TYPE THEOLIZER_INTERNAL_UNPAREN(std::weak_ptr<T>) 326 #define THEOLIZER_GENERATED_PARAMETER_LIST template<class T> 327 #define THEOLIZER_GENERATED_UNIQUE_NAME weak_ptrTheolizer 331 #define THEOLIZER_GENERATED_VERSION_NO THEOLIZER_INTERNAL_DEFINE(kVersionNo,1) 332 #define THEOLIZER_GENERATED_CLASS_NAME()\ 333 THEOLIZER_INTERNAL_TEMPLATE_NAME((u8"std::weak_ptr",T)) 334 #include <theolizer/internal/version_manual.inc> 335 #undef THEOLIZER_GENERATED_VERSION_NO 337 #endif//THEOLIZER_WRITE_CODE // ###### std::weak_ptr<T> ###### 343 #endif // THEOLIZER_INTERNAL_DOXYGEN 344 #endif // THEOLIZER_INTERNAL_UNIQUE_PTR_H #define THEOLIZER_PROCESS(dSerializer, dInstance)
通常の保存/回復処理マクロ(2-4-2.シリアライズ処理要求 参照)
#define THEOLIZER_PROVIDED_BY(dVendor)
ソース自動生成制御
#define THEOLIZER_PROCESS_OWNER(dSerializer, dInstance)
オーナ・ポインタ用の保存/回復処理マクロ(2-4-2.シリアライズ処理要求 参照)