Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
mmap_struct.hpp
Go to the documentation of this file.
1#pragma once
3#include <memory>
4
5namespace fc
6{
7 class path;
8 namespace detail
9 {
14 {
15 public:
16 size_t size()const;
17 void flush();
18
19 protected:
20 void open( const fc::path& file, size_t s, bool create );
21 std::unique_ptr<fc::file_mapping> _file_mapping;
22 std::unique_ptr<fc::mapped_region> _mapped_region;
23 };
24 };
25
32 template<typename T>
34 {
35 public:
36 mmap_struct():_mapped_struct(nullptr){}
43 void open( const fc::path& file, bool create = false )
44 {
45 detail::mmap_struct_base::open( file, sizeof(T), create );
46 _mapped_struct = (T*)_mapped_region->get_address();
47 }
48
49 T* operator->() { return _mapped_struct; }
50 const T* operator->()const { return _mapped_struct; }
51
52 T& operator*() { return *_mapped_struct; }
53 const T& operator*()const { return *_mapped_struct; }
54
55 private:
56 T* _mapped_struct;
57 };
58
59}
void open(const fc::path &file, size_t s, bool create)
std::unique_ptr< fc::mapped_region > _mapped_region
std::unique_ptr< fc::file_mapping > _file_mapping
A struct that has been mapped from a file.
void open(const fc::path &file, bool create=false)
const T & operator*() const
const T * operator->() const
wraps boost::filesystem::path to provide platform independent path manipulation.
namespace sysio::chain
Definition authority.cpp:3
#define T(meth, val, expected)
char * s