hwdet::Distribution Class Reference

Distribution specific code. More...

#include <Distribution.h>

Inheritance diagram for hwdet::Distribution:

hwdet::MessageReporter hwdet::DefaultDistribution hwdet::FedoraCoreDistribution hwdet::GentooDistribution

Public Member Functions

 Distribution (const String &distro_name, MessageReporter *parent_reporter)
 Construtor.
virtual ~Distribution (void)
 Free all used resources.
String GetName (void) const
 Get name of the distribution.
virtual float GetFitness (void)=0
 Get fitness value for current distro.
virtual bool DetectOS (XMLElement *root_node)=0
 Detect properties of the installed OS.
virtual bool DetectSoftware (XMLElement *products_node)
 Query installed software.
void AddPackager (Packager *packager)
 Add new packager.
PackagerGetPackager (void)
 Find suitable packager.

Protected Attributes

int kernel_major
 Major version of the kernel.
int kernel_minor
 Minor version of the kenrle.
int kernel_release
 Releae number of the kernel.
int kernel_version_code
 Kernel version code.
String uts_name
 Name of the system as determined by uname.
String uts_release
 Release of the system as determined by uname.
String uts_version
 Version of the system as determined by uname.
String uts_machine
 Machine type as determined by uname.
String kernel_version_parsed
 Parsed version of the kernel.

Private Attributes

std::vector< Packager * > packagers
 List of currently registered packagers.
DefaultPackagerdefault_packager
 Default packager.

Detailed Description

Distribution specific code.

This class handles all distribution specific tasks - that is, OS detection and detection of installed software.


Constructor & Destructor Documentation

hwdet::Distribution::Distribution ( const String distro_name,
MessageReporter parent_reporter 
) [inline]

Construtor.

Creates distribution with given name. Name is only informational and is provided only as a means to differentiate log messages. This will also call uname and initialize all const fields with values returned by the call.

Parameters:
distro_name Name used to identify log messages from this class (this does not need to be real name of the distribution).
parent_reporter Reporter that will receive messages reported by this class. Set to NULL to disable message dispatch (messages will be written directly to the stdout).

virtual hwdet::Distribution::~Distribution ( void   )  [inline, virtual]

Free all used resources.

This will automatically free all packagers registered by the user.


Member Function Documentation

void hwdet::Distribution::AddPackager ( Packager packager  )  [inline]

Add new packager.

This will register new packager that can be used to query software installed on the computer. You should always register packagers for given distribution so that the official one is the first one registered and optional packagers come later.

Parameters:
packager Packager to add to the list of the packagers.

virtual bool hwdet::Distribution::DetectOS ( XMLElement root_node  )  [pure virtual]

Detect properties of the installed OS.

This method detects properties of the operating system currently running and stores them in the sub-node of given XML file node.

Parameters:
root_node Root node of the XML file. You should create new OperatingSystem subnode which contains all data you have collected about the OS.
Returns:
true on success, false otherwise.
Note:
Use ReportMessage methods to write all messages. Do not use cout/cerr to write to the standard/error outputs.

Implemented in hwdet::DefaultDistribution, hwdet::FedoraCoreDistribution, and hwdet::GentooDistribution.

virtual bool hwdet::Distribution::DetectSoftware ( XMLElement products_node  )  [inline, virtual]

Query installed software.

This method will query all software installed on the system using appropriate packager and store all data in the given XML file node. Suitable packager handler is chosen with the GetPackager method.

Parameters:
products_node Node which will receive all application data.
Returns:
true on success, false otherwise.

virtual float hwdet::Distribution::GetFitness ( void   )  [pure virtual]

Get fitness value for current distro.

Fitness value is floating-point number in the closed interval [0, 1] which determines how suitable is this class for current operating system. Value of zero means that current OS is not supported by this class at all. Value of one means that current OS is fully supported by the class. You should return 1 only if you are also able to query applications installed on the current system (that is, you have at least one non-default packager that can be used on surrent computer set-up). Fitness value is used to pick most suitable distribution handler from the distribution registry (see DistributionRegistry class).

Returns:
Real number from the closed interval [0, 1] which determines how suitable is this class for current set-up.

Implemented in hwdet::DefaultDistribution, hwdet::FedoraCoreDistribution, and hwdet::GentooDistribution.

String hwdet::Distribution::GetName ( void   )  const [inline]

Get name of the distribution.

Returns:
Name which is used to identify log messages produced by this class. This is not neccessarily name of the actual Linux distro.

Reimplemented from hwdet::MessageReporter.

Packager* hwdet::Distribution::GetPackager ( void   )  [inline]

Find suitable packager.

This will search list of packagers and pick the first one that is suitable for current system set-up. Packager is suitable is its method IsSupported returns true. Packagers are searched in the order they were registered, therefore you can "prioritize" certain packager by registering as the first one.

Returns:
Pointer to the packager that is suitable for current set-up. If no such packager is found, default one will be returned (see DefaultPackager class). You must not free returned pointer by yourself!


Field Documentation

DefaultPackager* hwdet::Distribution::default_packager [private]

Default packager.

int hwdet::Distribution::kernel_major [protected]

Major version of the kernel.

int hwdet::Distribution::kernel_minor [protected]

Minor version of the kenrle.

int hwdet::Distribution::kernel_release [protected]

Releae number of the kernel.

int hwdet::Distribution::kernel_version_code [protected]

Kernel version code.

String hwdet::Distribution::kernel_version_parsed [protected]

Parsed version of the kernel.

std::vector< Packager * > hwdet::Distribution::packagers [private]

List of currently registered packagers.

String hwdet::Distribution::uts_machine [protected]

Machine type as determined by uname.

String hwdet::Distribution::uts_name [protected]

Name of the system as determined by uname.

String hwdet::Distribution::uts_release [protected]

Release of the system as determined by uname.

String hwdet::Distribution::uts_version [protected]

Version of the system as determined by uname.


The documentation for this class was generated from the following file:
Generated on Tue Dec 19 17:43:51 2006 for Detector for Linux by  doxygen 1.4.7