Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
class_udev_control Class Reference

This class simplifies the implementation of the udev library. More...

#include <udev_control.h>

Public Member Functions

bool AddProperty (string name, string value)
 Add a property pair to the list of properties. More...
 
bool AddSubsystem (string subsystem)
 Add subsystem to the properties. More...
 
 class_udev_control (string id_)
 Constructor. More...
 
bool EnumerateDevices ()
 Enumerate devices. More...
 
string GetId ()
 Get id of the class. More...
 
string GetPath (uint i=0)
 Get the path to the device. More...
 
bool Monitoring ()
 Monitor device. More...
 
bool RegistryAction (string action, void(*callback)(string action, string node, void *data), void *data)
 Registry and action handler. More...
 
bool SetUpMonitoring ()
 Configure monitoring. More...
 
uint size ()
 Get the size of the device list. More...
 
 ~class_udev_control ()
 Destructor. More...
 

Public Attributes

vector< string > device_list
 List of all devices that pass the filter. More...
 
string id
 Id of the class. More...
 

Private Member Functions

bool FilterProperties (struct udev_device *dev_)
 Filter properties. More...
 
string GetProperty (struct udev_device *dev_, string name)
 Get device property. More...
 

Private Attributes

map< string, void(*)(string,
string, void *)> 
actions
 Map of pairs of actions strings and corresponding handler function. More...
 
map< string, void(*)(string,
string, void *)>::iterator 
actions_it
 Map iterator for the actions handler map. More...
 
struct udev_device * dev
 Device auxiliary variable. More...
 
struct udev_list_entry * dev_list_entry
 
struct udev_list_entry * devices
 List entries. More...
 
struct udev_enumerate * enumerate
 Enumerator auxiliary variable. More...
 
int fd
 File descriptor used in the monitoring. More...
 
struct udev_monitor * mon
 Udev monitor. More...
 
map< string, string > properties
 Map of all properties added. More...
 
map< string, string >::iterator properties_it
 Properties map iterator. More...
 
vector< string > sub_systems
 Subsystem vector, these will be used to prefilter the devices. More...
 
struct udev * udev
 Auxiliary variable. More...
 
map< string, void * > user_data
 Map of pairs of actions strings and user data parameters. More...
 

Detailed Description

This class simplifies the implementation of the udev library.

Each instance can only handle one device with a variable size set of rules.
Rules are added with the AddSubsystem() and AddProperty() functions.
The paths to the devices that correspond to the rules are saved in the device_list variable and are accessible via the GetPath() function.

Definition at line 53 of file udev_control.h.

Constructor & Destructor Documentation

class_udev_control::class_udev_control ( string  id_)

Constructor.

The constructor initializes the udev main object. And sets the class id.

Parameters
id_id of this class

Definition at line 28 of file udev_control.cpp.

class_udev_control::~class_udev_control ( )

Destructor.

Unreference the udev main object.

Definition at line 42 of file udev_control.cpp.

Member Function Documentation

bool class_udev_control::AddProperty ( string  name,
string  value 
)

Add a property pair to the list of properties.

This function adds a property name/value pair to the list of all properties that will be used to filter the devices.

Parameters
namename of the property to add
valuevalue of the property
Returns
always true

Definition at line 54 of file udev_control.cpp.

bool class_udev_control::AddSubsystem ( string  subsystem)

Add subsystem to the properties.

This functions adds a subsystem to the filter pairs.

Parameters
subsystemvalue of the subsytem
Returns
always true

Definition at line 65 of file udev_control.cpp.

bool class_udev_control::EnumerateDevices ( )

Enumerate devices.

Enumerate all devices that pass the filter of properties and subsystems.
This is the function that filters devices and makes them available in the list.
Multiple devices with the same set of rules are ordered by minor number (this is a property that all devices share).

Returns
always true

Definition at line 152 of file udev_control.cpp.

bool class_udev_control::FilterProperties ( struct udev_device *  dev_)
private

Filter properties.

This function filters the devices using the properties added.

Parameters
dev_device to filter
Returns
true if the devices passes all the filters or false if not

Definition at line 112 of file udev_control.cpp.

string class_udev_control::GetId ( )
inline

Get id of the class.

Returns
id of the class

Definition at line 196 of file udev_control.h.

string class_udev_control::GetPath ( uint  i = 0)
inline

Get the path to the device.

This function returns the path

Returns
id of the class

Definition at line 207 of file udev_control.h.

string class_udev_control::GetProperty ( struct udev_device *  dev_,
string  name 
)
private

Get device property.

This function reads a device property by its name.

Parameters
dev_device to use
namename of the property
Returns
value of the property

Definition at line 102 of file udev_control.cpp.

bool class_udev_control::Monitoring ( )

Monitor device.

This function monitors the device

Returns
always true

Definition at line 216 of file udev_control.cpp.

bool class_udev_control::RegistryAction ( string  action,
void(*)(string action, string node, void *data)  callback,
void *  data 
)

Registry and action handler.

This functions allows the user to set handler for specific actions on the devices
(remove, add, modify, etc..).

Parameters
actionname of the action
callbackhandler function
datadata to be sent to the handler
Returns
always true

Definition at line 47 of file udev_control.cpp.

bool class_udev_control::SetUpMonitoring ( )

Configure monitoring.

Configure the monitoring, must be called before calling Monitoring().

Returns
always true

Definition at line 72 of file udev_control.cpp.

uint class_udev_control::size ( )
inline

Get the size of the device list.

Returns
size of the device list

Definition at line 187 of file udev_control.h.

Member Data Documentation

map<string,void (*)(string,string,void*)> class_udev_control::actions
private

Map of pairs of actions strings and corresponding handler function.

Definition at line 75 of file udev_control.h.

map<string,void (*)(string,string,void*)>::iterator class_udev_control::actions_it
private

Map iterator for the actions handler map.

Definition at line 79 of file udev_control.h.

struct udev_device* class_udev_control::dev
private

Device auxiliary variable.

Definition at line 63 of file udev_control.h.

struct udev_list_entry * class_udev_control::dev_list_entry
private

Definition at line 61 of file udev_control.h.

vector<string> class_udev_control::device_list

List of all devices that pass the filter.

Definition at line 122 of file udev_control.h.

struct udev_list_entry* class_udev_control::devices
private

List entries.

Definition at line 61 of file udev_control.h.

struct udev_enumerate* class_udev_control::enumerate
private

Enumerator auxiliary variable.

Definition at line 59 of file udev_control.h.

int class_udev_control::fd
private

File descriptor used in the monitoring.

Definition at line 67 of file udev_control.h.

string class_udev_control::id

Id of the class.

Definition at line 119 of file udev_control.h.

struct udev_monitor* class_udev_control::mon
private

Udev monitor.

Definition at line 65 of file udev_control.h.

map<string,string> class_udev_control::properties
private

Map of all properties added.

Definition at line 71 of file udev_control.h.

map<string,string>::iterator class_udev_control::properties_it
private

Properties map iterator.

Definition at line 73 of file udev_control.h.

vector<string> class_udev_control::sub_systems
private

Subsystem vector, these will be used to prefilter the devices.

Definition at line 69 of file udev_control.h.

struct udev* class_udev_control::udev
private

Auxiliary variable.

Definition at line 57 of file udev_control.h.

map<string,void*> class_udev_control::user_data
private

Map of pairs of actions strings and user data parameters.

Definition at line 77 of file udev_control.h.


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


device_mapper
Author(s): Jorge Almeida
autogenerated on Mon Mar 2 2015 01:31:36