Loading...
Searching...
No Matches
PedConstraint

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`.

## Detailed Description

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).

## Function Documentation

## ped_constraint_any()

PedConstraint * ped_constraint_any | ( | const PedDevice * | dev | ) |

Return a constraint that any region on the given device will satisfy.

## ped_constraint_destroy()

void ped_constraint_destroy | ( | PedConstraint * | constraint | ) |

Release the memory allocated for a PedConstraint constructed with ped_constraint_new().

## ped_constraint_done()

void ped_constraint_done | ( | PedConstraint * | constraint | ) |

Release the memory allocated for a PedConstraint constructed with ped_constraint_init().

## ped_constraint_duplicate()

PedConstraint * ped_constraint_duplicate | ( | const PedConstraint * | constraint | ) |

Duplicate a constraint.

Returns
  `NULL` on failure.

## ped_constraint_exact()

PedConstraint * ped_constraint_exact | ( | const PedGeometry * | geom | ) |

Return a constraint that only the given region will satisfy.

## ped_constraint_init()

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.

Returns
  `0` on failure.

## ped_constraint_intersect()

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.

Returns
  `NULL` if no solution could be found (note that `NULL` is a valid PedConstraint).

## ped_constraint_is_solution()

int ped_constraint_is_solution | ( | const PedConstraint * | constraint,
|  | const PedGeometry * | geom )

Check whether `geom` satisfies the given constraint.

Returns
  `1` if it does.

## ped_constraint_new()

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.

Returns
  `NULL` on failure.

## ped_constraint_new_from_max()

PedConstraint * ped_constraint_new_from_max | ( | const PedGeometry * | max | ) |

Return a constraint that requires a region to be entirely contained inside `max`.

Returns
  `NULL` on failure.

## ped_constraint_new_from_min()

PedConstraint * ped_constraint_new_from_min | ( | const PedGeometry * | min | ) |

Return a constraint that requires a region to entirely contain `min`.

Returns
  `NULL` on failure.

## ped_constraint_new_from_min_max()

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`.

Returns
  `NULL` on failure.

## ped_constraint_solve_max()

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.

## ped_constraint_solve_nearest()

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.

Returns
  PedGeometry, or NULL when a `constrain` cannot be satisfied