Mantid
Loading...
Searching...
No Matches
FreeBlock.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "MantidKernel/DllConfig.h"
10
11namespace Mantid {
12namespace Kernel {
13
22class MANTID_KERNEL_DLL FreeBlock {
23public:
25 FreeBlock() : m_filePos(0), m_size(0) {}
26
30 FreeBlock(uint64_t pos, uint64_t size) : m_filePos(pos), m_size(size) {}
31
33 inline uint64_t getFilePosition() const { return m_filePos; }
34
36 inline uint64_t getSize() const { return m_size; }
37
38 //----------------------------------------------------------------
49 static bool merge(FreeBlock &first, const FreeBlock &second) {
50 if ((first.m_filePos + first.m_size) == second.m_filePos) {
51 // Blocks are contiguous and get merged
52 first.m_size += second.m_size;
53 // Caller will then remove the other block
54 return true;
55 } else
56 return false;
57 }
58
59public:
60 uint64_t m_filePos;
61 uint64_t m_size;
62};
63
64} // namespace Kernel
65} // namespace Mantid
size_t m_size
Maximum size of the store.
FreeBlock: a simple class that holds the position and size of block of free space in a file.
Definition: FreeBlock.h:22
FreeBlock(uint64_t pos, uint64_t size)
Constructor.
Definition: FreeBlock.h:30
static bool merge(FreeBlock &first, const FreeBlock &second)
Attempt to merge an adjacent block into this one.
Definition: FreeBlock.h:49
uint64_t getSize() const
Definition: FreeBlock.h:36
uint64_t getFilePosition() const
Definition: FreeBlock.h:33
FreeBlock()
Default constructor.
Definition: FreeBlock.h:25
Helper class which provides the Collimation Length for SANS instruments.