libzypp 17.31.7
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
22namespace 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) + "," +
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:
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
bool empty() const
Test for an empty path.
Definition: Pathname.h:114
Attach point of a media source.
Definition: MediaSource.h:106
Pathname path
The path name (mount point).
Definition: MediaSource.h:116
AttachPoint(const Pathname &_path=Pathname(), bool _temp=true)
Definition: MediaSource.h:108
bool temp
If it was created temporary.
Definition: MediaSource.h:117
Media source internally used by MediaManager and MediaHandler.
Definition: MediaSource.h:37
std::ostream & operator<<(std::ostream &str, const MediaSource &obj)
Stream output.
Definition: MediaSource.h:98
unsigned int min_nr
A minor number if source is a device.
Definition: MediaSource.h:90
std::string type
A media handler specific source type.
Definition: MediaSource.h:91
unsigned int maj_nr
A major number if source is a device.
Definition: MediaSource.h:89
bool iown
True, if mounted by media manager.
Definition: MediaSource.h:94
std::string name
A media handler specific source name.
Definition: MediaSource.h:92
virtual std::string asString() const
Return media source as string for debuging purposes.
Definition: MediaSource.h:78
std::string bdir
Directory, the media may be bound to.
Definition: MediaSource.h:93
virtual bool equals(const MediaSource &src) const
Check if the both sources are equal.
Definition: MediaSource.h:62
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
String related utilities and Regular expression matching.
zypp::RW_pointer< MediaSource > MediaSourceRef
Definition: MediaSource.h:124
std::ostream & operator<<(std::ostream &str, const MediaHandler &obj)
unsigned int MediaAccessId
Media manager access Id type.
Definition: MediaSource.h:29
zypp::RW_pointer< AttachPoint > AttachPointRef
Definition: MediaSource.h:125
std::string numstring(char n, int w=0)
Definition: String.h:289
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
A simple structure containing references to a media source and its attach point.
Definition: MediaSource.h:134
MediaSourceRef mediaSource
Definition: MediaSource.h:144
AttachedMedia(const MediaSourceRef &_mediaSource, const AttachPointRef &_attachPoint)
Definition: MediaSource.h:138
AttachPointRef attachPoint
Definition: MediaSource.h:145