libzypp  10.5.0
MediaSource.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_MEDIA_MEDIASOURCE_H
00013 #define ZYPP_MEDIA_MEDIASOURCE_H
00014 
00015 #include <iosfwd>
00016 
00017 #include "zypp/Pathname.h"
00018 #include "zypp/base/String.h"
00019 #include "zypp/base/PtrTypes.h"
00020 
00021 
00022 namespace zypp {
00023   namespace media {
00024 
00026 
00029     typedef unsigned int MediaAccessId;
00030 
00031 
00033 
00036     class MediaSource
00037     {
00038     public:
00039       MediaSource(const std::string &_type,  const std::string &_name,
00040                   unsigned int       _maj=0, unsigned int       _min=0,
00041                   const std::string &_bdir=std::string(), bool  _own=true)
00042         : maj_nr(_maj)
00043         , min_nr(_min)
00044         , type(_type)
00045         , name(_name)
00046         , bdir(_bdir)
00047         , iown(_own)
00048       {}
00049 
00050       MediaSource()
00051         : maj_nr(0)
00052         , min_nr(0)
00053       {}
00054 
00055       virtual
00056       ~MediaSource()
00057       {}
00058 
00062       virtual bool equals(const MediaSource &src) const
00063       {
00064         if( type == src.type)
00065         {
00066           if( maj_nr == 0)
00067             return name == src.name;
00068           else
00069             return maj_nr == src.maj_nr &&
00070                    min_nr == src.min_nr;
00071         }
00072         return false;
00073       }
00074 
00078       virtual std::string asString() const
00079       {
00080         std::string tmp1;
00081         if(maj_nr != 0)
00082         {
00083           tmp1 = "[" + str::numstring(maj_nr) + "," +
00084                        str::numstring(min_nr) + "]";
00085         }
00086         return type + "<" + name + tmp1 + ">";
00087       }
00088 
00089       unsigned int maj_nr;  
00090       unsigned int min_nr;  
00091       std::string  type;    
00092       std::string  name;    
00093       std::string  bdir;    
00094       bool         iown;    
00095     };
00096 
00098     inline std::ostream & operator<<( std::ostream & str, const MediaSource & obj )
00099     { return str << obj.asString(); }
00100 
00102 
00105     class AttachPoint
00106     {
00107     public:
00108       AttachPoint(const Pathname &_path=Pathname(),
00109                   bool            _temp=true)
00110         : path(_path)
00111         , temp(_temp)
00112       {}
00113 
00114       bool empty() const { return path.empty(); }
00115 
00116       Pathname path;    
00117       bool     temp;    
00118     };
00119 
00121     std::ostream & operator<<( std::ostream & str, const AttachPoint & obj );
00122 
00124     typedef zypp::RW_pointer<MediaSource> MediaSourceRef;
00125     typedef zypp::RW_pointer<AttachPoint> AttachPointRef;
00126 
00127 
00129 
00133     struct AttachedMedia
00134     {
00135       AttachedMedia()
00136       {}
00137 
00138       AttachedMedia(const MediaSourceRef &_mediaSource,
00139                     const AttachPointRef &_attachPoint)
00140         : mediaSource( _mediaSource)
00141         , attachPoint( _attachPoint)
00142       {}
00143 
00144       MediaSourceRef mediaSource;
00145       AttachPointRef attachPoint;
00146     };
00147 
00149     std::ostream & operator<<( std::ostream & str, const AttachedMedia & obj );
00150 
00151   } // namespace media
00152 } // namespace zypp
00153 
00154 
00155 #endif // ZYPP_MEDIA_MEDIASOURCE_H
00156