31 #if !defined(THEOLIZER_INTERNAL_CORE_SWITCHER_H) 32 #define THEOLIZER_INTERNAL_CORE_SWITCHER_H 34 #include <initializer_list> 36 #include "core_serializer.h" 48 #pragma warning(disable:4100 4127 4189) 55 #ifndef THEOLIZER_INTERNAL_DOXYGEN 70 template<
class tBaseSerializer,
typename tType,
bool tIsRegister,
71 TrackingMode tTrackingMode,
class tEnable>
75 static void save(tBaseSerializer& iSerializer, tType& iInstance)
77 static_assert(Ignore<tType>::kFalse,
"This is not serializable class.");
81 static void load(tBaseSerializer& iSerializer, tType& iInstance)
83 static_assert(Ignore<tType>::kFalse,
"This is not serializable class.");
92 #define THEOLIZER_INTERNAL_NON_FOUND_DERIVED(dBase) \ 93 THEOLIZER_INTERNAL_DATA_ERROR( \ 94 u8"Can not find the derived class for %1%." \ 95 " Please specify the derived class by THEOLIZER_REGISTER_CLASS((derived class));",\ 101 template<
class tBaseSerializer,
typename tType,
class tEnalbe=
void>
104 static void save(tBaseSerializer& iSerializer, tType*& iPointer)
106 Switcher<tBaseSerializer, tType, false, etmDefault>::save(iSerializer, *iPointer);
111 template<
class tBaseSerializer,
typename tClassType>
112 struct SavePointer<tBaseSerializer, tClassType, EnableIf<IsIntrusive<tClassType>::value> >
114 static void save(tBaseSerializer& iSerializer, tClassType*& iPointer)
116 tClassType* aPointer=iPointer;
117 auto& aClassTypeInfo=ClassTypeInfo<tClassType>::getInstance();
118 bool ret=aClassTypeInfo.saveTypeInstance
122 std::type_index(
typeid(*aPointer))
126 THEOLIZER_INTERNAL_NON_FOUND_DERIVED(aClassTypeInfo);
132 template<
class tBaseSerializer,
typename tClassType>
137 EnableIf<IsNonIntrusive<tClassType>::value>
140 static void save(tBaseSerializer& iSerializer, tClassType*& iPointer)
142 typedef TheolizerNonIntrusive<tClassType> NonIntrusiveType;
143 auto& aClassTypeInfo=ClassTypeInfo<NonIntrusiveType>::getInstance();
144 bool ret=aClassTypeInfo.saveTypeInstance
147 reinterpret_cast<NonIntrusiveType*&>(iPointer),
148 std::type_index(
typeid(*iPointer))
152 THEOLIZER_INTERNAL_NON_FOUND_DERIVED(aClassTypeInfo);
160 template<
class tBaseSerializer,
typename tType,
class tEnalbe=
void>
163 static void load(tBaseSerializer& iSerializer, tType*& oPointer)
167 if (!oPointer) oPointer =
reinterpret_cast<tType*
>(
new tType());
170 Switcher<tBaseSerializer, tType,
false, etmDefault
171 >::load(iSerializer, *oPointer);
176 template<
class tBaseSerializer,
typename tClassType>
177 struct LoadPointer<tBaseSerializer, tClassType, EnableIf<IsIntrusive<tClassType>::value> >
179 static void load(tBaseSerializer& iSerializer, tClassType*& oPointer)
182 auto& aClassTypeInfo=ClassTypeInfo<tClassType>::getInstance();
185 if (iSerializer.mCheckMode != CheckMode::InMemory)
187 ret=aClassTypeInfo.loadTypeInstance
191 iSerializer.getProgramTypeIndex()
198 iSerializer.loadControl(aTypeIndex);
199 TypeIndexList aTypeIndexList;
200 aTypeIndexList.emplace_back(aTypeIndex);
201 ret=aClassTypeInfo.loadTypeInstance
210 THEOLIZER_INTERNAL_NON_FOUND_DERIVED(aClassTypeInfo);
216 template<
class tBaseSerializer,
typename tClassType>
217 struct LoadPointer<tBaseSerializer, tClassType, EnableIf<IsNonIntrusive<tClassType>::value> >
219 static void load(tBaseSerializer& iSerializer, tClassType*& oPointer)
222 typedef TheolizerNonIntrusive<tClassType> NonIntrusiveType;
223 auto& aClassTypeInfo=ClassTypeInfo<NonIntrusiveType>::getInstance();
226 if (iSerializer.mCheckMode != CheckMode::InMemory)
228 ret=aClassTypeInfo.loadTypeInstance
231 reinterpret_cast<NonIntrusiveType*&>(oPointer),
232 iSerializer.getProgramTypeIndex()
239 iSerializer.loadControl(aTypeIndex);
240 TypeIndexList aTypeIndexList;
241 aTypeIndexList.emplace_back(aTypeIndex);
242 ret=aClassTypeInfo.loadTypeInstance
245 reinterpret_cast<NonIntrusiveType*&>(oPointer),
251 THEOLIZER_INTERNAL_NON_FOUND_DERIVED(aClassTypeInfo);
264 typename tPointerType,
265 TrackingMode tTrackingMode,
266 THEOLIZER_INTERNAL_OVERLOAD((tTrackingMode != etmOwner))
268 void deletePointer(tPointerType iPointer)
274 typename tPointerType,
275 TrackingMode tTrackingMode,
276 THEOLIZER_INTERNAL_OVERLOAD
278 (tTrackingMode == etmOwner)
279 && (!std::is_array<
typename std::remove_pointer<tPointerType>::type>::value)
282 void deletePointer(tPointerType iPointer)
289 typename tPointerType,
290 TrackingMode tTrackingMode,
291 THEOLIZER_INTERNAL_OVERLOAD
293 (tTrackingMode == etmOwner)
294 && (std::is_array<
typename std::remove_pointer<tPointerType>::type>::value)
297 void deletePointer(tPointerType iPointer)
304 template<
class tBaseSerializer,
typename tPo
interType,
bool tIsRegister,TrackingMode tTrackingMode>
311 EnableIf<std::is_pointer<tPointerType>::value>
315 static void save(tBaseSerializer& iSerializer, tPointerType& iPointer)
318 typedef typename RemoveCV<tPointerType>::type PointerType;
320 typedef typename std::remove_pointer<PointerType>::type PointeeType;
326 SerializeInfo& aSerializeInfo=
327 iSerializer.registerObject
329 const_cast<PointerType&>(iPointer),
330 typeid(PointerType&),
336 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
337 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
339 aTypeIndex = theolizer::internal::getTypeIndex<PointeeType>();
343 if (tTrackingMode == etmDefault)
345 iSerializer.saveObjectId(aSerializeInfo.mObjectId, aTypeIndex);
352 BaseSerializer::AutoRestoreSaveStructure aAutoRestoreSaveStructure
356 (iSerializer.mRefProcessing)?Structure::Reference:Structure::OwnerPointer,
358 aSerializeInfo.mObjectId,
363 BaseSerializer::AutoClassTracking aAutoClassTracking(iSerializer);
368 iSerializer.writePreElement();
369 SavePointer<tBaseSerializer,
371 >::save(iSerializer, const_cast<PointerType&>(iPointer));
372 aSerializeInfo.mStatus=etsProcessed;
375 iSerializer.mRequireClearTracking=
true;
378 static void load(tBaseSerializer& iSerializer, tPointerType& oPointer)
381 typedef typename RemoveCV<tPointerType>::type PointerType;
383 typedef typename std::remove_pointer<PointerType>::type PointeeType;
386 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
387 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
389 aTypeIndex = theolizer::internal::getTypeIndex<PointeeType>();
393 if (tTrackingMode == etmDefault)
397 iSerializer.loadObjectId(aObjectId, aTypeIndex);
398 iSerializer.recoverObject
401 reinterpret_cast<void*&>(const_cast<PointerType&>(oPointer)),
402 typeid(PointerType&),
413 BaseSerializer::AutoRestoreLoadStructure aAutoRestoreLoadStructure
417 (iSerializer.mRefProcessing)?Structure::Reference:Structure::OwnerPointer,
423 BaseSerializer::AutoClassTracking aAutoClassTracking(iSerializer);
426 bool aIsLoaded=iSerializer.isLoadedObject(aObjectId, aPointer);
429 if (!iSerializer.readPreElement())
431 THEOLIZER_INTERNAL_DATA_ERROR(u8
"Format Error.");
436 typename std::remove_pointer<PointerType>::type
437 >::load(iSerializer, const_cast<PointerType&>(oPointer));
440 tPointerType aPointerBak=oPointer;
441 iSerializer.recoverObject
444 reinterpret_cast<void*&>(const_cast<PointerType&>(oPointer)),
450 if (aPointerBak != oPointer)
452 deletePointer<tPointerType, tTrackingMode>(aPointerBak);
455 iSerializer.mRequireClearTracking=
true;
463 template<
class tBaseSerializer,
typename tArrayType,
bool tIsRegister, TrackingMode tTrackingMode>
470 EnableIf<std::is_array<tArrayType>::value>
474 static void save(tBaseSerializer& iSerializer, tArrayType& iArray)
476 iSerializer.template saveArray<tBaseSerializer, tArrayType, tTrackingMode>(iArray);
479 static void load(tBaseSerializer& iSerializer, tArrayType& oArray)
481 iSerializer.template loadArray<tBaseSerializer, tArrayType, tTrackingMode>(oArray);
489 template<
class tBaseSerializer,
class tVersionType,
bool tIsRegister, TrackingMode tTrackingMode>
496 typename tVersionType::TheolizerArrayVersion
500 static void save(tBaseSerializer& iSerializer, tVersionType& iArray)
502 iSerializer.template saveArray
505 typename tVersionType::VersionArray,
510 static void load(tBaseSerializer& iSerializer, tVersionType& oArray)
512 iSerializer.template loadArray
515 typename tVersionType::VersionArray,
525 template<
class tBaseSerializer,
class tVersionType,
bool tIsRegister, TrackingMode tTrackingMode>
532 typename tVersionType::TheolizerArrayUnderlying
536 static void save(tBaseSerializer& iSerializer, tVersionType& iArray)
538 Switcher<tBaseSerializer,
539 typename tVersionType::UnderlyingType,
542 >::save(iSerializer, iArray.get());
545 static void load(tBaseSerializer& iSerializer, tVersionType& oArray)
547 Switcher<tBaseSerializer,
548 typename tVersionType::UnderlyingType,
551 >::load(iSerializer, oArray.get());
559 template<
class tBaseSerializer,
class tTargetClass,
bool tIsRegister, TrackingMode tTrackingMode>
566 EnableIf<IsIntrusive<tTargetClass>::value && !IsTheolizerVersion<tTargetClass>::value>
569 typedef tTargetClass IntrusiveType;
572 static void save(tBaseSerializer& iSerializer, tTargetClass& iInstance)
574 auto& aClassTypeInfo = ClassTypeInfo<IntrusiveType>::getInstance();
576 #ifndef THEOLIZER_INTERNAL_DISABLE_NULL_REFERENCE 579 THEOLIZER_INTERNAL_WRONG_USING(
580 "This reference(%1%) is nullptr.",
581 aClassTypeInfo.getCName());
588 if ((!iSerializer.mBaseProcessing)
589 && (
typeid(tTargetClass) !=
typeid(iInstance)))
593 BaseSerializer::AutoRefProcessing aAutoRefProcessing(iSerializer);
594 tTargetClass* aInstancePtr = &iInstance;
597 if (tTrackingMode == etmDefault)
600 BaseSerializer::AutoRestoreSave aAutoRestoreSave(iSerializer, emOrder,
true);
601 iSerializer.writePreElement();
602 SavePointer<tBaseSerializer,
604 >::save(iSerializer, aInstancePtr);
612 typename std::add_pointer<tTargetClass>::type,
615 >::save(iSerializer, aInstancePtr);
621 unsigned aVersionNo=iSerializer.mVersionNoList.at(aClassTypeInfo.mTypeIndex);
622 IntrusiveType* aInstancePtr = &iInstance;
625 TrackingMode aTrackingMode=tTrackingMode;
626 if ((aTrackingMode == etmDefault)
627 && (iSerializer.mClassTracking && iSerializer.mBaseProcessing))
629 aTrackingMode=etmPointee;
631 if (aTrackingMode == etmDefault)
633 IntrusiveType::Theolizer::saveClass(iSerializer, aInstancePtr, aVersionNo);
639 SerializeInfo& aSerializeInfo=
640 iSerializer.registerObject
649 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
650 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
652 aTypeIndex = theolizer::internal::getTypeIndex<tTargetClass>();
656 BaseSerializer::AutoRestoreSaveStructure aAutoRestoreSaveStructure
662 aSerializeInfo.mObjectId,
667 BaseSerializer::AutoClassTracking aAutoClassTracking(iSerializer);
672 iSerializer.writePreElement();
673 IntrusiveType::Theolizer::saveClass(iSerializer, aInstancePtr, aVersionNo);
678 static void load(tBaseSerializer& iSerializer, tTargetClass& oInstance)
680 auto& aClassTypeInfo = ClassTypeInfo<IntrusiveType>::getInstance();
682 #ifndef THEOLIZER_INTERNAL_DISABLE_NULL_REFERENCE 685 THEOLIZER_INTERNAL_WRONG_USING(
686 "This reference(%1%) is nullptr.",
687 aClassTypeInfo.getCName());
694 if ((!iSerializer.mBaseProcessing)
695 && (
typeid(tTargetClass) !=
typeid(oInstance)))
699 BaseSerializer::AutoRefProcessing aAutoRefProcessing(iSerializer);
700 tTargetClass* aInstancePtr = &oInstance;
703 if (tTrackingMode == etmDefault)
706 BaseSerializer::AutoRestoreLoad aAutoRestoreLoad(iSerializer);
707 if (!iSerializer.readPreElement())
709 THEOLIZER_INTERNAL_DATA_ERROR(u8
"Format Error.");
711 LoadPointer<tBaseSerializer,
713 >::load(iSerializer, aInstancePtr);
721 typename std::add_pointer<tTargetClass>::type,
724 >::load(iSerializer, aInstancePtr);
730 unsigned aVersionNo=iSerializer.mVersionNoList.at(aClassTypeInfo.mTypeIndex);
731 IntrusiveType* aInstancePtr = &oInstance;
734 TrackingMode aTrackingMode=tTrackingMode;
735 if ((aTrackingMode == etmDefault)
736 && (iSerializer.mClassTracking && iSerializer.mBaseProcessing))
738 aTrackingMode=etmPointee;
740 if (aTrackingMode == etmDefault)
742 IntrusiveType::Theolizer::loadClass(iSerializer, aInstancePtr, aVersionNo);
747 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
748 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
750 aTypeIndex = theolizer::internal::getTypeIndex<tTargetClass>();
754 size_t aObjectId=kInvalidSize;
755 BaseSerializer::AutoRestoreLoadStructure aAutoRestoreLoadStructure
765 BaseSerializer::AutoClassTracking aAutoClassTracking(iSerializer);
768 IntrusiveType* aPointer=&oInstance;
771 iSerializer.recoverObject
774 reinterpret_cast<void*&>(aPointer),
782 if (!iSerializer.readPreElement())
784 THEOLIZER_INTERNAL_DATA_ERROR(u8
"Format Error.");
786 IntrusiveType::Theolizer::loadClass(iSerializer, aInstancePtr, aVersionNo);
798 template<
class tBaseSerializer,
class tTargetClass,
bool tIsRegister, TrackingMode tTrackingMode>
805 EnableIf<IsNonIntrusive<tTargetClass>::value && !IsTheolizerVersion<tTargetClass>::value>
808 typedef TheolizerNonIntrusive<tTargetClass> NonIntrusiveType;
809 typedef typename NonIntrusiveType::TheolizerTarget TheolizerTarget;
812 static void save(tBaseSerializer& iSerializer, tTargetClass& iInstance)
814 auto& aClassTypeInfo = ClassTypeInfo<NonIntrusiveType>::getInstance();
816 #ifndef THEOLIZER_INTERNAL_DISABLE_NULL_REFERENCE 819 THEOLIZER_INTERNAL_WRONG_USING(
820 "This reference(%1%) is nullptr.",
821 aClassTypeInfo.getCName());
828 if ((!iSerializer.mBaseProcessing)
829 && (
typeid(tTargetClass) !=
typeid(iInstance)))
833 BaseSerializer::AutoRefProcessing aAutoRefProcessing(iSerializer);
834 tTargetClass* aInstancePtr = &iInstance;
837 if (tTrackingMode == etmDefault)
840 BaseSerializer::AutoRestoreSave aAutoRestoreSave(iSerializer, emOrder,
true);
841 iSerializer.writePreElement();
842 SavePointer<tBaseSerializer,
844 >::save(iSerializer, aInstancePtr);
852 typename std::add_pointer<tTargetClass>::type,
855 >::save(iSerializer, aInstancePtr);
861 unsigned aVersionNo=iSerializer.mVersionNoList.at(aClassTypeInfo.mTypeIndex);
862 NonIntrusiveType* aInstancePtr =
static_cast<NonIntrusiveType*
>(&iInstance);
865 TrackingMode aTrackingMode=tTrackingMode;
866 if ((aTrackingMode == etmDefault)
867 && (iSerializer.mClassTracking && iSerializer.mBaseProcessing))
869 aTrackingMode=etmPointee;
871 if (aTrackingMode == etmDefault)
873 NonIntrusiveType::Theolizer::saveClass(iSerializer, aInstancePtr, aVersionNo);
879 SerializeInfo& aSerializeInfo=
880 iSerializer.registerObject
883 typeid(
typename std::add_pointer<TheolizerTarget>::type),
889 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
890 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
892 aTypeIndex = theolizer::internal::getTypeIndex<tTargetClass>();
896 BaseSerializer::AutoRestoreSaveStructure aAutoRestoreSaveStructure
902 aSerializeInfo.mObjectId,
907 BaseSerializer::AutoClassTracking aAutoClassTracking(iSerializer);
912 iSerializer.writePreElement();
913 NonIntrusiveType::Theolizer::saveClass(iSerializer, aInstancePtr, aVersionNo);
918 static void load(tBaseSerializer& iSerializer, tTargetClass& oInstance)
920 auto& aClassTypeInfo = ClassTypeInfo<NonIntrusiveType>::getInstance();
922 #ifndef THEOLIZER_INTERNAL_DISABLE_NULL_REFERENCE 925 THEOLIZER_INTERNAL_WRONG_USING(
926 "This reference(%1%) is nullptr.",
927 aClassTypeInfo.getCName());
934 if ((!iSerializer.mBaseProcessing)
935 && (
typeid(tTargetClass) !=
typeid(oInstance)))
939 BaseSerializer::AutoRefProcessing aAutoRefProcessing(iSerializer);
940 tTargetClass* aInstancePtr = &oInstance;
943 if (tTrackingMode == etmDefault)
946 BaseSerializer::AutoRestoreLoad aAutoRestoreLoad(iSerializer);
947 if (!iSerializer.readPreElement())
949 THEOLIZER_INTERNAL_DATA_ERROR(u8
"Format Error.");
951 LoadPointer<tBaseSerializer,
953 >::load(iSerializer, aInstancePtr);
961 typename std::add_pointer<tTargetClass>::type,
964 >::load(iSerializer, aInstancePtr);
970 unsigned aVersionNo=iSerializer.mVersionNoList.at(aClassTypeInfo.mTypeIndex);
971 NonIntrusiveType* aInstancePtr =
static_cast<NonIntrusiveType*
>(&oInstance);
974 TrackingMode aTrackingMode=tTrackingMode;
975 if ((aTrackingMode == etmDefault)
976 && (iSerializer.mClassTracking && iSerializer.mBaseProcessing))
978 aTrackingMode=etmPointee;
980 if (aTrackingMode == etmDefault)
982 NonIntrusiveType::Theolizer::loadClass(iSerializer, aInstancePtr, aVersionNo);
987 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
988 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
990 aTypeIndex = theolizer::internal::getTypeIndex<tTargetClass>();
994 size_t aObjectId=kInvalidSize;
995 BaseSerializer::AutoRestoreLoadStructure aAutoRestoreLoadStructure
1005 BaseSerializer::AutoClassTracking aAutoClassTracking(iSerializer);
1008 iSerializer.recoverObject
1011 reinterpret_cast<void*&>(aInstancePtr),
1012 typeid(aInstancePtr),
1019 iSerializer.readPreElement();
1020 NonIntrusiveType::Theolizer::loadClass(iSerializer, aInstancePtr, aVersionNo);
1030 template<
class tBaseSerializer,
class tVersionType,
bool tIsRegister, TrackingMode tTrackingMode>
1039 IsTheolizerVersion<tVersionType>::value
1040 && !tVersionType::Theolizer::kIsEnum
1041 && !tVersionType::Theolizer::kIsArray
1045 typedef typename tVersionType::TheolizerClass TheolizerClass;
1046 typedef typename tVersionType::TheolizerTarget TheolizerTarget;
1049 static void save(tBaseSerializer& iSerializer, tVersionType& iInstance)
1052 TrackingMode aTrackingMode=tTrackingMode;
1053 if ((aTrackingMode == etmDefault)
1054 && (iSerializer.mClassTracking && iSerializer.mBaseProcessing))
1056 aTrackingMode=etmPointee;
1058 if (aTrackingMode == etmDefault)
1060 iInstance.saveClass(iSerializer, tVersionType::Theolizer::kVersionNo);
1066 SerializeInfo& aSerializeInfo=
1067 iSerializer.registerObject
1069 iInstance.mTheolizerSpecials.mTarget,
1070 typeid(
typename std::add_pointer<TheolizerTarget>::type),
1076 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
1077 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
1079 aTypeIndex = theolizer::internal::getTypeIndex<TheolizerTarget>();
1083 BaseSerializer::AutoRestoreSaveStructure aAutoRestoreSaveStructure
1089 aSerializeInfo.mObjectId,
1094 BaseSerializer::AutoClassTracking aAutoClassTracking(iSerializer);
1099 iSerializer.writePreElement();
1100 iInstance.saveClass(iSerializer, tVersionType::Theolizer::kVersionNo);
1105 static void load(tBaseSerializer& iSerializer, tVersionType& oInstance)
1108 TrackingMode aTrackingMode=tTrackingMode;
1109 if ((aTrackingMode == etmDefault)
1110 && (iSerializer.mClassTracking && iSerializer.mBaseProcessing))
1112 aTrackingMode=etmPointee;
1114 if (aTrackingMode == etmDefault)
1116 oInstance.loadClass(iSerializer, tVersionType::Theolizer::kVersionNo);
1121 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
1122 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
1124 aTypeIndex = theolizer::internal::getTypeIndex<TheolizerTarget>();
1128 size_t aObjectId=kInvalidSize;
1129 BaseSerializer::AutoRestoreLoadStructure aAutoRestoreLoadStructure
1139 BaseSerializer::AutoClassTracking aAutoClassTracking(iSerializer);
1142 iSerializer.recoverObject
1145 reinterpret_cast<void*&>(oInstance.mTheolizerSpecials.mTarget),
1146 typeid(oInstance.mTheolizerSpecials.mTarget),
1153 if (!iSerializer.readPreElement()) {
1154 THEOLIZER_INTERNAL_DATA_ERROR(u8
"Format Error.");
1156 oInstance.loadClass(iSerializer, tVersionType::Theolizer::kVersionNo);
1166 template<
class tBaseSerializer,
class tBaseType,
bool tIsRegister, TrackingMode tTrackingMode>
1173 EnableIf<IsTheolizerBase<tBaseType>::value>
1176 typedef typename tBaseType::Target Target;
1179 static void save(tBaseSerializer& iSerializer, tBaseType& iInstance)
1181 Switcher<tBaseSerializer,
1184 >::save(iSerializer, static_cast<Target&>(iInstance));
1187 static void load(tBaseSerializer& iSerializer, tBaseType& oInstance)
1189 Switcher<tBaseSerializer,
1192 >::load(iSerializer, static_cast<Target&>(oInstance));
1202 template<
class tBaseSerializer,
typename tEnumType,
bool tIsRegister, TrackingMode tTrackingMode>
1209 EnableIf<std::is_enum<tEnumType>::value>
1213 static void save(tBaseSerializer& iSerializer, tEnumType& iInstance)
1215 unsigned aVersionNo=iSerializer.mVersionNoList.at(
1216 EnumTypeInfo<tEnumType>::getInstance().mTypeIndex);
1218 if (tTrackingMode == etmDefault)
1220 TheolizerNonIntrusive<tEnumType>::Theolizer::
1221 saveEnum(iSerializer, iInstance, aVersionNo);
1227 SerializeInfo& aSerializeInfo=
1228 iSerializer.registerObject
1237 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
1238 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
1240 aTypeIndex = theolizer::internal::getTypeIndex<tEnumType>();
1244 BaseSerializer::AutoRestoreSaveStructure aAutoRestoreSaveStructure
1250 aSerializeInfo.mObjectId,
1257 iSerializer.writePreElement();
1258 TheolizerNonIntrusive<tEnumType>::Theolizer::
1259 saveEnum(iSerializer, iInstance, aVersionNo);
1264 static void load(tBaseSerializer& iSerializer, tEnumType& oInstance)
1266 unsigned aVersionNo=iSerializer.mVersionNoList.at(
1267 EnumTypeInfo<tEnumType>::getInstance().mTypeIndex);
1269 if (tTrackingMode == etmDefault)
1271 TheolizerNonIntrusive<tEnumType>::Theolizer::
1272 loadEnum(iSerializer,oInstance,aVersionNo);
1277 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
1278 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
1280 aTypeIndex = theolizer::internal::getTypeIndex<tEnumType>();
1284 size_t aObjectId=kInvalidSize;
1285 BaseSerializer::AutoRestoreLoadStructure aAutoRestoreLoadStructure
1295 tEnumType* aPointer=&oInstance;
1296 iSerializer.recoverObject
1299 reinterpret_cast<void*&>(aPointer),
1307 iSerializer.readPreElement();
1308 TheolizerNonIntrusive<tEnumType>::Theolizer::
1309 loadEnum(iSerializer, oInstance, aVersionNo);
1321 template<
class tBaseSerializer,
class tVersionType,
bool tIsRegister, TrackingMode tTrackingMode>
1328 typename tVersionType::TheolizerEnumVersion
1331 typedef typename tVersionType::TheolizerTarget TheolizerTarget;
1334 static void save(tBaseSerializer& iSerializer, tVersionType& iInstance)
1336 if (tTrackingMode == etmDefault)
1338 iInstance.saveEnum(iSerializer, tVersionType::Theolizer::kLastVersionNo);
1344 SerializeInfo& aSerializeInfo=
1345 iSerializer.registerObject
1348 typeid(iInstance.mTarget),
1354 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
1355 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
1357 aTypeIndex = theolizer::internal::getTypeIndex<TheolizerTarget>();
1361 BaseSerializer::AutoRestoreSaveStructure aAutoRestoreSaveStructure
1367 aSerializeInfo.mObjectId,
1374 iSerializer.writePreElement();
1375 iInstance.saveEnum(iSerializer, tVersionType::Theolizer::kLastVersionNo);
1380 static void load(tBaseSerializer& iSerializer, tVersionType& oInstance)
1382 if (tTrackingMode == etmDefault)
1384 oInstance.loadEnum(iSerializer, tVersionType::Theolizer::kLastVersionNo);
1389 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
1390 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
1392 aTypeIndex = theolizer::internal::getTypeIndex<TheolizerTarget>();
1396 size_t aObjectId=kInvalidSize;
1397 BaseSerializer::AutoRestoreLoadStructure aAutoRestoreLoadStructure
1407 iSerializer.recoverObject
1410 reinterpret_cast<void*&>(oInstance.mTarget),
1411 typeid(oInstance.mTarget),
1418 iSerializer.readPreElement();
1419 oInstance.loadEnum(iSerializer, tVersionType::Theolizer::kLastVersionNo);
1433 template<
class tBaseSerializer,
typename tPrimitiveType,
bool tIsRegister,TrackingMode tTrackingMode>
1440 EnableIf<IsPrimitive<tPrimitiveType>::value>
1444 static void save(tBaseSerializer& iSerializer, tPrimitiveType& iInstance)
1446 if (tTrackingMode == etmDefault)
1448 iSerializer.savePrimitive(iInstance);
1454 SerializeInfo& aSerializeInfo=
1455 iSerializer.registerObject
1464 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
1465 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
1467 aTypeIndex = theolizer::internal::getTypeIndex<tPrimitiveType>();
1471 BaseSerializer::AutoRestoreSaveStructure aAutoRestoreSaveStructure
1477 aSerializeInfo.mObjectId,
1484 iSerializer.writePreElement();
1485 iSerializer.savePrimitive(iInstance);
1490 static void load(tBaseSerializer& iSerializer, tPrimitiveType& oInstance)
1492 if (tTrackingMode == etmDefault)
1494 iSerializer.loadPrimitive(oInstance);
1499 std::size_t aTypeIndex = theolizer::internal::kInvalidSize;
1500 if (iSerializer.mCheckMode == theolizer::CheckMode::TypeCheckInData)
1502 aTypeIndex = theolizer::internal::getTypeIndex<tPrimitiveType>();
1506 size_t aObjectId=kInvalidSize;
1507 BaseSerializer::AutoRestoreLoadStructure aAutoRestoreLoadStructure
1517 tPrimitiveType* aPointer=&oInstance;
1518 iSerializer.recoverObject
1521 reinterpret_cast<void*&>(aPointer),
1529 iSerializer.readPreElement();
1530 iSerializer.loadPrimitive(oInstance);
1542 class tBaseSerializer,
1543 class tTheolizerNonKeepStep,
1545 TrackingMode tTrackingMode
1550 tTheolizerNonKeepStep,
1555 IsTheolizerNonKeepStep<tTheolizerNonKeepStep>::value
1560 static void save(tBaseSerializer& iSerializer, tTheolizerNonKeepStep& iInstance)
1562 iInstance.template save<tIsRegister, tTrackingMode>(iSerializer);
1565 static void load(tBaseSerializer& iSerializer, tTheolizerNonKeepStep& oInstance)
1567 oInstance.template load<tIsRegister, tTrackingMode>(iSerializer);
1581 template<
class tM
idSerializer>
1582 struct MidSerializer
1584 static MidSerializer& getInstance()
1586 static MidSerializer instance;
1591 template<
class tSerializer>
1592 int registerMidSerializer()
1594 theolizer::internal::MidSerializer<typename tSerializer::MidSerializer>::getInstance();
1598 #define THEOLIZER_INTERNAL_REGISTER_MID_SERIALIZER(dSerializer) \ 1599 static int k##dSerializer THEOLIZER_INTERNAL_UNUSED= \ 1600 theolizer::internal::registerMidSerializer<dSerializer<> >() 1611 TrackingMode tTrackingMode,
1612 class tTheolizerVersion,
1617 struct BranchedProcess { };
1623 TrackingMode tTrackingMode,
1624 class tTheolizerVersion,
1628 struct BranchedProcess
1634 EnableIf<tSerializer::kHasDestination>
1639 tSerializer& iSerializer,
1642 char const* iFileName,
1647 theolizer::internal::getUpVersionCount()=0;
1652 TypeFunctions<tSerializer> aTypeFunctions;
1655 RegisterType<tSerializer, tType, tTheolizerVersion>::getInstance();
1658 ApiBoundary aApiBoundary(&iSerializer.mAdditionalInfo);
1659 BaseSerializer::AutoRestoreSerializeInfo aAutoRestoreSerializeInfo
1660 (iSerializer, iName, 0, std::is_pointer<tType>::value, iFileName, iLineNo);
1666 iSerializer.checkError();
1669 if (iSerializer.mIsSaver)
1671 BaseSerializer::AutoRestoreSaveProcess
1672 aAutoRestoreSaveTop(iSerializer, getTypeIndex<tType>());
1675 Switcher<BaseSerializer, tType, true, tTrackingMode>::save(iSerializer,ioInstance);
1679 BaseSerializer::AutoRestoreLoadProcess
1680 aAutoRestoreLoadTop(iSerializer, getTypeIndex<tType>());
1683 Switcher<BaseSerializer, tType, true, tTrackingMode>::load(iSerializer,ioInstance);
1689 if (!iSerializer.getNoThrowException())
1701 TrackingMode tTrackingMode,
1702 class tTheolizerVersion,
1706 struct BranchedProcess
1712 EnableIf<!tSerializer::kHasDestination>
1717 tSerializer& iSerializer,
1720 char const* iFileName,
1725 AutoRestore<unsigned> aUpVersionCount(getUpVersionCount(), 0);
1730 RegisterType<tSerializer, tType, tTheolizerVersion>::getInstance();
1733 ApiBoundary aApiBoundary(&iSerializer.mAdditionalInfo);
1734 BaseSerializer::AutoRestoreSerializeInfo aAutoRestoreSerializeInfo
1735 (iSerializer, iName, 0, std::is_pointer<tType>::value, iFileName, iLineNo);
1738 iSerializer.checkError();
1741 if (iSerializer.mIsSaver)
1743 iSerializer.writePreElement(
true);
1744 BaseSerializer::AutoRestoreSaveProcess
1745 aAutoRestoreSaveTop(iSerializer, getTypeIndex<tType>());
1746 Switcher<BaseSerializer, tType, true, tTrackingMode>::save(iSerializer, ioInstance);
1750 if (iSerializer.readPreElement(
true))
1752 BaseSerializer::AutoRestoreLoadProcess
1753 aAutoRestoreLoadTop(iSerializer, getTypeIndex<tType>());
1754 Switcher<BaseSerializer, tType, true, tTrackingMode>::load(iSerializer,ioInstance);
1768 TrackingMode tTrackingMode,
1769 class tTheolizerVersion,
1775 tSerializer& iSerializer,
1776 tType
const& iInstance,
1778 char const* iFileName,
1782 THEOLIZER_INTERNAL_ASSERT(iSerializer.mIsSaver,
"Can not load to const variable.(%1%)", iName);
1785 typedef typename RemoveCV<tType>::type Type;
1793 BranchedProcess<tTrackingMode, tTheolizerVersion, tSerializer, Type>::
1794 process(iSerializer, (Type&)iInstance, iName, iFileName, iLineNo);
1801 TrackingMode tTrackingMode,
1802 class tTheolizerVersion,
1808 tSerializer& iSerializer,
1811 char const* iFileName,
1815 BranchedProcess<tTrackingMode, tTheolizerVersion, tSerializer, tType>::
1816 process(iSerializer, ioInstance, iName, iFileName, iLineNo);
1823 #endif // THEOLIZER_INTERNAL_DOXYGEN 1832 #pragma warning(pop) 1835 #endif // THEOLIZER_INTERNAL_CORE_SWITCHER_H