Stop borrowing the constructor to load the LVM2_PV_Info cache (#750582)

An LVM2_PV_Info object contains no member variables as all the data is
static (exists once in the program and accessed by all objects).  The
constructor did nothing, except when passed true to load the cache.

Provide a separate load_cache() member function and remove the
constructors and destructor which do nothing.  The C++ compiler will
provide a default constructor and destructor, which don't do anything as
there are no member variables to initialise and finalise.

This makes the interface a little easier to understand.  Mostly a step
along the way of refactoring how the LVM2_PV_Info cache module works.

Bug 750582 - Refactor the LVM2_PV_Info module object interface and
             internal cache representation
This commit is contained in:
Mike Fleetwood 2015-06-05 19:44:07 +01:00 committed by Curtis Gedak
parent 7a4a375ed6
commit 81f0b934bc
3 changed files with 8 additions and 21 deletions

View File

@ -33,9 +33,7 @@ namespace GParted
class LVM2_PV_Info
{
public:
LVM2_PV_Info() ;
LVM2_PV_Info( bool do_refresh ) ;
~LVM2_PV_Info() ;
static void load_cache();
bool is_lvm2_pv_supported() ;
Glib::ustring get_vg_name( const Glib::ustring & path ) ;
Byte_Value get_size_bytes( const Glib::ustring & path ) ;
@ -46,8 +44,8 @@ public:
std::vector<Glib::ustring> get_error_messages( const Glib::ustring & path ) ;
private:
void initialize_if_required() ;
void set_command_found() ;
void load_lvm2_pv_info_cache() ;
static void set_command_found();
static void load_lvm2_pv_info_cache();
Glib::ustring get_pv_attr_by_path( const Glib::ustring & path, unsigned int entry ) const ;
Glib::ustring get_pv_attr_by_row( unsigned int row, unsigned int entry ) const ;
Glib::ustring get_vg_attr_by_name( const Glib::ustring & vgname, unsigned int entry ) const ;

View File

@ -150,7 +150,7 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
Proc_Partitions_Info pp_info( true ) ; //Refresh cache of proc partition information
FS_Info fs_info( true ) ; //Refresh cache of file system information
DMRaid dmraid( true ) ; //Refresh cache of dmraid device information
LVM2_PV_Info lvm2_pv_info( true ) ; //Refresh cache of LVM2 PV information
LVM2_PV_Info::load_cache(); // Refresh cache of LVM2 PV information
btrfs::clear_cache() ;
init_maps() ;

View File

@ -84,22 +84,11 @@ std::vector<Glib::ustring> LVM2_PV_Info::lvm2_pv_cache ;
std::vector<Glib::ustring> LVM2_PV_Info::lvm2_vg_cache ;
std::vector<Glib::ustring> LVM2_PV_Info::error_messages ;
LVM2_PV_Info::LVM2_PV_Info()
{
}
LVM2_PV_Info::LVM2_PV_Info( bool do_refresh )
{
if ( do_refresh )
{
set_command_found() ;
load_lvm2_pv_info_cache() ;
lvm2_pv_info_cache_initialized = true ;
}
}
LVM2_PV_Info::~LVM2_PV_Info()
void LVM2_PV_Info::load_cache()
{
set_command_found();
load_lvm2_pv_info_cache();
lvm2_pv_info_cache_initialized = true;
}
bool LVM2_PV_Info::is_lvm2_pv_supported()