Thrill  0.1

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 ()
 
virtual void load_config_file (const std::string &config_path)
 Load disk configuration file. More...
 
virtual void load_default_config ()
 Load default configuration. More...
 
configadd_disk (const disk_config &cfg)
 
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
 
virtual std::string default_disk_path ()
 
virtual std::string default_disk_io_impl ()
 Returns name of the default I/O implementation. More...
 
virtual std::string default_config_file_name ()
 returns the name of the default config file prefix More...
 
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...
 
- 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...
 

Protected Member Functions

 config ()
 Constructor: this must be inlined to print the header version string. More...
 
virtual ~config ()
 deletes autogrow files More...
 
virtual void find_config ()
 Search several places for a config file. More...
 
virtual void initialize ()
 

Private Types

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

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

Additional Inherited Members

- Public Types inherited from singleton< config >
using instance_pointer = instance_type *
 
using instance_type = config
 
using volatile_instance_pointer = volatile instance_pointer
 
- Static Public Member Functions inherited from singleton< config >
static instance_pointer create_instance ()
 create instance of SubInstanceType and move into singleton More...
 
static void destroy_instance ()
 destroy singleton and mark as invalid More...
 
static instance_pointer get_instance ()
 return instance or create base instance if empty More...
 
static instance_typeget_ref ()
 

Member Typedef Documentation

◆ disk_list_type

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

config ( )
protected

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

Definition at line 49 of file config.cpp.

◆ ~config()

~config ( )
protectedvirtual

deletes autogrow files

Definition at line 53 of file config.cpp.

References config::disks_list, and TLX_LOG1.

Member Function Documentation

◆ add_disk()

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 181 of file config.cpp.

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

Referenced by config::load_default_config().

◆ check_initialized()

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.

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

◆ default_config_file_name()

std::string default_config_file_name ( )
virtual

returns the name of the default config file prefix

Definition at line 256 of file config.cpp.

Referenced by config::find_config().

◆ default_disk_io_impl()

std::string default_disk_io_impl ( )
virtual

Returns name of the default I/O implementation.

Definition at line 247 of file config.cpp.

Referenced by config::load_default_config().

◆ default_disk_path()

std::string default_disk_path ( )
virtual

Returns default path of disk.

Returns
string that contains the disk's path name

Definition at line 232 of file config.cpp.

Referenced by config::load_default_config().

◆ disk() [1/2]

disk_config & disk ( size_t  disk)

Returns mutable disk_config structure for additional disk parameters.

Definition at line 219 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().

◆ disk() [2/2]

const disk_config& disk ( size_t  disk) const

Returns constant disk_config structure for additional disk parameters.

◆ disk_io_impl()

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 267 of file config.cpp.

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

◆ disk_path()

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 226 of file config.cpp.

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

◆ disk_size()

external_size_type disk_size ( size_t  disk) const

Returns disk size.

Parameters
diskdisk's identifier
Returns
disk size in bytes

Definition at line 261 of file config.cpp.

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

◆ disks_number()

size_t disks_number ( )
inline

◆ find_config()

void find_config ( )
protectedvirtual

Search several places for a config file.

Definition at line 84 of file config.cpp.

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

Referenced by config::initialize().

◆ flash_range()

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 211 of file config.cpp.

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

◆ initialize()

void initialize ( )
protectedvirtual

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 66 of file config.cpp.

References config::disks_list, config::find_config(), config::first_flash, foxxll::get_version_string_long(), config::is_initialized, config::max_device_id_, foxxll::print_library_version_mismatch(), and TLX_LOG1.

◆ load_config_file()

void load_config_file ( const std::string &  config_path)
virtual

Load disk configuration file.

Definition at line 144 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().

◆ load_default_config()

void load_default_config ( )
virtual

◆ max_device_id()

unsigned int max_device_id ( )

Returns automatic physical device id counter.

Definition at line 189 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().

◆ next_device_id()

unsigned int next_device_id ( )

Returns next automatic physical device id counter.

Definition at line 194 of file config.cpp.

References config::max_device_id_.

Referenced by foxxll::create_file().

◆ regular_disk_range()

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 205 of file config.cpp.

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

◆ total_size()

external_size_type total_size ( ) const

Returns the total size over all disks.

Definition at line 273 of file config.cpp.

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

◆ update_max_device_id()

void update_max_device_id ( unsigned int  devid)

Update the automatic physical device id counter.

Definition at line 199 of file config.cpp.

References config::max_device_id_.

Referenced by foxxll::create_file().

Member Data Documentation

◆ disks_list

◆ first_flash

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::add_disk(), config::flash_range(), config::initialize(), config::load_config_file(), and config::regular_disk_range().

◆ is_initialized

bool is_initialized
private

◆ max_device_id_

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: