libzypp  10.5.0
HalContext.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00013 #ifndef ZYPP_TARGET_HAL_HALCONTEXT_H
00014 #define ZYPP_TARGET_HAL_HALCONTEXT_H
00015 
00016 #include <zypp/target/hal/HalException.h>
00017 #include <zypp/base/PtrTypes.h>
00018 #include <string>
00019 #include <vector>
00020 #include <stdint.h>
00021 
00023 namespace zypp
00024 { 
00025 
00026   namespace target
00027   { 
00028 
00029     namespace hal
00030     { 
00031 
00032 
00033       // -------------------------------------------------------------
00037       class HalDrive;
00038       class HalVolume;
00039 
00040       class HalDrive_Impl;
00041       class HalVolume_Impl;
00042       class HalContext_Impl;
00046 
00047       //
00048       // CLASS NAME : HalContext
00049       //
00057       class HalContext
00058       {
00059       public:
00060         typedef
00061         zypp::RW_pointer<HalContext_Impl>::unspecified_bool_type  bool_type;
00062 
00063         HalContext(bool autoconnect=false);
00064         HalContext(const HalContext &context);
00065         ~HalContext();
00066 
00067         HalContext&
00068         operator=(const HalContext &context);
00069 
00073         operator bool_type() const;
00074 
00077         void
00078         connect();
00079 
00084         std::vector<std::string>
00085         getAllDevices() const;
00086 
00092         HalDrive
00093         getDriveFromUDI(const std::string &udi) const;
00094 
00100         HalVolume
00101         getVolumeFromUDI(const std::string &udi) const;
00102 
00103         HalVolume
00104         getVolumeFromDeviceFile(const std::string &device_file) const;
00105 
00111         std::vector<std::string>
00112         findDevicesByCapability(const std::string &capability) const;
00113 
00114         bool
00115         getDevicePropertyBool  (const std::string &udi,
00116                                 const std::string &key) const;
00117 
00118         int32_t
00119         getDevicePropertyInt32 (const std::string &udi,
00120                                 const std::string &key) const;
00121 
00122         uint64_t
00123         getDevicePropertyUInt64(const std::string &udi,
00124                                 const std::string &key) const;
00125 
00126         double
00127         getDevicePropertyDouble(const std::string &udi,
00128                                 const std::string &key) const;
00129 
00130         std::string
00131         getDevicePropertyString(const std::string &udi,
00132                                 const std::string &key) const;
00133 
00134         void
00135         setDevicePropertyBool  (const std::string &udi,
00136                                 const std::string &key,
00137                                 bool               value);
00138 
00139         void
00140         setDevicePropertyInt32 (const std::string &udi,
00141                                 const std::string &key,
00142                                 int32_t            value);
00143 
00144         void
00145         setDevicePropertyUInt64(const std::string &udi,
00146                                 const std::string &key,
00147                                 uint64_t           value);
00148 
00149         void
00150         setDevicePropertyDouble(const std::string &udi,
00151                                 const std::string &key,
00152                                 double             value);
00153 
00154         void
00155         setDevicePropertyString(const std::string &udi,
00156                                 const std::string &key,
00157                                 const std::string &value);
00158 
00159         void
00160         removeDeviceProperty(const std::string &udi,
00161                              const std::string &key);
00162 
00163       private:
00164 
00165         zypp::RW_pointer<HalContext_Impl> h_impl;
00166       };
00167 
00168 
00170       //
00171       // CLASS NAME : HalDrive
00172       //
00177       class HalDrive
00178       {
00179       public:
00180         typedef
00181         zypp::RW_pointer<HalDrive_Impl>::unspecified_bool_type    bool_type;
00182 
00183         HalDrive();
00184         HalDrive(const HalDrive &drive);
00185         ~HalDrive();
00186 
00187         HalDrive&
00188         operator=(const HalDrive &drive);
00189 
00190         operator bool_type() const;
00191 
00192         std::string
00193         getUDI() const;
00194 
00195         std::string
00196         getTypeName() const;
00197 
00201         std::string
00202         getDeviceFile() const;
00203 
00207         unsigned int
00208         getDeviceMajor() const;
00209 
00213         unsigned int
00214         getDeviceMinor() const;
00215 
00219         bool
00220         usesRemovableMedia() const;
00221 
00222         /*
00223         ** Returns the media type names supported by the drive.
00224         **
00225         ** Since hal does not implement a textual form here, we
00226         ** are using the drive type and property names from
00227         ** "storage.cdrom.*" namespace:
00228         **   cdrom, cdr, cdrw, dvd, dvdr, dvdrw, dvdram,
00229         **   dvdplusr, dvdplusrw, dvdplusrdl
00230         **
00231         ** FIXME: Should we provide own LibHalDriveCdromCaps?
00232         */
00233         std::vector<std::string>
00234         getCdromCapabilityNames() const;
00235 
00240         std::vector<std::string>
00241         findAllVolumes() const;
00242 
00243       private:
00244         friend class HalContext;
00245 
00246         HalDrive(HalDrive_Impl *impl);
00247 
00248         zypp::RW_pointer<HalDrive_Impl>   d_impl;
00249       };
00250 
00251 
00253       //
00254       // CLASS NAME : HalVolume
00255       //
00260       class HalVolume
00261       {
00262       public:
00263         typedef
00264         zypp::RW_pointer<HalVolume_Impl>::unspecified_bool_type   bool_type;
00265 
00266         HalVolume();
00267         HalVolume(const HalVolume &volume);
00268         ~HalVolume();
00269 
00270         HalVolume&
00271         operator=(const HalVolume &volume);
00272 
00273         operator bool_type() const;
00274 
00275         std::string
00276         getUDI() const;
00277 
00281         std::string
00282         getDeviceFile() const;
00283 
00287         unsigned int
00288         getDeviceMajor() const;
00289 
00293         unsigned int
00294         getDeviceMinor() const;
00295 
00296         bool
00297         isDisc() const;
00298 
00299         bool
00300         isPartition() const;
00301 
00302         bool
00303         isMounted() const;
00304 
00308         std::string
00309         getFSType() const;
00310 
00314         std::string
00315         getFSUsage() const;
00316 
00320         std::string
00321         getMountPoint() const;
00322 
00323       private:
00324         friend class HalContext;
00325         friend class HalDrive;
00326         HalVolume(HalVolume_Impl *impl);
00327 
00328         zypp::RW_pointer<HalVolume_Impl>  v_impl;
00329       };
00330 
00331 
00333     } // namespace hal
00336   } // namespace target
00339 } // namespace zypp
00341 
00342 #endif // ZYPP_TARGET_HAL_HALCONTEXT_H
00343 
00344 /*
00345 ** vim: set ts=2 sts=2 sw=2 ai et:
00346 */