I used to think that serialization has nothing to do with rtti, but it is actually closely related.
Serialization is to convert an object into word-based throttling data for data transmission and storage. The simplest and most straightforward way is to play a standalone game in 'disks, playing and playing with a disk, the main character in the game, the npc, the map of various game elements, stored in a certain way to files, but simply say that serialization does not talk about media, from objects to binary data streams, is serialization. The purpose of serialization is to deserialize data from byte streams into objects at a certain time in the future and continue a previous software application.
Rtti generally refers to identifying dynamic type information at runtime without rtti. The deserialization process is roughly like this:
Get a piece of byte data
=>
Analyze a public header ID
=>
If identity = 1 then
Obja = new ClassA
Obja. load (the rest)
Else if identity = 2 then
Objb = new ClassB
Objb. load (...)
...
End
There will be a bunch of if else, or switch case, and there will be various types of new, or something else.
Designing a public base class won't change the above situations. Of course, the public base class is essential for a fully oriented application, unless you persuade yourself not to use object-oriented.
With rtti, You can do cool operations. deserialization can actually be done like this:
Get a piece of byte data
=>
Directly generate a base class Object Pointer
=>
Thrown to System Object Manager
=>
Identify dynamic types with rtti and drop them to their respective managers or directly participate in the logic
There is a limitation implementation in MFC. For more information, see the relevant documentation. The limitation refers to how I don't want to use the CObject base class of MFC to specify my own base class, how can I specify my memory distributor and how can I customize my storage format.
Aspx ">