Files
scylladb/serialization_format.hh
Avi Kivity 3aa8231c7a db: add serialization_format class
This is an abstraction layer boundary between transport and the rest of the
code.  Instead of the protocol version permeating through the code, encapsulate
it in a serialization_format variable.

This is intended to replace all uses of protocol_version outside transport.
2015-03-16 18:10:09 +02:00

26 lines
816 B
C++

/*
* Copyright (C) 2015 Cloudius Systems, Ltd.
*/
#pragma once
// Abstraction of transport protocol-dependent serialization format
// Protocols v1, v2 used 16 bits for collection sizes, while v3 and
// above use 32 bits. But letting every bit of the code know what
// transport protocol we're using (and in some cases, we aren't using
// any transport -- it's for internal storage) is bad, so abstract it
// away here.
class serialization_format {
bool _use_32_bit;
private:
explicit serialization_format(bool use_32_bit) : _use_32_bit(use_32_bit) {}
public:
static serialization_format use_16_bit() { return serialization_format(false); }
static serialization_format use_32_bit() { return serialization_format(true); }
static serialization_format internal() { return use_32_bit(); }
};