31 #if !defined(THEOLIZER_INTERNAL_CORE_TYPE_INFO_H) 32 #define THEOLIZER_INTERNAL_CORE_TYPE_INFO_H 46 #pragma warning(disable:4100 4127 4251) 53 #ifndef THEOLIZER_INTERNAL_DOXYGEN 73 enum ReadStat {Terminated=0, Continue, DontCare};
99 template<
class tBaseSerializer,
typename tType,
bool tIsRegister=
false,
100 TrackingMode tTrackingMode=etmDefault,
class tEnable=
void>
105 TrackingMode tTrackingMode,
106 class tTheolizerVersion,
111 struct BranchedProcess;
115 TrackingMode tTrackingMode,
116 class tTheolizerVersion,
122 tSerializer& iSerializer,
123 tType
const& iInstance,
125 char const* iFileName,
131 TrackingMode tTrackingMode,
132 class tTheolizerVersion,
138 tSerializer& iSerializer,
141 char const* iFileName,
157 struct SerializedTypeIndex;
163 struct SerializedTypeName;
170 class THEOLIZER_INTERNAL_DLL BaseTypeInfo;
191 char const* mTypeName;
192 std::size_t mTypeIndex;
194 TypeName(
char const* iTypeName, std::size_t iTypeIndex) :
195 mTypeName(iTypeName),
196 mTypeIndex(iTypeIndex)
199 typedef std::vector<TypeName> TypeNameList;
201 TypeNameList::const_iterator findTypeName(TypeNameList
const& iTypeNameList,
202 char const* iTypeName);
208 typedef std::vector<std::size_t> TypeIndexList;
210 using TypeInfoListImpl=std::vector<BaseTypeInfo*>;
216 class BaseGlobalVersions;
218 class THEOLIZER_INTERNAL_DLL TypeInfoList
221 template<
class,
class,
class,
bool,
bool>
friend class RegisterType;
223 TypeInfoList() : mPrimitiveTypeIndex(kInvalidSize)
227 TypeInfoListImpl mList;
230 std::size_t mPrimitiveTypeIndex;
233 static TypeInfoList& getInstance();
236 TypeInfoList(
const TypeInfoList&) =
delete;
237 TypeInfoList( TypeInfoList&&) =
delete;
238 TypeInfoList& operator=(
const TypeInfoList&) =
delete;
239 TypeInfoList& operator=( TypeInfoList&&) =
delete;
242 std::size_t registerType(BaseTypeInfo* iTypeInfo);
245 TypeInfoListImpl& getList() {
return mList;}
248 std::size_t getPrimitiveTypeIndex() {
return mPrimitiveTypeIndex;}
259 class THEOLIZER_INTERNAL_DLL VersionNoList :
public std::vector<unsigned>
263 VersionNoList(
bool iIsMetaMode=
false) : mIsMetaMode(iIsMetaMode) { }
264 bool isMetaMode()
const {
return mIsMetaMode;}
265 unsigned at(std::size_t iTypeIndex)
const;
301 using ElementRange = PolyRange<ElementBase const>;
313 etkNonIntrusiveFlag =8,
319 etkPrimitive =etkPrimitiveFlag,
320 etkEnum =etkEnumFlag | etkNonIntrusiveFlag,
321 etkIntrusiveAuto =etkClassFlag,
322 etkNonIntrusiveAuto =etkClassFlag | etkNonIntrusiveFlag,
323 etkIntrusiveManual =etkClassFlag | etkManualFlag,
324 etkNonIntrusiveManual =etkClassFlag | etkNonIntrusiveFlag | etkManualFlag
348 class BaseSerializer;
353 template<
class,
class,
class,
bool,
bool>
friend class RegisterType;
354 friend class BaseSerializer;
355 friend class TypeInfoList;
356 template<
class>
friend class PointerTypeInfo;
357 template<
class>
friend class ArrayTypeInfo;
358 template<
class>
friend class ClassTypeInfo;
359 template<
class,
typename,
bool, TrackingMode,
class>
friend struct Switcher;
360 template<
typename,
bool,
class>
friend struct Switcher2;
361 template<
typename...>
friend struct ParameterName;
362 template<
class>
friend class Element;
365 void registerTypeIndex(std::size_t iTypeIndex)
367 mTypeIndex=iTypeIndex;
373 Destinations mTopDestinations;
382 TypeCategory mTypeCategory;
385 BaseTypeInfo(TypeCategory iTypeCategory) :
389 mTypeCategory(iTypeCategory),
390 mTypeIndex(kInvalidSize),
396 std::size_t mTypeIndex;
406 Destinations
const& iDestinations
410 mTopDestinations.add(iDestinations);
416 Destinations
const& iSerializerDestinations
424 return iSerializerDestinations.isMatch(mTopDestinations,
true);
429 bool isManual() {
return mIsManual;}
436 virtual std::type_index getStdTypeIndex(
bool iRaw=
false)
const = 0;
437 virtual unsigned getLastVersionNoV()
const = 0;
438 virtual std::string getTypeName(VersionNoList
const& iVersionNoList) = 0;
441 virtual char const* getUniqueName()
442 {THEOLIZER_INTERNAL_ABORT(
"BaseTypeInfo::getUniqueName()");}
443 virtual ElementsMapping getElementsMapping(
unsigned iVersionNo)
444 {THEOLIZER_INTERNAL_ABORT(
"BaseTypeInfo::getElementsMapping()");}
447 virtual ElementRange getElementRange(
unsigned iVersionNo)
448 {
return ElementRange();}
451 virtual char const* getCName()
const = 0;
452 bool isTopLovel() {
return mIsTopLevel;}
456 bool isPointee() {
return mIsPointee; }
463 virtual bool setSaving(BaseSerializer& iSerializer, std::vector<SaveStat>& ioSaveStatList)
467 virtual BaseTypeInfo* getPointeeTypeInfo() {
return nullptr;}
470 virtual std::size_t getUnderlyingTypeIndex()
471 {THEOLIZER_INTERNAL_ABORT(
"BaseTypeInfo::getUnderlyingTypeIndex()");}
476 virtual unsigned getTypeFlags(
unsigned iVersionNo) {
return 0;}
478 virtual TypeKind getTypeKind() = 0;
487 template<
typename tType,
class tEnable=
void>
490 typedef typename std::remove_cv<tType>::type Type;
492 static std::type_index getStdTypeIndex()
494 return std::type_index(
typeid(Type));
499 template<
typename tType>
500 class StdTypeIndex<tType, EnableIf<std::is_pointer<tType>::value>>
502 typedef typename std::remove_pointer<tType>::type Type;
504 static std::type_index getStdTypeIndex()
506 return StdTypeIndex<Type>::getStdTypeIndex();
510 template<
typename tType>
511 class StdTypeIndex<tType, EnableIf<std::is_lvalue_reference<tType>::value>>
513 typedef typename std::remove_reference<tType>::type Type;
515 static std::type_index getStdTypeIndex()
517 return StdTypeIndex<Type>::getStdTypeIndex();
521 template<
typename tType>
522 class StdTypeIndex<tType, EnableIf<std::is_array<tType>::value>>
524 typedef typename std::remove_extent<tType>::type Type;
526 static std::type_index getStdTypeIndex()
528 return StdTypeIndex<Type>::getStdTypeIndex();
537 template<
typename tPo
interType>
538 class PointerTypeInfo :
public BaseTypeInfo
542 PointerTypeInfo() : BaseTypeInfo(etcPointerType) { }
544 static PointerTypeInfo& getInstance()
546 static PointerTypeInfo instance;
551 PointerTypeInfo(
const PointerTypeInfo&) =
delete;
552 PointerTypeInfo( PointerTypeInfo&&) =
delete;
553 PointerTypeInfo& operator=(
const PointerTypeInfo&) =
delete;
554 PointerTypeInfo& operator=( PointerTypeInfo&&) =
delete;
559 std::type_index getStdTypeIndex(
bool iRaw)
const 561 return StdTypeIndex<tPointerType>::getStdTypeIndex();
564 static unsigned getLastVersionNo();
565 unsigned getLastVersionNoV()
const {
return getLastVersionNo();}
567 std::string getTypeName(VersionNoList
const& iVersionNoList);
569 char const* getCName()
const 571 return THEOLIZER_INTERNAL_TYPE_NAME(tPointerType);
575 BaseTypeInfo* getPointeeTypeInfo();
579 TypeKind getTypeKind()
581 return getPointeeTypeInfo()->getTypeKind();
597 template<
typename tArrayType>
598 class ArrayTypeInfo :
public BaseTypeInfo
602 ArrayTypeInfo() : BaseTypeInfo(etcArrayType) { }
604 static ArrayTypeInfo& getInstance()
606 static ArrayTypeInfo instance;
611 ArrayTypeInfo(
const ArrayTypeInfo&) =
delete;
612 ArrayTypeInfo( ArrayTypeInfo&&) =
delete;
613 ArrayTypeInfo& operator= (
const ArrayTypeInfo&) =
delete;
614 ArrayTypeInfo& operator= ( ArrayTypeInfo&&) =
delete;
619 std::type_index getStdTypeIndex(
bool iRaw)
const 620 {
return StdTypeIndex<tArrayType>::getStdTypeIndex();}
622 static unsigned getLastVersionNo();
623 unsigned getLastVersionNoV()
const {
return getLastVersionNo();}
625 std::string getTypeName(VersionNoList
const& iVersionNoList);
627 char const* getCName()
const 629 return THEOLIZER_INTERNAL_TYPE_NAME(tArrayType);
632 std::size_t getUnderlyingTypeIndex();
636 TypeKind getTypeKind()
638 BaseTypeInfo* aTypeInfo =
639 TypeInfoList::getInstance().getList().at(getUnderlyingTypeIndex());
640 return aTypeInfo->getTypeKind();
662 template<
class tClassType>
663 class ClassTypeInfo :
public BaseTypeInfo
665 template<
class,
typename,
class>
friend struct SavePointer;
666 template<
class,
typename,
class>
friend struct LoadPointer;
668 typedef typename tClassType::TheolizerTarget TheolizerTarget;
670 typedef typename tClassType::TheolizerClass TheolizerClass;
674 ClassTypeInfo() : BaseTypeInfo(etcClassType) { }
676 static ClassTypeInfo& getInstance()
678 static ClassTypeInfo instance;
683 ClassTypeInfo(
const ClassTypeInfo&) =
delete;
684 ClassTypeInfo( ClassTypeInfo&&) =
delete;
685 ClassTypeInfo& operator=(
const ClassTypeInfo&) =
delete;
686 ClassTypeInfo& operator=( ClassTypeInfo&&) =
delete;
693 std::type_index getStdTypeIndex(
bool iRaw)
const 697 return std::type_index(
typeid(TheolizerTarget));
700 typedef typename tClassType::Theolizer::DefineUniqueName::UniqueClass UniqueClass;
701 return std::type_index(
typeid(UniqueClass));
704 static unsigned getLastVersionNo() {
return tClassType::Theolizer::kLastVersionNo;}
705 unsigned getLastVersionNoV()
const {
return getLastVersionNo();}
707 std::string getTypeName(VersionNoList
const& iVersionNoList)
709 THEOLIZER_INTERNAL_ASSERT(BaseTypeInfo::mTypeIndex != kInvalidSize,
710 "Not registered class %1%.", getCName());
711 return tClassType::Theolizer::getClassName
714 iVersionNoList.at(BaseTypeInfo::mTypeIndex)
717 char const* getUniqueName()
719 return tClassType::Theolizer::getUniqueName();
722 ElementsMapping getElementsMapping(
unsigned iVersionNo)
724 return tClassType::Theolizer::getElementsMapping(iVersionNo);
728 char const* getCName()
const 730 return THEOLIZER_INTERNAL_TYPE_NAME(
typename tClassType::TheolizerTarget);
734 ElementRange getElementRange(
unsigned iVersionNo)
736 return tClassType::Theolizer::getElementRange(iVersionNo);
745 virtual bool saveTypeInstance
747 BaseSerializer& iSerializer,
748 tClassType*& iPointer,
749 std::type_index iStdTypeIndex
751 virtual bool loadTypeInstance
753 BaseSerializer& iSerializer,
754 tClassType*& ioPointer,
755 TypeIndexList& iTypeIndexList
757 virtual bool setSaving
759 BaseSerializer& iSerializer,
760 std::vector<SaveStat>& ioSaveStatList
762 virtual void const* getDerivedPointer(TheolizerTarget* iBasePointer)=0;
763 virtual std::size_t getTypeIndex()=0;
764 virtual ~HolderBase() { }
768 template<
class tDrivedClassType>
769 struct Holder :
public HolderBase
774 bool saveTypeInstance
776 BaseSerializer& iSerializer,
777 tClassType*& iPointer,
778 std::type_index iStdTypeIndex
781 typedef typename tClassType::TheolizerTarget TheolizerTarget;
782 tDrivedClassType* aPointer=
783 static_cast<tDrivedClassType*
>(
reinterpret_cast<TheolizerTarget*
>(iPointer));
784 return ClassTypeInfo<tDrivedClassType>::getInstance().
793 bool loadTypeInstance
795 BaseSerializer& iSerializer,
796 tClassType*& ioPointer,
797 TypeIndexList& iTypeIndexList
800 tDrivedClassType* aPointer=
801 static_cast<tDrivedClassType*
>(
reinterpret_cast<TheolizerTarget*
>(ioPointer));
802 bool ret=ClassTypeInfo<tDrivedClassType>::getInstance().
809 ioPointer=
reinterpret_cast<tClassType*
>(
static_cast<TheolizerTarget*
>(aPointer));
813 bool setSaving(BaseSerializer& iSerializer, std::vector<SaveStat>& ioSaveStatList)
815 return ClassTypeInfo<tDrivedClassType>::getInstance().
816 setSaving(iSerializer, ioSaveStatList);
819 void const* getDerivedPointer(TheolizerTarget* iBasePointer)
821 void* aPointer=
static_cast<tDrivedClassType*
>(iBasePointer);
825 std::size_t getTypeIndex()
827 return ClassTypeInfo<tDrivedClassType>::getInstance().mTypeIndex;
832 std::vector<std::unique_ptr<HolderBase> > mDrivedClassList;
836 template<
class tDrivedClassType>
837 void registerDrivedClass()
842 mDrivedClassList.emplace_back(
new Holder<tDrivedClassType>);
846 bool saveTypeInstance
848 BaseSerializer& iSerializer,
849 tClassType*& iPointer,
850 std::type_index iStdTypeIndex
854 bool loadTypeInstance
856 BaseSerializer& iSerializer,
857 tClassType*& ioPointer,
858 TypeIndexList& iTypeIndexList
863 bool setSaving(BaseSerializer& iSerializer, std::vector<SaveStat>& ioSaveStatList)
866 if (!mDrivedClassList.size())
872 for (
auto&& aDrivedClass : mDrivedClassList)
874 std::size_t aTypeIndex = aDrivedClass->getTypeIndex();
875 SaveStat& aSaveStat = ioSaveStatList.at(aTypeIndex);
877 if (aSaveStat == essIdle)
880 if (aTypeIndex < mTypeIndex) ret=
true;
882 if (aDrivedClass->setSaving(iSerializer, ioSaveStatList)) ret=
true;
888 void const* getDerivedPointer(TheolizerTarget* iBasePointer);
892 std::type_index getTargetStdTypeIndex()
const 894 return std::type_index(
typeid(
typename tClassType::TheolizerTarget));
899 unsigned getTypeFlags(
unsigned iVersionNo)
902 if (tClassType::Theolizer::kIsAuto)
903 return tClassType::Theolizer::getTypeFlags(iVersionNo);
907 ret |= theolizer::internal::ecfOrder;
911 TypeKind getTypeKind()
913 std::underlying_type<TypeKind>::type ret = etkClassFlag;
915 if (tClassType::Theolizer::kIsNonIntrusive)
917 ret |= etkNonIntrusiveFlag;
920 if (!tClassType::Theolizer::kIsAuto)
922 ret |= etkManualFlag;
927 typename tClassType::Theolizer::DefineUniqueName::UniqueClass,
928 typename tClassType::TheolizerTarget
931 ret |= etkTemplateFlag;
934 return static_cast<TypeKind
>(ret);
944 template<
typename tEnumType>
945 class EnumTypeInfo :
public BaseTypeInfo
948 typedef TheolizerNonIntrusive<tEnumType> EnumNonIntrusive;
951 EnumTypeInfo() : BaseTypeInfo(etcEnumType) { }
953 static EnumTypeInfo& getInstance()
955 static EnumTypeInfo instance;
960 EnumTypeInfo(
const EnumTypeInfo&) =
delete;
961 EnumTypeInfo( EnumTypeInfo&&) =
delete;
962 EnumTypeInfo& operator=(
const EnumTypeInfo&) =
delete;
963 EnumTypeInfo& operator=( EnumTypeInfo&&) =
delete;
968 std::type_index getStdTypeIndex(
bool iRaw)
const 969 {
return std::type_index(
typeid(tEnumType));}
971 static unsigned getLastVersionNo()
973 return EnumNonIntrusive::Theolizer::kLastVersionNo;
975 unsigned getLastVersionNoV()
const {
return getLastVersionNo();}
977 std::string getTypeName(VersionNoList
const& iVersionNoList)
979 return EnumNonIntrusive::Theolizer::getEnumName
982 at(BaseTypeInfo::mTypeIndex)
986 char const* getCName()
const 988 return THEOLIZER_INTERNAL_TYPE_NAME(tEnumType);
992 ElementRange getElementRange(
unsigned iVersionNo)
994 return EnumNonIntrusive::Theolizer::getElementRange(iVersionNo);
999 unsigned getTypeFlags(
unsigned iVersionNo)
1001 return EnumNonIntrusive::Theolizer::getTypeFlags(iVersionNo);
1006 TypeKind getTypeKind() {
return etkEnum;}
1018 template<
typename tPrimitiveType>
1019 class THEOLIZER_INTERNAL_DLL PrimitiveTypeInfo :
public BaseTypeInfo
1023 PrimitiveTypeInfo() : BaseTypeInfo(etcPrimitiveType) { }
1025 static PrimitiveTypeInfo& getInstance();
1028 PrimitiveTypeInfo(
const PrimitiveTypeInfo&) =
delete;
1029 PrimitiveTypeInfo( PrimitiveTypeInfo&&) =
delete;
1030 PrimitiveTypeInfo& operator=(
const PrimitiveTypeInfo&) =
delete;
1031 PrimitiveTypeInfo& operator=( PrimitiveTypeInfo&&) =
delete;
1036 std::type_index getStdTypeIndex(
bool iRaw)
const 1038 return BaseTypeFunctions::getInstance().getStdTypeIndex();
1041 static unsigned getLastVersionNo()
1043 return BaseTypeFunctions::getInstance().getLastVersionNo();
1045 unsigned getLastVersionNoV()
const {
return getLastVersionNo();}
1047 std::string getTypeName(VersionNoList
const& iVersionNoList)
1049 unsigned aVersionNo = iVersionNoList.at(BaseTypeInfo::mTypeIndex);
1050 return BaseTypeFunctions::getInstance().getPrimitiveName(aVersionNo, tPrimitiveType());
1053 char const* getCName()
const 1055 return THEOLIZER_INTERNAL_TYPE_NAME(tPrimitiveType);
1060 TypeKind getTypeKind() {
return etkPrimitive;}
1067 template<
typename tType>
1068 std::size_t getTypeIndex();
1076 template<
typename tType,
class tEnable=
void>
1079 static_assert(Ignore<tType>::kFalse,
"This is not supported type.");
1084 template<
typename tType>
1085 struct GetTypeInfo<tType, EnableIf<std::is_pointer<tType>::value> >
1087 typedef PointerTypeInfo<tType> Type;
1092 template<
typename tType>
1093 struct GetTypeInfo<tType, EnableIf<std::is_array<tType>::value> >
1095 typedef ArrayTypeInfo<tType> Type;
1100 template<
typename tType>
1101 struct GetTypeInfo<tType, EnableIf<IsIntrusive<tType>::value> >
1103 typedef ClassTypeInfo<tType> Type;
1108 template<
typename tType>
1109 struct GetTypeInfo<tType, EnableIf<IsNonIntrusive<tType>::value> >
1112 typedef TheolizerNonIntrusive<tType> TheolizerClass;
1114 typedef ClassTypeInfo<TheolizerClass> Type;
1119 template<
typename tType>
1120 struct GetTypeInfo<tType, EnableIf<std::is_enum<tType>::value> >
1122 typedef EnumTypeInfo<tType> Type;
1127 template<
typename tType>
1128 struct GetTypeInfo<tType, EnableIf<IsPrimitive<tType>::value> >
1130 typedef PrimitiveTypeInfo<tType> Type;
1135 template<
typename tType>
1136 struct GetTypeInfo<tType, EnableIf<std::is_lvalue_reference<tType>::value> >
1139 typedef typename std::remove_reference<tType>::type RemovedType;
1141 typedef typename GetTypeInfo<RemovedType>::Type Type;
1154 class tTheolizerVersion,
1156 bool uIsManual=
false,
1159 struct RegisterPointeeUnderlying
1161 static void registerType() { }
1166 template<
class tSerializer,
typename tType,
class tTheolizerVersion,
bool uIsDerived,
bool uIsManual>
1167 struct RegisterPointeeUnderlying
1174 EnableIf<std::is_pointer<tType>::value>
1177 static void registerType();
1182 template<
class tSerializer,
typename tType,
class tTheolizerVersion,
bool uIsDerived,
bool uIsManual>
1183 struct RegisterPointeeUnderlying
1190 EnableIf<std::is_array<tType>::value>
1193 static void registerType();
1200 template<
typename tType,
bool uIsDerived>
1201 struct RegisterToBaseClassEntrance
1203 void operator()(BaseTypeInfo*) { }
1206 template<
typename tType>
1207 struct RegisterToBaseClassEntrance<tType, true>
1209 void operator()(BaseTypeInfo* iBaseTypeInfo)
1211 typedef typename tType::TheolizerClass TheolizerClass;
1212 typedef typename TheolizerClass::Theolizer Theolizer;
1213 Theolizer::registerToBaseClass(iBaseTypeInfo);
1225 class tTheolizerVersion=::tTheolizerVersion,
1226 bool uIsDerived=
false,
1227 bool uIsManual=
false 1232 typedef typename RemoveCV<tType>::type RemovedCVType;
1234 static RegisterType& mInstance;
1235 static void use(
const RegisterType&) {}
1238 BaseTypeInfo* mBaseTypeInfo;
1245 typedef typename GetTypeInfo<RemovedCVType>::Type TypeInfo;
1246 mBaseTypeInfo=&TypeInfo::getInstance();
1249 std::cout <<
"RegisterType<" << THEOLIZER_INTERNAL_TYPE_NAME(tSerializer) <<
",\n" 1250 <<
" " << THEOLIZER_INTERNAL_TYPE_NAME(tType) <<
",\n" 1251 <<
" " << THEOLIZER_INTERNAL_TYPE_NAME(TypeInfo) <<
",\n" 1252 <<
" " << THEOLIZER_INTERNAL_TYPE_NAME(tTheolizerVersion) <<
",\n" 1253 <<
" uIsDerived=" << uIsDerived <<
">\n";
1257 if (tSerializer::kHasDestination)
1260 mBaseTypeInfo->addDestination(tSerializer::getDestinations());
1264 std::size_t aTypeIndex=0;
1265 if (mBaseTypeInfo->mIsRegistered)
1267 aTypeIndex=mBaseTypeInfo->mTypeIndex;
1272 aTypeIndex=TypeInfoList::getInstance().registerType(mBaseTypeInfo);
1276 mBaseTypeInfo->registerTypeIndex(aTypeIndex);
1280 RegisterToBaseClassEntrance<TypeInfo, uIsDerived>()(mBaseTypeInfo);
1284 RegisterPointeeUnderlying
1294 tTheolizerVersion::addElement
1296 []{
return theolizer::internal::getTypeIndex<tType>();}
1302 static RegisterType& getInstance()
1304 static RegisterType instance;
1308 instance.mBaseTypeInfo->mIsManual=uIsManual;
1314 RegisterType(
const RegisterType&) =
delete;
1315 RegisterType( RegisterType&&) =
delete;
1316 RegisterType& operator=(
const RegisterType&) =
delete;
1317 RegisterType& operator=( RegisterType&&) =
delete;
1320 void setPointee() { mBaseTypeInfo->mIsPointee=
true; }
1324 template<
class tSerializer,
class tType,
class tTheolizerVersion,
bool uIsDerived,
bool uIsManual>
1325 RegisterType<tSerializer, tType, tTheolizerVersion, uIsDerived, uIsManual>&
1326 RegisterType<tSerializer, tType, tTheolizerVersion, uIsDerived, uIsManual>::mInstance
1327 = RegisterType<tSerializer, tType, tTheolizerVersion, uIsDerived, uIsManual>::getInstance();
1333 template<
class tSerializer,
typename tType,
class tTheolizerVersion,
bool uIsDerived,
bool uIsManual>
1334 void RegisterPointeeUnderlying
1341 EnableIf<std::is_pointer<tType>::value>
1347 typename std::remove_pointer<tType>::type,
1351 >::getInstance().setPointee();
1364 class tTheolizerVersion,
1366 bool uIsManual=
false,
1369 struct RegisterUnderlying
1371 static void registerType()
1386 template<
class tSerializer,
typename tType,
class tTheolizerVersion,
bool uIsDerived,
bool uIsManual>
1387 struct RegisterUnderlying
1394 EnableIf<std::is_array<tType>::value>
1397 static void registerType()
1402 typename std::remove_extent<tType>::type,
1412 template<
class tSerializer,
typename tType,
class tTheolizerVersion,
bool uIsDerived,
bool uIsManual>
1413 void RegisterPointeeUnderlying
1420 EnableIf<std::is_array<tType>::value>
1426 typename std::remove_extent<tType>::type,
1442 template<
typename tType,
bool tIsRegister=false,
class tEnable=
void>
1446 static unsigned getLastVersionNo()
1448 static_assert(Ignore<tType>::kFalse,
"This is not serializable class.");
1452 static std::string getTypeName(VersionNoList
const& iVersionNoList)
1454 static_assert(Ignore<tType>::kFalse,
"This is not serializable class.");
1458 static std::size_t getTypeIndex()
1460 static_assert(Ignore<tType>::kFalse,
"This is not serializable class.");
1464 static void const* getDerivedPointer(tType* iPointer)
1466 static_assert(Ignore<tType>::kFalse,
"This is not serializable class.");
1475 template<
typename tPo
interType,
bool tIsRegister>
1480 EnableIf<std::is_pointer<tPointerType>::value>
1483 typedef typename RemoveCV<tPointerType>::type PointerType;
1486 static unsigned getLastVersionNo()
1488 return PointerTypeInfo<PointerType>::getLastVersionNo();
1491 static std::string getTypeName(VersionNoList
const& iVersionNoList)
1493 return PointerTypeInfo<PointerType>::getInstance().getTypeName(iVersionNoList);
1496 static std::size_t getTypeIndex()
1498 return PointerTypeInfo<PointerType>::getInstance().mTypeIndex;
1511 template<
typename tArrayType,
bool tIsRegister>
1516 EnableIf<std::is_array<tArrayType>::value>
1519 typedef typename RemoveCV<tArrayType>::type ArrayType;
1522 static unsigned getLastVersionNo()
1524 return ArrayTypeInfo<ArrayType>::getLastVersionNo();
1527 static std::string getTypeName(VersionNoList
const& iVersionNoList)
1529 return ArrayTypeInfo<ArrayType>::getInstance().getTypeName(iVersionNoList);
1532 static std::size_t getTypeIndex()
1534 return ArrayTypeInfo<ArrayType>::getInstance().mTypeIndex;
1537 static void const* getDerivedPointer(tArrayType* iPointer)
1549 template<
class tClassType,
bool tIsRegister>
1554 EnableIf<IsIntrusive<tClassType>::value>
1557 typedef typename std::remove_cv<tClassType>::type ClassType;
1560 static unsigned getLastVersionNo()
1562 return ClassTypeInfo<ClassType>::getLastVersionNo();
1565 static std::string getTypeName(VersionNoList
const& iVersionNoList)
1567 return ClassTypeInfo<ClassType>::getInstance().getTypeName(iVersionNoList);
1570 static std::size_t getTypeIndex()
1572 return ClassTypeInfo<ClassType>::getInstance().mTypeIndex;
1575 static void const* getDerivedPointer(tClassType* iPointer)
1577 return ClassTypeInfo<ClassType>::getInstance().getDerivedPointer(iPointer);
1585 template<
class tClassType,
bool tIsRegister>
1590 EnableIf<IsNonIntrusive<tClassType>::value>
1593 typedef typename std::remove_cv<tClassType>::type ClassNoConst;
1594 typedef TheolizerNonIntrusive<ClassNoConst> ClassType;
1597 static unsigned getLastVersionNo()
1599 return ClassTypeInfo<ClassType>::getLastVersionNo();
1602 static std::string getTypeName(VersionNoList
const& iVersionNoList)
1604 return ClassTypeInfo<ClassType>::
1605 getInstance().getTypeName(iVersionNoList);
1608 static std::size_t getTypeIndex()
1610 return ClassTypeInfo<ClassType>::getInstance().mTypeIndex;
1613 static void const* getDerivedPointer(tClassType* iPointer)
1615 return ClassTypeInfo<ClassType>::getInstance().getDerivedPointer(iPointer);
1623 template<
typename tEnumType,
bool tIsRegister>
1628 EnableIf<std::is_enum<tEnumType>::value>
1631 typedef typename std::remove_cv<tEnumType>::type EnumType;
1634 static unsigned getLastVersionNo()
1636 return EnumTypeInfo<EnumType>::getLastVersionNo();
1639 static std::string getTypeName(VersionNoList
const& iVersionNoList)
1641 return EnumTypeInfo<EnumType>::getInstance().getTypeName(iVersionNoList);
1644 static std::size_t getTypeIndex()
1646 return EnumTypeInfo<EnumType>::getInstance().mTypeIndex;
1649 static void const* getDerivedPointer(tEnumType* iPointer)
1663 template<
typename tPrimitiveType,
bool tIsRegister>
1668 EnableIf<IsPrimitive<tPrimitiveType>::value>
1671 typedef typename std::remove_cv<tPrimitiveType>::type PrimitiveType;
1674 static unsigned getLastVersionNo()
1676 return PrimitiveTypeInfo<PrimitiveType>::getLastVersionNo();
1679 static std::string getTypeName(VersionNoList
const& iVersionNoList)
1681 return PrimitiveTypeInfo<PrimitiveType>::getInstance().getTypeName(iVersionNoList);
1684 static std::size_t getTypeIndex()
1686 return PrimitiveTypeInfo<PrimitiveType>::getInstance().mTypeIndex;
1689 static void const* getDerivedPointer(tPrimitiveType* iPointer)
1699 template<
typename tType>
1700 std::size_t getTypeIndex()
1702 typedef typename std::remove_reference<tType>::type Type;
1703 return Switcher2<Type>::getTypeIndex();
1711 template<
typename tType>
1712 void const* getDerivedPointer(tType* iPointer)
1714 return Switcher2<tType>::getDerivedPointer(iPointer);
1748 template<
typename tPo
interType>
1749 unsigned PointerTypeInfo<tPointerType>::getLastVersionNo()
1751 typedef typename std::remove_pointer<tPointerType>::type ParentType;
1752 return Switcher2<ParentType>::getLastVersionNo();
1755 template<
typename tPo
interType>
1756 std::string PointerTypeInfo<tPointerType>::
1757 getTypeName(VersionNoList
const& iVersionNoList)
1759 typedef typename std::remove_pointer<tPointerType>::type ParentType;
1760 return Switcher2<ParentType>::getTypeName(iVersionNoList)+
"*";
1765 template<
typename tPo
interType>
1766 BaseTypeInfo* PointerTypeInfo<tPointerType>::getPointeeTypeInfo()
1768 typedef typename std::remove_pointer<tPointerType>::type ParentType;
1769 std::size_t aTypeIndex = Switcher2<ParentType>::getTypeIndex();
1770 return TypeInfoList::getInstance().getList().at(aTypeIndex);
1777 template<
typename tArrayType>
1778 unsigned ArrayTypeInfo<tArrayType>::getLastVersionNo()
1780 typedef typename std::remove_extent<tArrayType>::type ParentType;
1781 return Switcher2<ParentType>::getLastVersionNo();
1784 template<
typename tArrayType>
1785 std::string ArrayTypeInfo<tArrayType>::
1786 getTypeName(VersionNoList
const& iVersionNoList)
1788 typedef typename std::remove_extent<tArrayType>::type ParentType;
1789 std::string ret = Switcher2<ParentType>::getTypeName(iVersionNoList);
1790 if (iVersionNoList.isMetaMode())
1793 std::size_t pos=ret.find(
'[');
1794 std::string aExtent;
1795 if (pos != std::string::npos)
1797 aExtent = ret.substr(pos);
1798 ret = ret.substr(0, pos);
1801 ret.append(std::to_string(std::extent<tArrayType>::value));
1803 ret.append(aExtent);
1813 template<
typename tArrayType>
1814 std::size_t ArrayTypeInfo<tArrayType>::
1815 getUnderlyingTypeIndex()
1817 typedef typename std::remove_all_extents<tArrayType>::type UnderlyingType;
1818 return getTypeIndex<UnderlyingType>();
1829 template<
class tM
idSerializer,
typename tPrimitive,
class tEnable=
void>
1830 struct PrimitiveName { };
1840 template<
typename tType, tType tValue,
class tEnable=
void>
1843 static std::string
get()
1845 return std::to_string(tValue);
1849 template<
typename tType, tType tValue>
1850 struct NonType<tType, tValue, EnableIf<std::is_enum<tType>::value> >
1852 static std::string
get()
1854 typedef typename std::underlying_type<tType>::type Type;
1855 Type mValue=
static_cast<Type
>(tValue);
1856 return std::to_string(mValue);
1866 template<
typename... tRest>
1867 struct ParameterName
1869 static std::string
get(VersionNoList
const& iVersionNoList)
1877 template<
typename tClass,
typename... tRest>
1878 struct ParameterName<tClass, tRest...>
1880 static std::string
get(VersionNoList
const& iVersionNoList)
1882 std::string aName=Switcher2<tClass>::getTypeName(iVersionNoList);
1883 if (
sizeof...(tRest))
1885 aName = aName+
","+ParameterName<tRest...>::get(iVersionNoList);
1893 template<
typename tType, tType tValue,
typename... tRest>
1894 struct ParameterName<NonType<tType, tValue>, tRest...>
1896 static std::string
get(VersionNoList
const& iVersionNoList)
1898 std::string aName=NonType<tType, tValue>::get();
1899 if (
sizeof...(tRest))
1901 aName = aName+
","+ParameterName<tRest...>::get(iVersionNoList);
1909 #define THEOLIZER_INTERNAL_DEF_PRIMITIVE(dType, dSymbol) \ 1910 template<typename... tRest> \ 1911 struct ParameterName<dType, tRest...> \ 1913 static std::string get(VersionNoList const& iVersionNoList) \ 1915 std::size_t aTypeIndex=PrimitiveTypeInfo<dType>::getInstance().mTypeIndex;\ 1916 unsigned aSerializerVersionNo=iVersionNoList.at(aTypeIndex); \ 1917 static dType aType; \ 1918 std::string aName=BaseTypeFunctions::getInstance(). \ 1919 getPrimitiveName(aSerializerVersionNo, aType); \ 1920 if (sizeof...(tRest)) { \ 1921 aName = aName+","+ParameterName<tRest...>::get(iVersionNoList);\ 1926 #include "primitive.inc" 1928 #define THEOLIZER_INTERNAL_DEF_PRIMITIVE(dType, dSymbol) \ 1929 template<typename... tRest> \ 1930 struct ParameterName<dType const, tRest...> \ 1932 static std::string get(VersionNoList const& iVersionNoList) \ 1934 std::size_t aTypeIndex=PrimitiveTypeInfo<dType>::getInstance().mTypeIndex;\ 1935 unsigned aSerializerVersionNo=iVersionNoList.at(aTypeIndex); \ 1936 static dType aType; \ 1937 std::string aName=BaseTypeFunctions::getInstance(). \ 1938 getPrimitiveName(aSerializerVersionNo, aType); \ 1939 if (sizeof...(tRest)) { \ 1940 aName = aName+","+ParameterName<tRest...>::get(iVersionNoList);\ 1945 #include "primitive.inc" 1953 template<
typename... tRest>
1954 struct ParameterName<void, tRest...>
1956 static std::string
get(BaseSerializer& iSerializer)
1960 if (
sizeof...(tRest))
1962 aName = aName+
","+ParameterName<tRest...>::get(iSerializer);
1972 template<
typename... tArgs>
1973 char const* makeTemplateName(
char const* iName, VersionNoList
const& iVersionNoList)
1975 static std::string gStaticString;
1977 if (iVersionNoList.isMetaMode())
1979 gStaticString = std::string(iName) +
"<" 1980 + ParameterName<tArgs...>::get(iVersionNoList)
1982 return gStaticString.c_str();
1986 gStaticString = std::string(iName) +
"<" 1987 + ParameterName<tArgs...>::get(iVersionNoList)
1989 return gStaticString.c_str();
1993 #define THEOLIZER_INTERNAL_MAKE_TEMPLATE_NAME(dName, ...) \ 1994 theolizer::internal::makeTemplateName<__VA_ARGS__>(dName, iVersionNoList) 2000 #endif // THEOLIZER_INTERNAL_DOXYGEN 2009 #pragma warning(pop) 2012 #endif // THEOLIZER_INTERNAL_CORE_TYPE_INFO_H
Theolizerライブラリのコア部(型情報リスト)