ignore
[platform/upstream/libzypp.git] / zypp / ResObject.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ResObject.h
10  *
11 */
12 #ifndef ZYPP_RESOBJECT_H
13 #define ZYPP_RESOBJECT_H
14
15 #include "zypp/base/Deprecated.h"
16
17 #include "zypp/detail/ResObjectImplIf.h"
18 #include "zypp/Resolvable.h"
19 #include "zypp/TranslatedText.h"
20 #include "zypp/NeedAType.h"
21
22 ///////////////////////////////////////////////////////////////////
23 namespace zypp
24 { /////////////////////////////////////////////////////////////////
25   namespace detail {
26     class ImplConnect;
27     class ResObjectImplIf;
28   }
29   class Source_Ref;
30   class ByteCount;
31
32   ///////////////////////////////////////////////////////////////////
33   //
34   //    CLASS NAME : ResObject
35   //
36   /** Interface base for resolvable objects (common data).
37   */
38   class ResObject : public Resolvable
39   {
40   public:
41     typedef detail::ResObjectImplIf  Impl;
42     typedef ResObject                Self;
43     typedef ResTraits<Self>          TraitsType;
44     typedef TraitsType::PtrType      Ptr;
45     typedef TraitsType::constPtrType constPtr;
46
47   public:
48     /** */
49     Text summary() const;
50
51     /** */
52     Text description() const;
53
54     /** */
55     Text insnotify() const;
56
57     /** */
58     Text delnotify() const;
59
60     /** */
61     Text licenseToConfirm() const;
62
63     /** */
64     Vendor vendor() const;
65
66     /** */
67     ByteCount size() const;
68
69     /** */
70     ByteCount archivesize() const;
71
72     /** Backlink to the source providing this. */
73     Source_Ref source() const;
74
75     /** Number of the source media that provides the data
76      *  required for installation. Zero, if no media access
77      *  is required.
78     */
79     unsigned sourceMediaNr() const;
80
81     /** Use sourceMediaNr */
82     ZYPP_DEPRECATED unsigned mediaId() const
83     { return sourceMediaNr(); }
84
85     /** */
86     bool installOnly() const;
87
88     /** */
89     Date buildtime() const;
90
91     /** Time of installation, or \c 0 */
92     Date installtime() const;
93
94     /** */
95     ZmdId zmdid () const;
96
97   protected:
98     /** Ctor */
99     ResObject( const Kind & kind_r,
100                const NVRAD & nvrad_r );
101     /** Dtor */
102     virtual ~ResObject();
103
104     /** Helper for stream output */
105     virtual std::ostream & dumpOn( std::ostream & str ) const;
106
107   private:
108     friend class detail::ImplConnect;
109     /** Access implementation */
110     virtual Impl & pimpl() = 0;
111     /** Access implementation */
112     virtual const Impl & pimpl() const = 0;
113   };
114   ///////////////////////////////////////////////////////////////////
115
116   /** Convert ResObject::Ptr into Ptr of a certain Kind.
117    * \return \c NULL iff \a p is \c NULL or points to a Resolvable
118    * not of the specified Kind.
119    * \relates ResObject
120    * \code
121    * asKind<Package>(resPtr);
122    * \endcode
123   */
124   template<class _Res>
125     inline typename ResTraits<_Res>::PtrType asKind( const ResObject::Ptr & p )
126     { return dynamic_pointer_cast<_Res>(p); }
127
128   template<class _Res>
129     inline typename ResTraits<_Res>::constPtrType asKind( const ResObject::constPtr & p )
130     { return dynamic_pointer_cast<const _Res>(p); }
131
132   /////////////////////////////////////////////////////////////////
133 } // namespace zypp
134 ///////////////////////////////////////////////////////////////////
135 #endif // ZYPP_RESOBJECT_H