The Pedigree Project 0.1
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
DeviceHashTree Class Reference

#include <DeviceHashTree.h>

+ Collaboration diagram for DeviceHashTree:

Public Member Functions

bool initialised ()
 
void fill (Device *root=0)
 
void add (Device *p)
 
Device * getDevice (uint32_t hash)
 
Device * getDevice (const String &hash)
 
size_t getHash (Device *p)
 

Static Public Member Functions

static DeviceHashTree & instance ()
 

Private Attributes

bool m_bInitialised
 
Tree< size_t, Device * > m_DeviceTree
 

Static Private Attributes

static DeviceHashTree m_Instance
 

Detailed Description

DeviceHashTree: Name-based device access

This class provides access to devices via a SHA1 hash generated from several unique identifers of the device. These hashes are deterministic across boots and are therefore ideal for use in addressing devices in userspace scripts or in configuration files.

Definition at line 38 of file DeviceHashTree.h.

Constructor & Destructor Documentation

◆ DeviceHashTree()

DeviceHashTree::DeviceHashTree ( )

Definition at line 30 of file DeviceHashTree.cc.

◆ ~DeviceHashTree()

DeviceHashTree::~DeviceHashTree ( )
virtual

Definition at line 32 of file DeviceHashTree.cc.

Member Function Documentation

◆ add()

void DeviceHashTree::add ( Device *  p)

Adds a device, if it doesn't already exist

Definition at line 47 of file DeviceHashTree.cc.

References Device::dump(), getHash(), Tree< K, E >::insert(), and Tree< K, E >::lookup().

◆ fill()

void DeviceHashTree::fill ( Device *  root = 0)

Fills the hash tree, starting at the given Device and recursively traversing each device with children.

Definition at line 41 of file DeviceHashTree.cc.

References Device::foreach().

◆ getDevice() [1/2]

Device * DeviceHashTree::getDevice ( const String &  hash)

Gets a device from a string hash

Definition at line 66 of file DeviceHashTree.cc.

References Tree< K, E >::lookup().

◆ getDevice() [2/2]

Device * DeviceHashTree::getDevice ( uint32_t  hash)

Gets a device from an integer hash

Definition at line 59 of file DeviceHashTree.cc.

References Tree< K, E >::lookup().

◆ getHash()

size_t DeviceHashTree::getHash ( Device *  p)

Grabs the hash for a given device

Definition at line 75 of file DeviceHashTree.cc.

References Device::dump(), Device::getName(), Device::getPciBusPosition(), Device::getPciDevicePosition(), and Device::getPciFunctionNumber().

Referenced by add().

+ Here is the caller graph for this function:

◆ initialised()

bool DeviceHashTree::initialised ( )
inline

Whether or not the hash tree is ready for use.

Definition at line 48 of file DeviceHashTree.h.

◆ instance()

static DeviceHashTree & DeviceHashTree::instance ( )
inlinestatic

Definition at line 43 of file DeviceHashTree.h.

Member Data Documentation

◆ m_bInitialised

bool DeviceHashTree::m_bInitialised
private

Definition at line 75 of file DeviceHashTree.h.

◆ m_DeviceTree

Tree<size_t, Device*> DeviceHashTree::m_DeviceTree
private

Definition at line 77 of file DeviceHashTree.h.

◆ m_Instance

DeviceHashTree DeviceHashTree::m_Instance
staticprivate

Definition at line 73 of file DeviceHashTree.h.


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