[Kde-hardware-devel] Examples

Kevin Ottens ervin at kde.org
Mon Sep 4 09:42:41 CEST 2006


Le lundi 4 septembre 2006 08:40, Karlos a écrit :
> Here is a pair of examples of cpu monitoring capabilities.

Looks sane as a first shot. A few comments though:

 - You probably want getUsage() to return a QMap, avoiding to mess with a 
pointer argument (we don't want people to shoot in their own foot here), and 
returning an empty QMap on error.

 - An enum type describing the type of information returned is probably 
welcome (let's name it ProcessorUsageType). So instead of QMap<QString,float> 
you would return QMap<ProcessorUsageType,float>. It would provide more 
typechecking and give a clear idea of the keys you can retrieve from the map.

 - My previous comment would lead to having this enum type shared accross all 
implementations. Currently you have the ("user", "nice", "system", "idle",
"iowait", "hw_irq", "sw_interr" keyset for Linux and the ("user", "nice", 
"system", "idle", "interrupt") keyset for FreeBSD. So the enum should be a 
common naming for both, and FreeBSD would probably use only a subset of it. 
Maybe something like:
enum ProcessorUsageType { User, Nice, System, Idle, IoWait, Irq, 
SwInterrupt };
Linux implementation would use the full set, and FreeBSD only User, Nice, 
System, Idle and SwInterrupt. Note that I'm assuming that "sw_interrupt" 
and "interrupt" have the same meaning on both system, which migh be wrong. In 
such a case we probably want to do it differently, but you get the idea.

 - Be careful of your indenting I've found at least a line indented using a 
tab instead of four spaces.

 - Nitpicking: I'd prefer it you don't indent braces (as in your for loops for 
example). Agreed it's a matter of personal taste, but I'd like to somewhat 
keep it consistent in the library and you're the only one having this type of 
brace placing.

I also have a few questions regarding where you want to go from here:
1) Are you intending to implement memory related information?
2) If yes, don't you think it would be better to have a "SysInfo" class 
instead having the relevant methods? I see "Processor" has only a getUsage() 
method and I think it'll be similar for memory, etc. Maybe we want a better 
name than "SysInfo" though.

Regards.
-- 
Kévin 'ervin' Ottens, http://ervin.ipsquad.net
"Ni le maître sans disciple, Ni le disciple sans maître,
Ne font reculer l'ignorance."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-hardware-devel/attachments/20060904/c5c40419/attachment.pgp 


More information about the Kde-hardware-devel mailing list