Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Array container does only serialize base classes
Array container does only serialize base classes [message #2814] Wed, 26 April 2006 09:38 Go to next message
hans is currently offline  hans
Messages: 44
Registered: March 2006
Location: Germany
Member
Hi,
the Array container class does not recreate the derived classes when Serialize() for load is called, only the base classe.

Either it should recreate the derived class, which requires some kind of class factory, like MFC dyncreate. Or it should ASSERT on save if a derived class object is in the Array.

Re: Array container does only serialize base classes [message #2815 is a reply to message #2814] Wed, 26 April 2006 09:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
hans wrote on Wed, 26 April 2006 03:38

Hi,
the Array container class does not recreate the derived classes when Serialize() for load is called, only the base classe.

Either it should recreate the derived class, which requires some kind of class factory, like MFC dyncreate. Or it should ASSERT on save if a derived class object is in the Array.




Yes, this is correct. I vote for ASSERT, however, at the moment I am not sure how condition should look like? Maybe typeinfo name equality?

Mirek
Re: Array container does only serialize base classes [message #2818 is a reply to message #2815] Wed, 26 April 2006 10:28 Go to previous messageGo to next message
hans is currently offline  hans
Messages: 44
Registered: March 2006
Location: Germany
Member
Hi,
Typeinfo requires having virtual functions in the class, which is
a big restriction. Perhaps only document it.
Re: Array container does only serialize base classes [message #2819 is a reply to message #2818] Wed, 26 April 2006 10:39 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Done Smile

Mirek
Re: Array container does only serialize base classes [message #2820 is a reply to message #2819] Wed, 26 April 2006 12:34 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member

<speculating>
Not exactly sure what Array class does, as I haven't learnt NTL or concepts like "pick" yet (shame on me), but according to Array documentation, Array owns its contained objects, so maybe that means the class needs a virtual destructor anyway, otherwise the derived destructor is never called ??
Even if typeinfo failed to detect a derived type for some cases, it might help other cases, and a mechanism for disabling the runtime assert is probably easy to provide.
</speculating>

Graeme
Re: Array container does only serialize base classes [message #2821 is a reply to message #2820] Wed, 26 April 2006 13:07 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
gprentice wrote on Wed, 26 April 2006 06:34


<speculating>
Not exactly sure what Array class does, as I haven't learnt NTL or concepts like "pick" yet (shame on me), but according to Array documentation, Array owns its contained objects, so maybe that means the class needs a virtual destructor anyway, otherwise the derived destructor is never called ??
Even if typeinfo failed to detect a derived type for some cases, it might help other cases, and a mechanism for disabling the runtime assert is probably easy to provide.
</speculating>

Graeme



I think you are right...

Just to make it clear, Array can and often is used in non-polymorphic situations too (e.g. for non-Moveable objects), then the virtual destructor really is not needed.

Mirek
Previous Topic: NTL and C4251
Next Topic: is there a substring method?
Goto Forum:
  


Current Time: Thu Apr 18 17:08:36 CEST 2024

Total time taken to generate the page: 0.02398 seconds