libzypp  17.32.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 #include <utility>
17 
18 #include <zypp/Pathname.h>
19 #include <zypp/base/String.h>
20 #include <zypp/base/PtrTypes.h>
21 
22 
23 namespace zypp {
24  namespace media {
25 
27 
30  using MediaAccessId = unsigned int;
31 
32 
34 
38  {
39  public:
40  MediaSource(std::string _type, std::string _name,
41  unsigned int _maj=0, unsigned int _min=0,
42  std::string _bdir=std::string(), bool _own=true)
43  : maj_nr(_maj)
44  , min_nr(_min)
45  , type(std::move(_type))
46  , name(std::move(_name))
47  , bdir(std::move(_bdir))
48  , iown(_own)
49  {}
50 
52  : maj_nr(0)
53  , min_nr(0)
54  {}
55 
56  virtual
58  {}
59 
63  virtual bool equals(const MediaSource &src) const
64  {
65  if( type == src.type)
66  {
67  if( maj_nr == 0)
68  return name == src.name;
69  else
70  return maj_nr == src.maj_nr &&
71  min_nr == src.min_nr;
72  }
73  return false;
74  }
75 
79  virtual std::string asString() const
80  {
81  std::string tmp1;
82  if(maj_nr != 0)
83  {
84  tmp1 = "[" + str::numstring(maj_nr) + "," +
85  str::numstring(min_nr) + "]";
86  }
87  return type + "<" + name + tmp1 + ">";
88  }
89 
90  unsigned int maj_nr;
91  unsigned int min_nr;
92  std::string type;
93  std::string name;
94  std::string bdir;
95  bool iown;
96  };
97 
99  inline std::ostream & operator<<( std::ostream & str, const MediaSource & obj )
100  { return str << obj.asString(); }
101 
103 
107  {
108  public:
110  bool _temp=true)
111  : path(std::move(_path))
112  , temp(_temp)
113  {}
114 
115  bool empty() const { return path.empty(); }
116 
118  bool temp;
119  };
120 
122  std::ostream & operator<<( std::ostream & str, const AttachPoint & obj );
123 
127 
128 
130 
135  {
137  {}
138 
140  AttachPointRef _attachPoint)
141  : mediaSource(std::move( _mediaSource))
142  , attachPoint(std::move( _attachPoint))
143  {}
144 
147  };
148 
150  std::ostream & operator<<( std::ostream & str, const AttachedMedia & obj );
151 
152  } // namespace media
153 } // namespace zypp
154 
155 
156 #endif // ZYPP_MEDIA_MEDIASOURCE_H
157 
Attach point of a media source.
Definition: MediaSource.h:106
std::ostream & operator<<(std::ostream &str, const MediaHandler &obj)
std::ostream & operator<<(std::ostream &str, const MediaSource &obj)
Definition: MediaSource.h:99
Pathname path
The path name (mount point).
Definition: MediaSource.h:117
unsigned int maj_nr
A major number if source is a device.
Definition: MediaSource.h:90
String related utilities and Regular expression matching.
Definition: Arch.h:363
bool temp
If it was created temporary.
Definition: MediaSource.h:118
std::string name
A media handler specific source name.
Definition: MediaSource.h:93
zypp::Pathname _path
AttachPoint(Pathname _path=Pathname(), bool _temp=true)
Definition: MediaSource.h:109
unsigned int MediaAccessId
Media manager access Id type.
Definition: MediaSource.h:30
bool empty() const
Test for an empty path.
Definition: Pathname.h:114
AttachPointRef attachPoint
Definition: MediaSource.h:146
MediaSourceRef mediaSource
Definition: MediaSource.h:145
A simple structure containing references to a media source and its attach point.
Definition: MediaSource.h:134
std::string type
A media handler specific source type.
Definition: MediaSource.h:92
std::string bdir
Directory, the media may be bound to.
Definition: MediaSource.h:94
std::string numstring(char n, int w=0)
Definition: String.h:289
virtual std::string asString() const
Return media source as string for debuging purposes.
Definition: MediaSource.h:79
Media source internally used by MediaManager and MediaHandler.
Definition: MediaSource.h:37
bool iown
True, if mounted by media manager.
Definition: MediaSource.h:95
AttachedMedia(MediaSourceRef _mediaSource, AttachPointRef _attachPoint)
Definition: MediaSource.h:139
unsigned int min_nr
A minor number if source is a device.
Definition: MediaSource.h:91
virtual bool equals(const MediaSource &src) const
Check if the both sources are equal.
Definition: MediaSource.h:63
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
MediaSource(std::string _type, std::string _name, unsigned int _maj=0, unsigned int _min=0, std::string _bdir=std::string(), bool _own=true)
Definition: MediaSource.h:40