libzypp  13.10.6
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  namespace target
27  {
28  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  //
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 */
bool getDevicePropertyBool(const std::string &udi, const std::string &key) const
Definition: HalContext.cc:444
std::vector< std::string > getCdromCapabilityNames() const
Definition: HalContext.cc:812
int32_t getDevicePropertyInt32(const std::string &udi, const std::string &key) const
Definition: HalContext.cc:466
std::string getMountPoint() const
Definition: HalContext.cc:1085
Hardware abstaction layer storage drive object.
Definition: HalContext.h:177
std::vector< std::string > getAllDevices() const
Retrieve UDI&#39;s of all devices.
Definition: HalContext.cc:355
HalDrive getDriveFromUDI(const std::string &udi) const
Construct a HalDrive object for the specified UDI.
Definition: HalContext.cc:377
unsigned int getDeviceMinor() const
Definition: HalContext.cc:792
void setDevicePropertyString(const std::string &udi, const std::string &key, const std::string &value)
Definition: HalContext.cc:653
std::string getDevicePropertyString(const std::string &udi, const std::string &key) const
Definition: HalContext.cc:533
std::string getTypeName() const
Definition: HalContext.cc:761
zypp::RW_pointer< HalDrive_Impl >::unspecified_bool_type bool_type
Definition: HalContext.h:181
zypp::RW_pointer< HalVolume_Impl > v_impl
Definition: HalContext.h:328
uint64_t getDevicePropertyUInt64(const std::string &udi, const std::string &key) const
Definition: HalContext.cc:488
unsigned int getDeviceMajor() const
Definition: HalContext.cc:995
HalVolume & operator=(const HalVolume &volume)
Definition: HalContext.cc:953
std::string getUDI() const
Definition: HalContext.cc:750
Hardware abstaction layer storage volume object.
Definition: HalContext.h:260
HalVolume getVolumeFromUDI(const std::string &udi) const
Construct a HalVolume object for the specified UDI.
Definition: HalContext.cc:391
void setDevicePropertyDouble(const std::string &udi, const std::string &key, double value)
Definition: HalContext.cc:630
std::string getDeviceFile() const
Definition: HalContext.cc:772
void setDevicePropertyInt32(const std::string &udi, const std::string &key, int32_t value)
Definition: HalContext.cc:584
HalContext(bool autoconnect=false)
Definition: HalContext.cc:296
std::string getFSType() const
Definition: HalContext.cc:1045
std::string getFSUsage() const
Definition: HalContext.cc:1055
std::vector< std::string > findDevicesByCapability(const std::string &capability) const
Retrieve UDI&#39;s of all devices with a capability.
Definition: HalContext.cc:420
unsigned int getDeviceMajor() const
Definition: HalContext.cc:782
HalVolume getVolumeFromDeviceFile(const std::string &device_file) const
Definition: HalContext.cc:405
zypp::RW_pointer< HalDrive_Impl > d_impl
Definition: HalContext.h:248
void setDevicePropertyUInt64(const std::string &udi, const std::string &key, uint64_t value)
Definition: HalContext.cc:607
bool usesRemovableMedia() const
Definition: HalContext.cc:802
HalContext & operator=(const HalContext &context)
Definition: HalContext.cc:324
unsigned int getDeviceMinor() const
Definition: HalContext.cc:1005
Hardware abstaction layer library wrapper.
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:265
zypp::RW_pointer< HalVolume_Impl >::unspecified_bool_type bool_type
Definition: HalContext.h:264
zypp::RW_pointer< HalContext_Impl > h_impl
Definition: HalContext.h:165
double getDevicePropertyDouble(const std::string &udi, const std::string &key) const
Definition: HalContext.cc:510
std::vector< std::string > findAllVolumes() const
Retrieve UDI&#39;s of all volumes of this drive.
Definition: HalContext.cc:902
std::string getUDI() const
Definition: HalContext.cc:974
void removeDeviceProperty(const std::string &udi, const std::string &key)
Definition: HalContext.cc:676
void setDevicePropertyBool(const std::string &udi, const std::string &key, bool value)
Definition: HalContext.cc:561
std::string getDeviceFile() const
Definition: HalContext.cc:985
HalDrive & operator=(const HalDrive &drive)
Definition: HalContext.cc:729
zypp::RW_pointer< HalContext_Impl >::unspecified_bool_type bool_type
Definition: HalContext.h:61