#include <Distribution.h>
Inheritance diagram for hwdet::Distribution:
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. | |
Packager * | GetPackager (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. | |
DefaultPackager * | default_packager |
Default packager. |
This class handles all distribution specific tasks - that is, OS detection and detection of installed software.
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.
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.
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.
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.
root_node | Root node of the XML file. You should create new OperatingSystem subnode which contains all data you have collected about the OS. |
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.
products_node | Node which will receive all application data. |
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).
Implemented in hwdet::DefaultDistribution, hwdet::FedoraCoreDistribution, and hwdet::GentooDistribution.
String hwdet::Distribution::GetName | ( | void | ) | const [inline] |
Get name of the distribution.
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.
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
.