- fixed some typos
[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 Repository;
31   class ByteCount;
32
33   ///////////////////////////////////////////////////////////////////
34   //
35   //    CLASS NAME : ResObject
36   //
37   /**
38    * Interface base for resolvable objects (common data).
39    * That is, all data not needed for solving, but common
40    * across all Resolvable kinds.
41   */
42   class ResObject : public Resolvable
43   {
44   public:
45     typedef detail::ResObjectImplIf  Impl;
46     typedef ResObject                Self;
47     typedef ResTraits<Self>          TraitsType;
48     typedef TraitsType::PtrType      Ptr;
49     typedef TraitsType::constPtrType constPtr;
50
51   public:
52     /**
53      * \short Short text describing the resolvable.
54      * This attribute is usually displayed in columns.
55      */
56     Text summary() const;
57
58     /**
59      * \short Long text describing the resolvable.
60      */
61     Text description() const;
62
63     /**
64      * \short Installation Notification
65      *
66      * This text can be used to tell the user some notes
67      * When he selects the resovable for installation.
68      */
69     Text insnotify() const;
70
71     /**
72      * \short De-Installation Notification
73      *
74      * This text can be used to tell the user some notes
75      * When he selects the resovable for deinstall.
76      */
77     Text delnotify() const;
78
79     /**
80      * \short License or agreement to accept
81      *
82      * Agreement, warning or license the user should
83      * accept before installing the resolvable.
84      */
85     Text licenseToConfirm() const;
86
87     /**
88      * \short Vendor
89      *
90      * For Example "Novell Inc."
91      */
92     Vendor vendor() const;
93
94     /** Installed size. */
95     ByteCount size() const;
96
97     /** Size of the rpm package. */
98     ByteCount archivesize() const;
99
100     /**
101      * Source providing this resolvable
102      */
103     /*ZYPP_DEPRECATED */ Source_Ref source() const;
104
105     /**
106      * Source providing this resolvable
107      */
108     Repository repository() const;
109     
110     /**
111      * Media number where the resolvable is located
112      * 0 if no media access is required.
113     */
114     unsigned mediaNr() const;
115     
116     /**
117      * Media number where the resolvable is located
118      * 0 if no media access is required.
119     */
120     /* ZYPP_DEPRECATED */ unsigned sourceMediaNr() const;
121
122     /**
123      * \deprecated Use sourceMediaNr 
124      */
125     /* ZYPP_DEPRECATED */ unsigned mediaId() const
126     { return sourceMediaNr(); }
127
128     /**
129      * \TODO FIXME what is this?
130      */
131     bool installOnly() const;
132
133     /**
134      * \short build time of the resolvable
135      */
136     Date buildtime() const;
137
138     /**
139      * \short Installation time
140      * 0 if the resolvable is not installed.
141      */
142     Date installtime() const;
143
144     /**
145      * \deprecated No replacement.
146      */
147     ZYPP_DEPRECATED ZmdId zmdid () const;
148
149   protected:
150     /** Ctor */
151     ResObject( const Kind & kind_r,
152                const NVRAD & nvrad_r );
153     /** Dtor */
154     virtual ~ResObject();
155
156     /** Helper for stream output */
157     virtual std::ostream & dumpOn( std::ostream & str ) const;
158
159   private:
160     friend class detail::ImplConnect;
161     /** Access implementation */
162     virtual Impl & pimpl() = 0;
163     /** Access implementation */
164     virtual const Impl & pimpl() const = 0;
165   };
166   ///////////////////////////////////////////////////////////////////
167
168   /** Convert ResObject::Ptr into Ptr of a certain Kind.
169    * \return \c NULL iff \a p is \c NULL or points to a Resolvable
170    * not of the specified Kind.
171    * \relates ResObject
172    * \code
173    * asKind<Package>(resPtr);
174    * \endcode
175   */
176   template<class _Res>
177     inline typename ResTraits<_Res>::PtrType asKind( const ResObject::Ptr & p )
178     { return dynamic_pointer_cast<_Res>(p); }
179
180   template<class _Res>
181     inline typename ResTraits<_Res>::constPtrType asKind( const ResObject::constPtr & p )
182     { return dynamic_pointer_cast<const _Res>(p); }
183
184   /////////////////////////////////////////////////////////////////
185 } // namespace zypp
186 ///////////////////////////////////////////////////////////////////
187 #endif // ZYPP_RESOBJECT_H