20 #ifndef CO_DISTRIBUTABLE_H 21 #define CO_DISTRIBUTABLE_H 23 #include <co/object.h> 24 #include <co/dataIStream.h> 25 #include <co/dataOStream.h> 26 #include <servus/serializable.h> 47 : T( rhs ), S( rhs ), _dirty( false ) {}
52 bool isDirty() const final {
return S::isDirty() || _dirty; }
55 uint128_t
commit(
const uint32_t incarnation = CO_COMMIT_NEXT ) final
57 const uint128_t& version = S::commit( incarnation );
71 typename S::ChangeType getChangeType()
const final {
return S::INSTANCE; }
75 S::getInstanceData( os );
76 const auto& data = T::toBinary();
77 os << data.size << Array< const void >( data.ptr.get(), data.size );
82 S::applyInstanceData( is );
83 const size_t size = is.
read<
size_t >();
90 template<
class T >
inline 91 std::ostream& operator << ( std::ostream& os, const Distributable< T >& object )
93 return os << static_cast< const T& >( object );
Distributable Collage object for any servus::Serializable object.
A std::ostream-like interface for object serialization.
Object-oriented network library.
CO_API const void * getRemainingBuffer(const uint64_t size)
Distributable(const Distributable &rhs)
Copy-construct a distributable object.
Distributable(Args...args)
Construct a new distributable object.
void notifyChanged() override
Call whenever the object has been modified so it can be distributed.
A std::istream-like input data stream for binary data.
bool isDirty() const final
uint128_t commit(const uint32_t incarnation=CO_COMMIT_NEXT) final