libzypp: zypp/media/MediaSource.h Source File

libzypp 17.38.11

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-core/Pathname.h>
19#include <zypp-core/base/String.h>
20#include <zypp-core/base/PtrTypes.h>
21
22
23namespace zypp {
24 namespace media {
25
27
30 using MediaAccessId = unsigned int;
31
32
34
37 class MediaSource
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
51 MediaSource()
52 : maj_nr(0)
53 , min_nr(0)
54 {}
55
56 virtual
57 ~MediaSource()
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
106 class AttachPoint
107 {
108 public:
109 AttachPoint(Pathname _path=Pathname(),
110 bool _temp=true)
111 : path(std::move(_path))
112 , temp(_temp)
113 {}
114
115 bool empty() const { return path.empty(); }
116
117 Pathname path;
118 bool temp;
119 };
120
122 std::ostream & operator<<( std::ostream & str, const AttachPoint & obj );
123
125 using MediaSourceRef = zypp::RW_pointer<MediaSource>;
126 using AttachPointRef = zypp::RW_pointer<AttachPoint>;
127
128
130
134 struct AttachedMedia
135 {
136 AttachedMedia()
137 {}
138
139 AttachedMedia(MediaSourceRef _mediaSource,
140 AttachPointRef _attachPoint)
141 : mediaSource(std::move( _mediaSource))
142 , attachPoint(std::move( _attachPoint))
143 {}
144
145 MediaSourceRef mediaSource;
146 AttachPointRef attachPoint;
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
Pathname.h
PtrTypes.h
String.h
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zypp::media::AttachPoint
Attach point of a media source.
Definition MediaSource.h:107
zypp::media::AttachPoint::AttachPoint
AttachPoint(Pathname _path=Pathname(), bool _temp=true)
Definition MediaSource.h:109
zypp::media::AttachPoint::path
Pathname path
The path name (mount point).
Definition MediaSource.h:117
zypp::media::AttachPoint::empty
bool empty() const
Definition MediaSource.h:115
zypp::media::AttachPoint::temp
bool temp
If it was created temporary.
Definition MediaSource.h:118
zypp::media::MediaSource
Media source internally used by MediaManager and MediaHandler.
Definition MediaSource.h:38
zypp::media::MediaSource::MediaSource
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
zypp::media::MediaSource::min_nr
unsigned int min_nr
A minor number if source is a device.
Definition MediaSource.h:91
zypp::media::MediaSource::type
std::string type
A media handler specific source type.
Definition MediaSource.h:92
zypp::media::MediaSource::maj_nr
unsigned int maj_nr
A major number if source is a device.
Definition MediaSource.h:90
zypp::media::MediaSource::iown
bool iown
True, if mounted by media manager.
Definition MediaSource.h:95
zypp::media::MediaSource::MediaSource
MediaSource()
Definition MediaSource.h:51
zypp::media::MediaSource::name
std::string name
A media handler specific source name.
Definition MediaSource.h:93
zypp::media::MediaSource::asString
virtual std::string asString() const
Return media source as string for debuging purposes.
Definition MediaSource.h:79
zypp::media::MediaSource::bdir
std::string bdir
Directory, the media may be bound to.
Definition MediaSource.h:94
zypp::media::MediaSource::~MediaSource
virtual ~MediaSource()
Definition MediaSource.h:57
zypp::media::MediaSource::equals
virtual bool equals(const MediaSource &src) const
Check if the both sources are equal.
Definition MediaSource.h:63
std
Definition ansi.h:855
str
String related utilities and Regular expression matching.
zypp::media
Definition MediaNetworkRequestExecutor.h:22
zypp::media::operator<<
std::ostream & operator<<(std::ostream &str, const MediaHandler &obj)
Definition MediaHandler.cc:1181
zypp::media::MediaAccessId
unsigned int MediaAccessId
Media manager access Id type.
Definition MediaSource.h:30
zypp::media::MediaSourceRef
zypp::RW_pointer< MediaSource > MediaSourceRef
Definition MediaSource.h:125
zypp::media::AttachPointRef
zypp::RW_pointer< AttachPoint > AttachPointRef
Definition MediaSource.h:126
zypp::str::numstring
std::string numstring(char n, int w=0)
Definition String.h:290
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293
zypp::media::AttachedMedia
A simple structure containing references to a media source and its attach point.
Definition MediaSource.h:135
zypp::media::AttachedMedia::AttachedMedia
AttachedMedia(MediaSourceRef _mediaSource, AttachPointRef _attachPoint)
Definition MediaSource.h:139
zypp::media::AttachedMedia::mediaSource
MediaSourceRef mediaSource
Definition MediaSource.h:145
zypp::media::AttachedMedia::AttachedMedia
AttachedMedia()
Definition MediaSource.h:136
zypp::media::AttachedMedia::attachPoint
AttachPointRef attachPoint
Definition MediaSource.h:146