libstorage-ng
Public Member Functions | Friends | List of all members
storage::Region Class Reference

A start/length pair with a block size. More...

#include <Region.h>

Public Member Functions

 Region (unsigned long long start, unsigned long long length, unsigned int block_size)
 
 Region (const Region &region)
 
 Region (Region &&region)=default
 
Regionoperator= (const Region &region)
 
Regionoperator= (Region &&region)=default
 
bool empty () const
 
unsigned long long get_start () const
 Returns the start of the region.
 
unsigned long long get_length () const
 Returns the length of the region.
 
unsigned long long get_end () const
 Returns the end of the region. More...
 
void set_start (unsigned long long start)
 Sets the start while keeping the length.
 
void set_length (unsigned long long length)
 Sets the length while keeping the start.
 
void adjust_start (long long delta)
 Adjusts the start while keeping the length. More...
 
void adjust_length (long long delta)
 Adjusts the length while keeping the start. More...
 
unsigned int get_block_size () const
 
void set_block_size (unsigned int block_size)
 
unsigned long long to_bytes (unsigned long long blocks) const
 
unsigned long long to_blocks (unsigned long long bytes) const
 
bool operator== (const Region &rhs) const
 Compare start and length of two regions. More...
 
bool operator!= (const Region &rhs) const
 Compare start and length of two regions. More...
 
bool operator< (const Region &rhs) const
 Compare start of two regions. More...
 
bool operator> (const Region &rhs) const
 Compare start of two regions. More...
 
bool operator<= (const Region &rhs) const
 Compare start of two regions. More...
 
bool operator>= (const Region &rhs) const
 Compare start of two regions. More...
 
bool inside (const Region &rhs) const
 Check whether the region is contained inside other. More...
 
bool intersect (const Region &rhs) const
 Check whether the region intersects with other. More...
 
Region intersection (const Region &rhs) const
 
std::vector< Regionunused_regions (const std::vector< Region > &used_regions) const
 Returns all regions not included in used_regions. More...
 
Impl & get_impl ()
 
const Impl & get_impl () const
 

Friends

std::ostream & operator<< (std::ostream &s, const Region &region)
 
bool getChildValue (const xmlNode *node, const char *name, Region &value)
 
void setChildValue (xmlNode *node, const char *name, const Region &value)
 

Detailed Description

A start/length pair with a block size.

The equation end = start + length - 1 holds.

Comparing Regions with different block_sizes will throw an exception.

Member Function Documentation

◆ adjust_length()

void storage::Region::adjust_length ( long long  delta)

Adjusts the length while keeping the start.

Exceptions
Exception

◆ adjust_start()

void storage::Region::adjust_start ( long long  delta)

Adjusts the start while keeping the length.

Exceptions
Exception

◆ get_end()

unsigned long long storage::Region::get_end ( ) const

Returns the end of the region.

Do not use this function if the region is empty since the end can wrap around in that case.

Exceptions
Exception

◆ inside()

bool storage::Region::inside ( const Region rhs) const

Check whether the region is contained inside other.

Exceptions
DifferentBlockSizes

◆ intersect()

bool storage::Region::intersect ( const Region rhs) const

Check whether the region intersects with other.

Exceptions
DifferentBlockSizes

◆ operator!=()

bool storage::Region::operator!= ( const Region rhs) const

Compare start and length of two regions.

Exceptions
DifferentBlockSizes

◆ operator<()

bool storage::Region::operator< ( const Region rhs) const

Compare start of two regions.

Exceptions
DifferentBlockSizes

◆ operator<=()

bool storage::Region::operator<= ( const Region rhs) const

Compare start of two regions.

Exceptions
DifferentBlockSizes

◆ operator==()

bool storage::Region::operator== ( const Region rhs) const

Compare start and length of two regions.

Exceptions
DifferentBlockSizes

◆ operator>()

bool storage::Region::operator> ( const Region rhs) const

Compare start of two regions.

Exceptions
DifferentBlockSizes

◆ operator>=()

bool storage::Region::operator>= ( const Region rhs) const

Compare start of two regions.

Exceptions
DifferentBlockSizes

◆ unused_regions()

std::vector<Region> storage::Region::unused_regions ( const std::vector< Region > &  used_regions) const

Returns all regions not included in used_regions.

All block sizes must be identical.

Exceptions
Exception

The documentation for this class was generated from the following file: