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         //friend HalMonitor;
00165         HalContext(bool,bool);
00166 
00167         zypp::RW_pointer<HalContext_Impl> h_impl;
00168       };
00169 
00170 
00172       //
00173       // CLASS NAME : HalDrive
00174       //
00179       class HalDrive
00180       {
00181       public:
00182         typedef
00183         zypp::RW_pointer<HalDrive_Impl>::unspecified_bool_type    bool_type;
00184 
00185         HalDrive();
00186         HalDrive(const HalDrive &drive);
00187         ~HalDrive();
00188 
00189         HalDrive&
00190         operator=(const HalDrive &drive);
00191 
00192         operator bool_type() const;
00193 
00194         std::string
00195         getUDI() const;
00196 
00197         std::string
00198         getTypeName() const;
00199 
00203         std::string
00204         getDeviceFile() const;
00205 
00209         unsigned int
00210         getDeviceMajor() const;
00211 
00215         unsigned int
00216         getDeviceMinor() const;
00217 
00221         bool
00222         usesRemovableMedia() const;
00223 
00224         /*
00225         ** Returns the media type names supported by the drive.
00226         **
00227         ** Since hal does not implement a textual form here, we
00228         ** are using the drive type and property names from
00229         ** "storage.cdrom.*" namespace:
00230         **   cdrom, cdr, cdrw, dvd, dvdr, dvdrw, dvdram,
00231         **   dvdplusr, dvdplusrw, dvdplusrdl
00232         **
00233         ** FIXME: Should we provide own LibHalDriveCdromCaps?
00234         */
00235         std::vector<std::string>
00236         getCdromCapabilityNames() const;
00237 
00242         std::vector<std::string>
00243         findAllVolumes() const;
00244 
00245       private:
00246         friend class HalContext;
00247 
00248         HalDrive(HalDrive_Impl *impl);
00249 
00250         zypp::RW_pointer<HalDrive_Impl>   d_impl;
00251       };
00252 
00253 
00255       //
00256       // CLASS NAME : HalVolume
00257       //
00262       class HalVolume
00263       {
00264       public:
00265         typedef
00266         zypp::RW_pointer<HalVolume_Impl>::unspecified_bool_type   bool_type;
00267 
00268         HalVolume();
00269         HalVolume(const HalVolume &volume);
00270         ~HalVolume();
00271 
00272         HalVolume&
00273         operator=(const HalVolume &volume);
00274 
00275         operator bool_type() const;
00276 
00277         std::string
00278         getUDI() const;
00279 
00283         std::string
00284         getDeviceFile() const;
00285 
00289         unsigned int
00290         getDeviceMajor() const;
00291 
00295         unsigned int
00296         getDeviceMinor() const;
00297 
00298         bool
00299         isDisc() const;
00300 
00301         bool
00302         isPartition() const;
00303 
00304         bool
00305         isMounted() const;
00306 
00310         std::string
00311         getFSType() const;
00312 
00316         std::string
00317         getFSUsage() const;
00318 
00322         std::string
00323         getMountPoint() const;
00324 
00325       private:
00326         friend class HalContext;
00327         friend class HalDrive;
00328         HalVolume(HalVolume_Impl *impl);
00329 
00330         zypp::RW_pointer<HalVolume_Impl>  v_impl;
00331       };
00332 
00333 
00335     } // namespace hal
00338   } // namespace target
00341 } // namespace zypp
00343 
00344 #endif // ZYPP_TARGET_HAL_HALCONTEXT_H
00345 
00346 /*
00347 ** vim: set ts=2 sts=2 sw=2 ai et:
00348 */

Generated on Thu Jul 6 00:07:26 2006 for zypp by  doxygen 1.4.6