00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PROC_PARTS_H
00024 #define PROC_PARTS_H
00025
00026
00027 #include <string>
00028 #include <list>
00029 #include <map>
00030
00031
00032 namespace storage
00033 {
00034 using std::string;
00035 using std::list;
00036 using std::map;
00037
00038
00039 class ProcParts
00040 {
00041 public:
00042
00043 ProcParts();
00044
00045 void reload();
00046
00047 bool getSize(const string& device, unsigned long long& sizeK) const;
00048 bool findDevice(const string& device) const;
00049
00050 list<string> getEntries() const;
00051
00052 template<class Pred>
00053 list<string> getMatchingEntries(Pred pred) const
00054 {
00055 list<string> ret;
00056 for (const_iterator i = data.begin(); i != data.end(); ++i)
00057 if (pred(i->first))
00058 ret.push_back(i->first);
00059 return ret;
00060 }
00061
00062 protected:
00063
00064 typedef map<string, unsigned long long>::const_iterator const_iterator;
00065
00066 const_iterator findEntry(const string& device) const;
00067
00068 map<string, unsigned long long> data;
00069
00070 };
00071
00072 }
00073
00074
00075 #endif