libstorage-ng
Toggle main menu visibility
Loading...
Searching...
No Matches
Alignment.h
1
/*
2
* Copyright (c) [2016-2018] SUSE LLC
3
*
4
* All Rights Reserved.
5
*
6
* This program is free software; you can redistribute it and/or modify it
7
* under the terms of version 2 of the GNU General Public License as published
8
* by the Free Software Foundation.
9
*
10
* This program is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
* more details.
14
*
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, contact Novell, Inc.
17
*
18
* To contact Novell about this file by physical or electronic mail, you may
19
* find current contact information at www.novell.com.
20
*/
21
22
23
#ifndef STORAGE_ALIGNMENT_H
24
#define STORAGE_ALIGNMENT_H
25
26
27
#include "storage/Utils/Topology.h"
28
#include "storage/Utils/Region.h"
29
#include "storage/Utils/Exception.h"
30
#include "storage/Utils/Swig.h"
31
32
33
namespace
storage
34
{
35
36
enum class
AlignType
37
{
41
REQUIRED
,
42
46
OPTIMAL
47
};
48
49
50
enum class
AlignPolicy
51
{
55
ALIGN_START_AND_END
= 0,
56
ALIGN_END ST_DEPRECATED = 0,
57
61
ALIGN_START_KEEP_END
= 1,
62
KEEP_END ST_DEPRECATED = 1,
63
67
ALIGN_START_KEEP_SIZE
= 2,
68
KEEP_SIZE ST_DEPRECATED = 2,
69
73
KEEP_START_ALIGN_END
= 3
74
};
75
76
77
class
AlignError :
public
Exception
78
{
79
public
:
80
AlignError();
81
};
82
83
91
class
Alignment
92
{
93
94
public
:
95
96
Alignment(
const
Topology
& topology,
AlignType
align_type =
AlignType::OPTIMAL
);
97
Alignment(
const
Alignment& alignment);
98
Alignment(Alignment&& alignment) =
default
;
99
~Alignment();
100
101
Alignment& operator=(
const
Alignment& alignment);
102
Alignment& operator=(Alignment&& alignment) =
default
;
103
108
bool
can_be_aligned
(
const
Region
& region,
AlignPolicy
align_policy)
const
;
109
115
Region
align
(
const
Region
& region,
AlignPolicy
align_policy =
AlignPolicy::ALIGN_START_AND_END
)
const
;
116
117
long
offset()
const
;
118
119
unsigned
long
grain()
const
;
120
121
public
:
122
123
class
Impl;
124
125
Impl& get_impl();
126
const
Impl& get_impl()
const
;
127
128
private
:
129
130
const
std::unique_ptr<Impl> impl;
131
132
};
133
134
}
135
136
137
#endif
storage::Alignment::can_be_aligned
bool can_be_aligned(const Region ®ion, AlignPolicy align_policy) const
Checks whether a region can be aligned.
storage::Alignment::align
Region align(const Region ®ion, AlignPolicy align_policy=AlignPolicy::ALIGN_START_AND_END) const
Aligns a region.
storage::Exception::Exception
Exception(LogLevel log_level=LogLevel::ERROR)
Default constructor.
storage::Region
A start/length pair with a block size.
Definition
Region.h:85
storage::Topology
A class to represent hardware alignment information.
Definition
Topology.h:39
storage
The storage namespace.
Definition
Actiongraph.h:40
storage::AlignType
AlignType
Definition
Alignment.h:37
storage::AlignType::OPTIMAL
@ OPTIMAL
Align to topology information.
Definition
Alignment.h:46
storage::UsedFeaturesDependencyType::REQUIRED
@ REQUIRED
Required used features only include the minimal set of used features.
Definition
UsedFeatures.h:42
storage::AlignPolicy
AlignPolicy
Definition
Alignment.h:51
storage::AlignPolicy::ALIGN_START_AND_END
@ ALIGN_START_AND_END
Align start and end.
Definition
Alignment.h:55
storage::AlignPolicy::ALIGN_START_KEEP_END
@ ALIGN_START_KEEP_END
Align start and keep end.
Definition
Alignment.h:61
storage::AlignPolicy::ALIGN_START_KEEP_SIZE
@ ALIGN_START_KEEP_SIZE
Align start and keep size.
Definition
Alignment.h:67
storage::AlignPolicy::KEEP_START_ALIGN_END
@ KEEP_START_ALIGN_END
Keep start and align end.
Definition
Alignment.h:73
storage
Utils
Alignment.h
Generated by
1.17.0