#1941 closed Bugs (fixed)
polymorphic archive interface doesn't match other archive interfaces
Reported by: | Owned by: | Robert Ramey | |
---|---|---|---|
Milestone: | Component: | serialization | |
Version: | Boost 1.35.0 | Severity: | Problem |
Keywords: | polymorphic | Cc: |
Description
I can't invoke get_library_version() on a polymorphic_binary_iarchive because it's private, whereas it's public in a binary_archive.
Change History (8)
comment:1 by , 14 years ago
Status: | new → assigned |
---|
comment:2 by , 14 years ago
Try calling get_library_version() on a polymorphic_xml_iarchive instance.
The problem is that polymorphic_iarchive_dispatch has the get_library_version() method declared as private. But the same method is public on other archives, like a binary_iarchive.
comment:3 by , 14 years ago
get_library_version() is public in the base class. Since its virtual function it dispatches through the vtable to the derived class function with the same name. The one in the derived class may be - and if fact should be - private. This prevents users from calling intothe dispatch directly and there by breaking the polymorphic design.
You shouldn't even be including polymorphic_iarchive_dispatch.hpp in your code - either directly or indirectly. Check out the manual and examples.
you can send me a small example which illustrates the problem and I'll look at it.
RObert Ramey
comment:4 by , 14 years ago
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
comment:5 by , 14 years ago
Here's the code that was causing me the grief:
Create the target archive object, as input boost::archive::polymorphic_binary_iarchive targetData(std::ifstream(sourcePath.external_directory_string().c_str()));
If the versioning implies that an update is not required if(targetData.get_library_version() == mTypeVersions[GetType(asset)]) {
Load from the target ...
}
comment:6 by , 14 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Re-opening the comment so that the sample problem code provided can be looked at
comment:7 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
The whole point of the polymorphic archive is to permit usage of a common interface without depending on the specific one. So really one is expected to use the base class "accessors"
try the following:
// Create the target archive object, as input boost::archive::polymorphic_iarchive &targetData = boost::archive::polymorphic_binary_iarchive targetData( std::ifstream(sourcePath.external_directory_string().c_str()) ); // If the versioning implies that an update is not required if(targetData.get_library_version() == mTypeVersions[GetType?(asset)]) { // Load from the target // ... }
If that fails let me know.
Robert Ramey
I'm looking at this and I don't see anything obvious. Send me a small example.
RObert Ramey