libzypp  17.23.5
MediaSource.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_MEDIA_MEDIASOURCE_H
13 #define ZYPP_MEDIA_MEDIASOURCE_H
14 
15 #include <iosfwd>
16 
17 #include <zypp/Pathname.h>
18 #include <zypp/base/String.h>
19 #include <zypp/base/PtrTypes.h>
20 
21 
22 namespace zypp {
23  namespace media {
24 
26 
29  typedef unsigned int MediaAccessId;
30 
31 
33 
37  {
38  public:
39  MediaSource(const std::string &_type, const std::string &_name,
40  unsigned int _maj=0, unsigned int _min=0,
41  const std::string &_bdir=std::string(), bool _own=true)
42  : maj_nr(_maj)
43  , min_nr(_min)
44  , type(_type)
45  , name(_name)
46  , bdir(_bdir)
47  , iown(_own)
48  {}
49 
51  : maj_nr(0)
52  , min_nr(0)
53  {}
54 
55  virtual
57  {}
58 
62  virtual bool equals(const MediaSource &src) const
63  {
64  if( type == src.type)
65  {
66  if( maj_nr == 0)
67  return name == src.name;
68  else
69  return maj_nr == src.maj_nr &&
70  min_nr == src.min_nr;
71  }
72  return false;
73  }
74 
78  virtual std::string asString() const
79  {
80  std::string tmp1;
81  if(maj_nr != 0)
82  {
83  tmp1 = "[" + str::numstring(maj_nr) + "," +
84  str::numstring(min_nr) + "]";
85  }
86  return type + "<" + name + tmp1 + ">";
87  }
88 
89  unsigned int maj_nr;
90  unsigned int min_nr;
91  std::string type;
92  std::string name;
93  std::string bdir;
94  bool iown;
95  };
96 
98  inline std::ostream & operator<<( std::ostream & str, const MediaSource & obj )
99  { return str << obj.asString(); }
100 
102 
106  {
107  public:
108  AttachPoint(const Pathname &_path=Pathname(),
109  bool _temp=true)
110  : path(_path)
111  , temp(_temp)
112  {}
113 
114  bool empty() const { return path.empty(); }
115 
117  bool temp;
118  };
119 
121  std::ostream & operator<<( std::ostream & str, const AttachPoint & obj );
122 
126 
127 
129 
134  {
136  {}
137 
138  AttachedMedia(const MediaSourceRef &_mediaSource,
139  const AttachPointRef &_attachPoint)
140  : mediaSource( _mediaSource)
141  , attachPoint( _attachPoint)
142  {}
143 
146  };
147 
149  std::ostream & operator<<( std::ostream & str, const AttachedMedia & obj );
150 
151  } // namespace media
152 } // namespace zypp
153 
154 
155 #endif // ZYPP_MEDIA_MEDIASOURCE_H
156 
zypp::media::MediaSource
Media source internally used by MediaManager and MediaHandler.
Definition: MediaSource.h:36
zypp::media::AttachedMedia::mediaSource
MediaSourceRef mediaSource
Definition: MediaSource.h:144
zypp::media::MediaSourceRef
zypp::RW_pointer< MediaSource > MediaSourceRef
Definition: MediaSource.h:124
zypp::media::MediaSource::name
std::string name
A media handler specific source name.
Definition: MediaSource.h:92
PtrTypes.h
Pathname.h
zypp::media::AttachPointRef
zypp::RW_pointer< AttachPoint > AttachPointRef
Definition: MediaSource.h:125
zypp::media::MediaSource::asString
virtual std::string asString() const
Return media source as string for debuging purposes.
Definition: MediaSource.h:78
zypp::media::MediaAccessId
unsigned int MediaAccessId
Media manager access Id type.
Definition: MediaSource.h:29
zypp::media::MediaSource::~MediaSource
virtual ~MediaSource()
Definition: MediaSource.h:56
zypp::media::AttachPoint::temp
bool temp
If it was created temporary.
Definition: MediaSource.h:117
zypp::RW_pointer< MediaSource >
zypp::media::operator<<
std::ostream & operator<<(std::ostream &str, const MediaAccess &obj)
Definition: MediaAccess.cc:481
zypp::media::AttachPoint::path
Pathname path
The path name (mount point).
Definition: MediaSource.h:116
zypp::media::MediaSource::MediaSource
MediaSource()
Definition: MediaSource.h:50
zypp::media::AttachPoint::AttachPoint
AttachPoint(const Pathname &_path=Pathname(), bool _temp=true)
Definition: MediaSource.h:108
zypp::media::AttachedMedia
A simple structure containing references to a media source and its attach point.
Definition: MediaSource.h:133
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::media::AttachedMedia::AttachedMedia
AttachedMedia()
Definition: MediaSource.h:135
zypp::str::numstring
std::string numstring(char n, int w=0)
Definition: String.h:286
zypp::media::AttachPoint
Attach point of a media source.
Definition: MediaSource.h:105
zypp::media::MediaSource::bdir
std::string bdir
Directory, the media may be bound to.
Definition: MediaSource.h:93
zypp::media::AttachedMedia::attachPoint
AttachPointRef attachPoint
Definition: MediaSource.h:145
zypp::media::MediaSource::type
std::string type
A media handler specific source type.
Definition: MediaSource.h:91
zypp::media::MediaSource::equals
virtual bool equals(const MediaSource &src) const
Check if the both sources are equal.
Definition: MediaSource.h:62
zypp::media::MediaSource::MediaSource
MediaSource(const std::string &_type, const std::string &_name, unsigned int _maj=0, unsigned int _min=0, const std::string &_bdir=std::string(), bool _own=true)
Definition: MediaSource.h:39
zypp::filesystem::Pathname::empty
bool empty() const
Test for an empty path.
Definition: Pathname.h:114
zypp::media::AttachPoint::empty
bool empty() const
Definition: MediaSource.h:114
String.h
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:44
zypp::media::MediaSource::iown
bool iown
True, if mounted by media manager.
Definition: MediaSource.h:94
zypp::media::MediaSource::operator<<
std::ostream & operator<<(std::ostream &str, const MediaSource &obj)
Definition: MediaSource.h:98
str
String related utilities and Regular expression matching.
zypp::media::AttachedMedia::AttachedMedia
AttachedMedia(const MediaSourceRef &_mediaSource, const AttachPointRef &_attachPoint)
Definition: MediaSource.h:138
zypp::media::MediaSource::maj_nr
unsigned int maj_nr
A major number if source is a device.
Definition: MediaSource.h:89
zypp::media::MediaSource::min_nr
unsigned int min_nr
A minor number if source is a device.
Definition: MediaSource.h:90