libzypp  11.13.5
HalContext.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
13 #ifndef ZYPP_TARGET_HAL_HALCONTEXT_H
14 #define ZYPP_TARGET_HAL_HALCONTEXT_H
15 
17 #include "zypp/base/PtrTypes.h"
18 #include <string>
19 #include <vector>
20 #include <stdint.h>
21 
23 namespace zypp
24 {
25 
26  namespace target
27  {
28 
29  namespace hal
30  {
31 
32 
33  // -------------------------------------------------------------
37  class HalDrive;
38  class HalVolume;
39 
40  class HalDrive_Impl;
41  class HalVolume_Impl;
42  class HalContext_Impl;
46 
47  //
48  // CLASS NAME : HalContext
49  //
57  class HalContext
58  {
59  public:
60  typedef
62 
63  HalContext(bool autoconnect=false);
64  HalContext(const HalContext &context);
65  ~HalContext();
66 
67  HalContext&
68  operator=(const HalContext &context);
69 
73  operator bool_type() const;
74 
77  void
78  connect();
79 
84  std::vector<std::string>
85  getAllDevices() const;
86 
92  HalDrive
93  getDriveFromUDI(const std::string &udi) const;
94 
100  HalVolume
101  getVolumeFromUDI(const std::string &udi) const;
102 
103  HalVolume
104  getVolumeFromDeviceFile(const std::string &device_file) const;
105 
111  std::vector<std::string>
112  findDevicesByCapability(const std::string &capability) const;
113 
114  bool
115  getDevicePropertyBool (const std::string &udi,
116  const std::string &key) const;
117 
118  int32_t
119  getDevicePropertyInt32 (const std::string &udi,
120  const std::string &key) const;
121 
122  uint64_t
123  getDevicePropertyUInt64(const std::string &udi,
124  const std::string &key) const;
125 
126  double
127  getDevicePropertyDouble(const std::string &udi,
128  const std::string &key) const;
129 
130  std::string
131  getDevicePropertyString(const std::string &udi,
132  const std::string &key) const;
133 
134  void
135  setDevicePropertyBool (const std::string &udi,
136  const std::string &key,
137  bool value);
138 
139  void
140  setDevicePropertyInt32 (const std::string &udi,
141  const std::string &key,
142  int32_t value);
143 
144  void
145  setDevicePropertyUInt64(const std::string &udi,
146  const std::string &key,
147  uint64_t value);
148 
149  void
150  setDevicePropertyDouble(const std::string &udi,
151  const std::string &key,
152  double value);
153 
154  void
155  setDevicePropertyString(const std::string &udi,
156  const std::string &key,
157  const std::string &value);
158 
159  void
160  removeDeviceProperty(const std::string &udi,
161  const std::string &key);
162 
163  private:
164 
166  };
167 
168 
170  //
171  // CLASS NAME : HalDrive
172  //
177  class HalDrive
178  {
179  public:
180  typedef
182 
183  HalDrive();
184  HalDrive(const HalDrive &drive);
185  ~HalDrive();
186 
187  HalDrive&
188  operator=(const HalDrive &drive);
189 
190  operator bool_type() const;
191 
192  std::string
193  getUDI() const;
194 
195  std::string
196  getTypeName() const;
197 
201  std::string
202  getDeviceFile() const;
203 
207  unsigned int
208  getDeviceMajor() const;
209 
213  unsigned int
214  getDeviceMinor() const;
215 
219  bool
220  usesRemovableMedia() const;
221 
222  /*
223  ** Returns the media type names supported by the drive.
224  **
225  ** Since hal does not implement a textual form here, we
226  ** are using the drive type and property names from
227  ** "storage.cdrom.*" namespace:
228  ** cdrom, cdr, cdrw, dvd, dvdr, dvdrw, dvdram,
229  ** dvdplusr, dvdplusrw, dvdplusrdl
230  **
231  ** FIXME: Should we provide own LibHalDriveCdromCaps?
232  */
233  std::vector<std::string>
234  getCdromCapabilityNames() const;
235 
240  std::vector<std::string>
241  findAllVolumes() const;
242 
243  private:
244  friend class HalContext;
245 
246  HalDrive(HalDrive_Impl *impl);
247 
249  };
250 
251 
253  //
254  // CLASS NAME : HalVolume
255  //
260  class HalVolume
261  {
262  public:
263  typedef
265 
266  HalVolume();
267  HalVolume(const HalVolume &volume);
268  ~HalVolume();
269 
270  HalVolume&
271  operator=(const HalVolume &volume);
272 
273  operator bool_type() const;
274 
275  std::string
276  getUDI() const;
277 
281  std::string
282  getDeviceFile() const;
283 
287  unsigned int
288  getDeviceMajor() const;
289 
293  unsigned int
294  getDeviceMinor() const;
295 
296  bool
297  isDisc() const;
298 
299  bool
300  isPartition() const;
301 
302  bool
303  isMounted() const;
304 
308  std::string
309  getFSType() const;
310 
314  std::string
315  getFSUsage() const;
316 
320  std::string
321  getMountPoint() const;
322 
323  private:
324  friend class HalContext;
325  friend class HalDrive;
326  HalVolume(HalVolume_Impl *impl);
327 
329  };
330 
331 
333  } // namespace hal
336  } // namespace target
339 } // namespace zypp
341 
342 #endif // ZYPP_TARGET_HAL_HALCONTEXT_H
343 
344 /*
345 ** vim: set ts=2 sts=2 sw=2 ai et:
346 */