2011-12-16 00:04:31 +05:30
|
|
|
// Copyright (C) 2011 Red Hat, Inc. All rights reserved.
|
2011-12-06 19:23:05 +05:30
|
|
|
//
|
2011-12-06 19:13:56 +05:30
|
|
|
// This file is part of the thin-provisioning-tools source.
|
|
|
|
//
|
|
|
|
// thin-provisioning-tools is free software: you can redistribute it
|
|
|
|
// and/or modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation, either version 3 of
|
|
|
|
// the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// thin-provisioning-tools is distributed in the hope that it will be
|
|
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with thin-provisioning-tools. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
|
2011-10-10 18:40:30 +05:30
|
|
|
#ifndef EMITTER_H
|
|
|
|
#define EMITTER_H
|
|
|
|
|
2012-05-17 17:33:10 +05:30
|
|
|
#include <boost/optional.hpp>
|
[build] Include boost/optional/optional_io.hpp in thin-provisioning/emitter.h (#102)
This fixes following build failure with Boost 1.67.0:
```
In file included from /usr/include/boost/optional/optional.hpp:33,
from /usr/include/boost/optional.hpp:15,
from ./thin-provisioning/emitter.h:23,
from contrib/thin_sexp_emitter.cc:2:
/usr/include/boost/optional/optional.hpp: In instantiation of ‘std::basic_ostream<_CharT, _Traits>& boost::operator<<(std::basic_ostream<_CharT, _Traits>&, const boost::optional_detail::optional_tag&) [with CharType = char; CharTrait = std::char_traits<char>]’:
./base/indented_stream.h:31:9: required from ‘{anonymous}::indented_stream& {anonymous}::indented_stream::operator<<(const T&) [with T = boost::optional<unsigned int>]’
contrib/thin_sexp_emitter.cc:105:29: required from ‘void {anonymous}::sexp_emitter::kv(const char*, const T&) [with T = boost::optional<unsigned int>]’
contrib/thin_sexp_emitter.cc:29:21: required from here
/usr/include/boost/optional/optional.hpp:1481:3: error: static assertion failed: If you want to output boost::optional, include header <boost/optional/optional_io.hpp>
BOOST_STATIC_ASSERT_MSG(sizeof(CharType) == 0, "If you want to output boost::optional, include header <boost/optional/optional_io.hpp>");
^~~~~~~~~~~~~~~~~~~~~~~
make: *** [contrib/Makefile:15: contrib/thin_sexp_emitter.o] Error 1
```
boost/optional/optional_io.hpp exists since at least Boost 1.34.0, so it is
safe to include in older versions, too.
2018-06-13 13:12:30 +05:30
|
|
|
#include <boost/optional/optional_io.hpp>
|
|
|
|
|
2020-04-30 19:32:43 +05:30
|
|
|
#include <memory>
|
2011-10-10 18:40:30 +05:30
|
|
|
#include <string>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace thin_provisioning {
|
|
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
// Here's a little grammar for how this all hangs together:
|
|
|
|
//
|
|
|
|
// superblock := <uuid> <time> <trans_id> <data_block_size> device*
|
|
|
|
// device := <dev id> <transaction id> <creation time> <snap time> <binding>
|
|
|
|
// binding := (<identifier> | <mapping>)*
|
|
|
|
// mapping := range_map | single_map
|
|
|
|
// range_map := <origin_begin> <origin_end> <data_begin>
|
|
|
|
// single_map := <origin> <data>
|
|
|
|
// named_mapping := <identifier> <mapping>
|
|
|
|
//------------------------------------------------
|
2014-06-10 21:08:10 +05:30
|
|
|
|
2011-10-10 18:40:30 +05:30
|
|
|
class emitter {
|
|
|
|
public:
|
2020-04-30 19:32:43 +05:30
|
|
|
typedef std::shared_ptr<emitter> ptr;
|
2011-10-10 18:40:30 +05:30
|
|
|
|
|
|
|
virtual ~emitter() {}
|
|
|
|
|
|
|
|
virtual void begin_superblock(std::string const &uuid,
|
|
|
|
uint64_t time,
|
|
|
|
uint64_t trans_id,
|
2016-02-27 12:50:02 +05:30
|
|
|
boost::optional<uint32_t> flags,
|
|
|
|
boost::optional<uint32_t> version,
|
2012-03-02 18:31:07 +05:30
|
|
|
uint32_t data_block_size,
|
2012-05-17 17:33:10 +05:30
|
|
|
uint64_t nr_data_blocks,
|
|
|
|
boost::optional<uint64_t> metadata_snap) = 0;
|
2011-10-10 18:40:30 +05:30
|
|
|
virtual void end_superblock() = 0;
|
|
|
|
|
|
|
|
virtual void begin_device(uint32_t dev_id,
|
|
|
|
uint64_t mapped_blocks,
|
|
|
|
uint64_t trans_id,
|
|
|
|
uint64_t creation_time,
|
|
|
|
uint64_t snap_time) = 0;
|
|
|
|
virtual void end_device() = 0;
|
|
|
|
|
|
|
|
virtual void begin_named_mapping(std::string const &name) = 0;
|
|
|
|
virtual void end_named_mapping() = 0;
|
|
|
|
|
|
|
|
virtual void identifier(std::string const &name) = 0;
|
2011-10-28 18:23:15 +05:30
|
|
|
virtual void range_map(uint64_t origin_begin, uint64_t data_begin, uint32_t time, uint64_t len) = 0;
|
|
|
|
virtual void single_map(uint64_t origin_block, uint64_t data_block, uint32_t time) = 0;
|
2011-10-10 18:40:30 +05:30
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
#endif
|