Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
config Class Reference

Detailed Description

Access point to disks properties. Since 1.4.0: no config files are read automatically!

Remarks
is a singleton

Definition at line 114 of file config.hpp.

+ Inheritance diagram for config:
+ Collaboration diagram for config:

#include <config.hpp>

Public Member Functions

Initialization Functions
void check_initialized ()
 
void load_config_file (const std::string &config_path)
 Load disk configuration file. More...
 
void load_default_config ()
 Load default configuration. More...
 
configadd_disk (const disk_config &cfg)
 
- Public Member Functions inherited from singleton< config >
 singleton ()=default
 
 singleton (const singleton &)=delete
 non-copyable: delete copy-constructor More...
 
singletonoperator= (const singleton &)=delete
 non-copyable: delete assignment operator More...
 

Private Types

using disk_list_type = std::vector< disk_config >
 typedef of list of configured disks More...
 

Private Member Functions

 config ()
 
 ~config ()
 deletes autogrow files More...
 
void find_config ()
 Search several places for a config file. More...
 
void initialize ()
 

Private Attributes

disk_list_type disks_list
 list of configured disks More...
 
unsigned first_flash
 In disks_list, flash devices come after all regular disks. More...
 
bool is_initialized
 Finished initializing config. More...
 

Automatic Disk Enumeration Functions

unsigned int max_device_id_
 static counter for automatic physical device enumeration More...
 
unsigned int max_device_id ()
 Returns automatic physical device id counter. More...
 
unsigned int next_device_id ()
 Returns next automatic physical device id counter. More...
 
void update_max_device_id (unsigned int devid)
 Update the automatic physical device id counter. More...
 

Query Functions

size_t disks_number ()
 
std::pair< unsigned, unsigned > regular_disk_range () const
 Returns contiguous range of regular disks w/o flash devices in the array of all disks. More...
 
std::pair< unsigned, unsigned > flash_range () const
 
disk_configdisk (size_t disk)
 Returns mutable disk_config structure for additional disk parameters. More...
 
const disk_configdisk (size_t disk) const
 Returns constant disk_config structure for additional disk parameters. More...
 
const std::string & disk_path (size_t disk) const
 
external_size_type disk_size (size_t disk) const
 
const std::string & disk_io_impl (size_t disk) const
 
external_size_type total_size () const
 Returns the total size over all disks. More...
 
static std::string default_disk_path ()
 
static std::string default_disk_io_impl ()
 Returns name of the default I/O implementation. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from singleton< config >
static instance_pointer get_instance ()
 
static instance_typeget_ref ()
 

Member Typedef Documentation

using disk_list_type = std::vector<disk_config>
private

typedef of list of configured disks

Definition at line 119 of file config.hpp.

Constructor & Destructor Documentation

config ( )
private

Constructor: this must be inlined to print the header version string.

Definition at line 49 of file config.cpp.

References foxxll::get_version_string_long(), LOG1, and foxxll::print_library_version_mismatch().

~config ( )
private

deletes autogrow files

Definition at line 56 of file config.cpp.

References config::disks_list, and LOG1.

Member Function Documentation

config & add_disk ( const disk_config cfg)

Add a disk to the configuration list.

Warning
This function should only be used during initialization, as it has no effect after construction of block_manager.

Definition at line 180 of file config.cpp.

References config::disks_list.

void check_initialized ( )
inline

Check that initialize() was called.

Note
This function need not be called by the user, block_manager will always call it.

Definition at line 151 of file config.hpp.

References config::initialize(), and config::is_initialized.

Referenced by block_manager::block_manager(), config::disk(), and config::disks_number().

std::string default_disk_io_impl ( )
static

Returns name of the default I/O implementation.

Definition at line 254 of file config.cpp.

Referenced by config::load_default_config().

std::string default_disk_path ( )
static

Returns default path of disk.

Returns
string that contains the disk's path name

Definition at line 227 of file config.cpp.

Referenced by config::load_default_config().

disk_config & disk ( size_t  disk)

Returns mutable disk_config structure for additional disk parameters.

Definition at line 214 of file config.cpp.

References config::check_initialized(), and config::disks_list.

Referenced by block_manager::block_manager(), config::disk_io_impl(), config::disk_path(), and config::disk_size().

const disk_config& disk ( size_t  disk) const

Returns constant disk_config structure for additional disk parameters.

const std::string & disk_io_impl ( size_t  disk) const

Returns name of I/O implementation of particular disk.

Parameters
diskdisk's identifier

Definition at line 248 of file config.cpp.

References config::disk(), config::disks_list, and config::is_initialized.

const std::string & disk_path ( size_t  disk) const

Returns path of disks.

Parameters
diskdisk's identifier
Returns
string that contains the disk's path name

Definition at line 221 of file config.cpp.

References config::disk(), config::disks_list, and config::is_initialized.

external_size_type disk_size ( size_t  disk) const

Returns disk size.

Parameters
diskdisk's identifier
Returns
disk size in bytes

Definition at line 242 of file config.cpp.

References config::disk(), config::disks_list, and config::is_initialized.

size_t disks_number ( )
inline
void find_config ( )
private

Search several places for a config file.

Definition at line 82 of file config.cpp.

References foxxll::exist_file(), config::load_config_file(), and config::load_default_config().

Referenced by config::initialize().

std::pair< unsigned, unsigned > flash_range ( ) const

Returns contiguous range of flash devices in the array of all disks.

Returns
range [begin, end) of flash device indices

Definition at line 208 of file config.cpp.

References config::disks_list, config::first_flash, and config::is_initialized.

void initialize ( )
private

If disk list is empty, then search different locations for a disk configuration file, or load a default config if everything fails.

Definition at line 69 of file config.cpp.

References config::disks_list, config::find_config(), config::is_initialized, and config::max_device_id_.

Referenced by config::check_initialized().

void load_config_file ( const std::string &  config_path)

Load disk configuration file.

Definition at line 143 of file config.cpp.

References config::disks_list, config::first_flash, disk_config::flash, FOXXLL_THROW, config::load_default_config(), and disk_config::parse_line().

Referenced by config::find_config().

void load_default_config ( )
unsigned int max_device_id ( )

Returns automatic physical device id counter.

Definition at line 186 of file config.cpp.

References config::max_device_id_.

Referenced by buf_istream< BlockType, BidIteratorType >::buf_istream(), and buf_istream_reverse< BlockType, BidIteratorType >::buf_istream_reverse().

unsigned int next_device_id ( )

Returns next automatic physical device id counter.

Definition at line 191 of file config.cpp.

References config::max_device_id_.

Referenced by foxxll::create_file().

std::pair< unsigned, unsigned > regular_disk_range ( ) const

Returns contiguous range of regular disks w/o flash devices in the array of all disks.

Returns
range [begin, end) of regular disk indices

Definition at line 202 of file config.cpp.

References config::first_flash, and config::is_initialized.

external_size_type total_size ( ) const

Returns the total size over all disks.

Definition at line 263 of file config.cpp.

References config::disks_list, and config::is_initialized.

void update_max_device_id ( unsigned int  devid)

Update the automatic physical device id counter.

Definition at line 196 of file config.cpp.

References config::max_device_id_.

Referenced by foxxll::create_file().

Member Data Documentation

unsigned first_flash
private

In disks_list, flash devices come after all regular disks.

Definition at line 125 of file config.hpp.

Referenced by config::flash_range(), config::load_config_file(), config::load_default_config(), and config::regular_disk_range().

unsigned int max_device_id_
protected

static counter for automatic physical device enumeration

Definition at line 175 of file config.hpp.

Referenced by config::initialize(), config::max_device_id(), config::next_device_id(), and config::update_max_device_id().


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