Serialization *
Last updated
Last updated
Version: 1.3
Enabled with HFSM_ENABLE_SERIALIZATION
Test: test_serialization.cpp
As demonstrated in test_serialization.cpp, it is allowed to exchange the SerialBuffer
between different FSMs, so long as their hierarchical structure is exactly the same.
This can be useful for network replication between structurally equivalent server and client FSM instances implementing some specific logic.
HFSM2 does not compress SerialBuffer
.
However, the configuration data saved to SerialBuffer::payload
is tightly packed to use the minimal number of bits.
The number of bits used in the payload is recorded in SerialBuffer::bitSize
, which could be used for example in custom network replication logic to minimize network bandwidth usage.
Compressing SerialBuffer
can also be used to further reduce the size serialized state.
hfsm2::Root::SerialBuffer
Buffer for serialization
hfsm2::Root::save(SerialBuffer&) const
Serialize the structural configuration
hfsm2::Root::load(const SerialBuffer&)
De-serialize the configuration and initialize FSM