41 agx::UInt16 const serializationVersionAtChange = 71;
45 return agxStream::detail::shouldReadDataFromArchive(
47 archiveSerializationVersion,
48 serializationVersionInRc,
49 serializationVersionAtChange,
51 agxVersionInTrunkAfterRc);
71 return agxStream::detail::shouldReadDataFromArchive(
73 archiveSerializationVersion,
74 serializationVersionInRc,
75 serializationVersionAtChange,
77 agxVersionInTrunkAfterRc);
100 template<
typename Component>
103 return !c->getIgnoreForStoreRestoreStream();
107 template<
typename Container>
110 using Component =
typename Container::value_type;
112 size_t count = count_if(
begin(components),
end(components), shouldStore<Component>);
118 template<
typename Container>
126 template<
typename Container>
137 bool match = numStored == numRestorable;
141 LOGGER_WARNING() <<
" Stream contains " << numStored <<
" and power line contains " << numRestorable <<
" restorable connectors." <<
LOGGER_ENDL();
195 bool match = endMarker == marker;
258 const char*
const parentName,
259 const char*
const dataName)
262 const bool parentHasObject =
object !=
nullptr;
263 bool streamHasObject;
264 stream >> streamHasObject;
267 bool const bothHaveObject = parentHasObject && streamHasObject;
268 bool const neitherHasObject = !parentHasObject && !streamHasObject;
269 bool const onlyParentHasObject = parentHasObject && !streamHasObject;
270 bool const onlyStreamHasObject = !parentHasObject && streamHasObject;
274 (
object->*restore)(stream);
277 else if (neitherHasObject)
282 else if (onlyParentHasObject)
287 else if (onlyStreamHasObject)
289 LOGGER_WARNING() << parentName <<
" expected " << dataName <<
" data in StoageStream, but there were none." <<
LOGGER_ENDL();
294 agxAbort1(
"Logic error. All possible cases should have been handled already.");
307 bool hasConstraint =
object !=
nullptr;
308 out << hasConstraint;
310 object->storeLightData(
out);
334 const char *
const parentName,
335 const char *
const dataName)
370 const char*
const parentName,
371 const char*
const dataName)
373 const bool parentHasObject =
object !=
nullptr;
374 bool streamHasObject;
375 stream >> streamHasObject;
377 bool const bothHaveObject = parentHasObject && streamHasObject;
378 bool const neitherHasObject = !parentHasObject && !streamHasObject;
379 bool const onlyParentHasObject = parentHasObject && !streamHasObject;
380 bool const onlyStreamHasObject = !parentHasObject && streamHasObject;
384 return object->restore(stream);
386 else if (neitherHasObject)
391 else if (onlyParentHasObject)
396 else if (onlyStreamHasObject)
398 LOGGER_WARNING() << parentName <<
" expected " << dataName <<
" data in StoageStream, but there were none." <<
LOGGER_ENDL();
403 agxAbort1(
"Logic error. All possible cases should have been handled already.");
#define AGXSTREAM_SERIALIZATION_VERSION_POWER_LINE_ROTAT_LOCAL_OR_WORLD_DIRECTION
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Abstract base class for storing/restoring a line/drums with version control.
bool hasMarkers(agxStream::StorageStream &in)
void storePowerLineEndMarker(agxStream::StorageStream &out)
const agx::UInt16 MARKER_SERIALIZATION_VERSION
void storeStorablesCount(const Container &components, agxStream::StorageStream &out)
bool restoreConnectorEndMarker(agxStream::StorageStream &in)
bool shouldReadRotationalActuatorConnectorData(size_t archiveAgxVersion, agx::UInt16 archiveSerializationVersion)
bool optionallyRestore(agxStream::StorageStream &stream, T *object, const char *const parentName, const char *const dataName)
Restores data for the given object if the object is not nullptr and the stream contains data for it.
const agx::UInt16 LIGHT_DATA_END_MARKER
const agx::UInt16 POWERLINE_BEGIN_MARKER
const agx::UInt16 POWERLINE_END_MARKER
bool restoreUnitEndMarker(agxStream::StorageStream &in)
const agx::UInt16 LIGHT_DATA_BEGIN_MARKER
const agx::UInt16 UNIT_END_MARKER
bool optionallyRestore_helper(agxStream::StorageStream &stream, agxStream::Serializable *object, RestoreMemFn restore, const char *const parentName, const char *const dataName)
Main worker helper for optinally restore.
bool restoreLightDataEndMarker(agxStream::StorageStream &in)
bool restoreRestorablesCount(const Container &components, agxStream::StorageStream &in)
void storeUnitEndMarker(agxStream::StorageStream &out)
bool optionallyRestoreLightData(agxStream::StorageStream &in, agxStream::Serializable *object, const char *const parentName, const char *const dataName)
Restores light data for the given object if the object is not nullptr and the stream contains data fo...
void storeLightDataEndMarker(agxStream::StorageStream &out)
void storeLightDataBeginMarker(agxStream::StorageStream &out)
void storeConnectorEndMarker(agxStream::StorageStream &out)
void optionallyStoreLightData(agxStream::StorageStream &out, agxStream::Serializable *object)
const agx::UInt16 CONNECTOR_END_MARKER
void storePowerLineBeginMarker(agxStream::StorageStream &out)
bool restorePowerLineBeginMarker(agxStream::StorageStream &in)
bool restoreMarker(agxStream::StorageStream &in, agx::UInt16 marker, const char *name)
bool shouldReadRotationalDimensionDirectionReference(size_t archiveAgxVersion, agx::UInt16 archiveSerializationVersion)
bool restoreLightDataBeginMarker(agxStream::StorageStream &in)
size_t countStoreRestorable(const Container &components)
bool shouldStore(const Component &c)
bool restorePowerLineEndMarker(agxStream::StorageStream &in)
void(agxStream::Serializable::* RestoreMemFn)(agxStream::StorageStream &)
Member function signature for methods that read data from a StorageStream.
agxPowerLine contains a collection of connected components that transport power across a system.
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
AGXCORE_EXPORT agx::UInt32 AGX_CALC_VERSION(agx::UInt8 generation, agx::UInt8 major, agx::UInt8 minor, agx::UInt8 patch)