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.
PedGeometryped_constraint_solve_max (const PedConstraint *constraint)
 Find the largest region that satisfies a constraint.
PedGeometryped_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

PedConstraint* ped_constraint_duplicate ( const PedConstraint *  constraint  ) 

Duplicate a constraint.

Returns:
NULL on failure.

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.

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

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

Check whether geom satisfies the given constraint.

Returns:
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.

Returns:
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.

Returns:
NULL on failure.

PedConstraint* ped_constraint_new_from_min ( const PedGeometry min  ) 

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

Returns:
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.

Returns:
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.

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


Generated on Fri May 4 05:15:31 2007 for libparted by  doxygen 1.5.2