libparted 3.6
|
Constraint solver interface. More...
Functions | |
PedConstraint * | ped_constraint_any (const PedDevice *dev) |
Return a constraint that any region on the given device will satisfy. | |
void | ped_constraint_destroy (PedConstraint *constraint) |
Release the memory allocated for a PedConstraint constructed with ped_constraint_new(). | |
void | ped_constraint_done (PedConstraint *constraint) |
Release the memory allocated for a PedConstraint constructed with ped_constraint_init(). | |
PedConstraint * | ped_constraint_duplicate (const PedConstraint *constraint) |
Duplicate a constraint. | |
PedConstraint * | ped_constraint_exact (const PedGeometry *geom) |
Return a constraint that only the given region will satisfy. | |
int | ped_constraint_init (PedConstraint *constraint, const PedAlignment *start_align, const PedAlignment *end_align, const PedGeometry *start_range, const PedGeometry *end_range, PedSector min_size, PedSector max_size) |
Initializes a pre-allocated piece of memory to contain a constraint with the supplied default values. | |
PedConstraint * | ped_constraint_intersect (const PedConstraint *a, const PedConstraint *b) |
Return a constraint that requires a region to satisfy both a and b . | |
int | ped_constraint_is_solution (const PedConstraint *constraint, const PedGeometry *geom) |
Check whether geom satisfies the given constraint. | |
PedConstraint * | ped_constraint_new (const PedAlignment *start_align, const PedAlignment *end_align, const PedGeometry *start_range, const PedGeometry *end_range, PedSector min_size, PedSector max_size) |
Convenience wrapper for ped_constraint_init(). | |
PedConstraint * | ped_constraint_new_from_max (const PedGeometry *max) |
Return a constraint that requires a region to be entirely contained inside max . | |
PedConstraint * | ped_constraint_new_from_min (const PedGeometry *min) |
Return a constraint that requires a region to entirely contain min . | |
PedConstraint * | ped_constraint_new_from_min_max (const PedGeometry *min, const PedGeometry *max) |
Return a constraint that requires a region to be entirely contained inside max , and to entirely contain min . | |
PedGeometry * | ped_constraint_solve_max (const PedConstraint *constraint) |
Find the largest region that satisfies a constraint. | |
PedGeometry * | ped_constraint_solve_nearest (const PedConstraint *constraint, const PedGeometry *geom) |
Return the nearest region to geom that satisfy a constraint . | |
Constraint solver interface.
Constraints are used to communicate restrictions on operations Constraints are restrictions on the location and alignment of the start and end of a partition, and the minimum and maximum size.
Constraints are closed under intersection (for the proof see the source code). For background information see the Chinese Remainder Theorem.
This interface consists of construction constraints, finding the intersection of constraints, and finding solutions to constraints.
The constraint solver allows you to specify constraints on where a partition or file system (or any PedGeometry) may be placed/resized/etc. For example, you might want to make sure that a file system is at least 10 Gb, or that it starts at the beginning of new cylinder.
The constraint solver in this file unifies solver in geom.c (which allows you to specify constraints on ranges) and natmath.c (which allows you to specify alignment constraints).
PedConstraint * ped_constraint_any | ( | const PedDevice * | dev | ) |
Return a constraint that any region on the given device will satisfy.
void ped_constraint_destroy | ( | PedConstraint * | constraint | ) |
Release the memory allocated for a PedConstraint constructed with ped_constraint_new().
void ped_constraint_done | ( | PedConstraint * | constraint | ) |
Release the memory allocated for a PedConstraint constructed with ped_constraint_init().
PedConstraint * ped_constraint_duplicate | ( | const PedConstraint * | constraint | ) |
Duplicate a constraint.
NULL
on failure. PedConstraint * ped_constraint_exact | ( | const PedGeometry * | geom | ) |
Return a constraint that only the given region will satisfy.
int ped_constraint_init | ( | PedConstraint * | constraint, |
const PedAlignment * | start_align, | ||
const PedAlignment * | end_align, | ||
const PedGeometry * | start_range, | ||
const PedGeometry * | end_range, | ||
PedSector | min_size, | ||
PedSector | max_size | ||
) |
Initializes a pre-allocated piece of memory to contain a constraint with the supplied default values.
0
on failure. PedConstraint * ped_constraint_intersect | ( | const PedConstraint * | a, |
const PedConstraint * | b | ||
) |
Return a constraint that requires a region to satisfy both a
and b
.
Moreover, any region satisfying a
and b
will also satisfy the returned constraint.
NULL
if no solution could be found (note that NULL
is a valid PedConstraint). int ped_constraint_is_solution | ( | const PedConstraint * | constraint, |
const PedGeometry * | geom | ||
) |
Check whether geom
satisfies the given constraint.
1
if it does. PedConstraint * ped_constraint_new | ( | const PedAlignment * | start_align, |
const PedAlignment * | end_align, | ||
const PedGeometry * | start_range, | ||
const PedGeometry * | end_range, | ||
PedSector | min_size, | ||
PedSector | max_size | ||
) |
Convenience wrapper for ped_constraint_init().
Allocates a new piece of memory and initializes the constraint.
NULL
on failure. PedConstraint * ped_constraint_new_from_max | ( | const PedGeometry * | max | ) |
Return a constraint that requires a region to be entirely contained inside max
.
NULL
on failure. PedConstraint * ped_constraint_new_from_min | ( | const PedGeometry * | min | ) |
Return a constraint that requires a region to entirely contain min
.
NULL
on failure. PedConstraint * ped_constraint_new_from_min_max | ( | const PedGeometry * | min, |
const PedGeometry * | max | ||
) |
Return a constraint that requires a region to be entirely contained inside max
, and to entirely contain min
.
NULL
on failure. PedGeometry * ped_constraint_solve_max | ( | const PedConstraint * | constraint | ) |
Find the largest region that satisfies a constraint.
There might be more than one solution. This function makes no guarantees about which solution it will choose in this case.
PedGeometry * ped_constraint_solve_nearest | ( | const PedConstraint * | constraint, |
const PedGeometry * | geom | ||
) |
Return the nearest region to geom
that satisfy a constraint
.
Note that "nearest" is somewhat ambiguous. This function makes no guarantees about how this ambiguity is resovled.
constrain
cannot be satisfied