dep_tag.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
00005  *
00006  * This file is part of the Paludis package manager. Paludis is free software;
00007  * you can redistribute it and/or modify it under the terms of the GNU General
00008  * Public License version 2, as published by the Free Software Foundation.
00009  *
00010  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
00011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00012  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00013  * details.
00014  *
00015  * You should have received a copy of the GNU General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #ifndef PALUDIS_GUARD_PALUDIS_DEP_TAG_HH
00021 #define PALUDIS_GUARD_PALUDIS_DEP_TAG_HH 1
00022 
00023 /** \file
00024  * Declarations for dependency tags.
00025  *
00026  * \ingroup g_dep_spec
00027  *
00028  * \section Examples
00029  *
00030  * - \ref example_dep_tag.cc "example_dep_tag.cc" (for tags)
00031  * - \ref example_dep_spec.cc "example_dep_spec.cc" (for specifications)
00032  * - \ref example_dep_label.cc "example_dep_label.cc" (for labels)
00033  */
00034 
00035 #include <paludis/dep_tag-fwd.hh>
00036 #include <paludis/dep_spec-fwd.hh>
00037 #include <paludis/name-fwd.hh>
00038 #include <paludis/package_id-fwd.hh>
00039 #include <paludis/spec_tree-fwd.hh>
00040 #include <paludis/util/instantiation_policy.hh>
00041 #include <paludis/util/simple_visitor.hh>
00042 #include <paludis/util/exception.hh>
00043 #include <paludis/util/named_value.hh>
00044 #include <paludis/util/fs_entry.hh>
00045 #include <paludis/util/operators.hh>
00046 #include <paludis/util/type_list.hh>
00047 
00048 #include <string>
00049 #include <tr1/memory>
00050 
00051 namespace paludis
00052 {
00053     namespace n
00054     {
00055         struct generation;
00056         struct tag;
00057     }
00058 
00059     /**
00060      * A DepTagCategory is identified by its name and has associated display
00061      * information for a DepTag's category.
00062      *
00063      * It is usually accessed via DepTagCategoryMaker.
00064      *
00065      * \see DepTagCategoryMaker
00066      * \see DepTag
00067      *
00068      * \ingroup g_dep_spec
00069      * \nosubgrouping
00070      */
00071     class PALUDIS_VISIBLE DepTagCategory :
00072         private InstantiationPolicy<DepTagCategory, instantiation_method::NonCopyableTag>
00073     {
00074         private:
00075             bool _visible;
00076             const std::string _id;
00077             const std::string _title;
00078             const std::string _pre_text;
00079             const std::string _post_text;
00080 
00081         public:
00082             ///\name Basic operations
00083             ///\{
00084 
00085             DepTagCategory(
00086                     bool visible,
00087                     const std::string & id,
00088                     const std::string & t,
00089                     const std::string & pre,
00090                     const std::string & post);
00091 
00092             ///\}
00093 
00094             /**
00095              * Should we be displayed in a tag category summary?
00096              */
00097             bool visible() const;
00098 
00099             /**
00100              * Fetch our short ID (for example, 'GLSA').
00101              */
00102             std::string id() const;
00103 
00104             /**
00105              * Fetch our title (for example, 'Security advisories'), or an
00106              * empty string if we're untitled.
00107              */
00108             std::string title() const;
00109 
00110             /**
00111              * Fetch our pre list text, or an empty string.
00112              */
00113             std::string pre_text() const;
00114 
00115             /**
00116              * Fetch our post list text, or an empty string.
00117              */
00118             std::string post_text() const;
00119     };
00120 
00121     /**
00122      * Factory for accessing DepTagCategory instances.
00123      *
00124      * \ingroup g_dep_spec
00125      * \since 0.30
00126      */
00127     class PALUDIS_VISIBLE DepTagCategoryFactory :
00128         public InstantiationPolicy<DepTagCategoryFactory, instantiation_method::SingletonTag>
00129     {
00130         friend class InstantiationPolicy<DepTagCategoryFactory, instantiation_method::SingletonTag>;
00131 
00132         private:
00133             DepTagCategoryFactory();
00134 
00135         public:
00136             const std::tr1::shared_ptr<DepTagCategory> create(const std::string &) const
00137                 PALUDIS_ATTRIBUTE((warn_unused_result));
00138     };
00139 
00140     /**
00141      * A DepTag can be associated with a PackageDepSpec, and is transferred
00142      * onto any associated DepListEntry instances.
00143      *
00144      * It is used for tagging dep list entries visually, for example to
00145      * indicate an associated GLSA.
00146      *
00147      * \ingroup g_dep_spec
00148      * \nosubgrouping
00149      */
00150     class PALUDIS_VISIBLE DepTag :
00151         private InstantiationPolicy<DepTag, instantiation_method::NonCopyableTag>,
00152         public relational_operators::HasRelationalOperators,
00153         public virtual DeclareAbstractAcceptMethods<DepTag, MakeTypeList<
00154             GLSADepTag, GeneralSetDepTag, DependencyDepTag, TargetDepTag>::Type>
00155     {
00156         protected:
00157             ///\name Basic operations
00158             ///\{
00159 
00160             DepTag();
00161 
00162         public:
00163             virtual ~DepTag();
00164 
00165             ///\}
00166 
00167             /**
00168              * Fetch our short text (for example, 'GLSA-1234') that is
00169              * displayed with the dep list entry.
00170              */
00171             virtual std::string short_text() const = 0;
00172 
00173             /**
00174              * Fetch our DepTagCategory's tag.
00175              */
00176             virtual std::string category() const = 0;
00177 
00178             ///\name Comparison operators
00179             ///\{
00180 
00181             bool operator< (const DepTag &) const;
00182             bool operator== (const DepTag &) const;
00183 
00184             ///\}
00185     };
00186 
00187     /**
00188      * DepTag subclass for GLSAs.
00189      *
00190      * \ingroup g_dep_spec
00191      * \nosubgrouping
00192      */
00193     class PALUDIS_VISIBLE GLSADepTag :
00194         public DepTag,
00195         public ImplementAcceptMethods<DepTag, GLSADepTag>
00196     {
00197         private:
00198             const std::string _id;
00199             const std::string _glsa_title;
00200             const FSEntry _glsa_file;
00201 
00202         public:
00203             ///\name Basic operations
00204             ///\{
00205 
00206             GLSADepTag(const std::string & id, const std::string & glsa_title, const FSEntry&);
00207             ~GLSADepTag();
00208 
00209             ///\}
00210 
00211             ///\name Content information
00212             ///\{
00213 
00214             virtual std::string short_text() const;
00215 
00216             virtual std::string category() const;
00217 
00218             /**
00219              * The full path to the glsa announcement file.
00220              */
00221             const FSEntry glsa_file() const;
00222 
00223             /**
00224              * Fetch our GLSA title (for example, 'Yet another PHP remote access
00225              * hole').
00226              */
00227             std::string glsa_title() const;
00228 
00229             ///\}
00230     };
00231 
00232     /**
00233      * DepTag subclass for general sets.
00234      *
00235      * \ingroup g_dep_spec
00236      * \nosubgrouping
00237      */
00238     class PALUDIS_VISIBLE GeneralSetDepTag :
00239         public DepTag,
00240         public ImplementAcceptMethods<DepTag, GeneralSetDepTag>,
00241         private PrivateImplementationPattern<GeneralSetDepTag>
00242     {
00243         public:
00244             ///\name Basic operations
00245             ///\{
00246 
00247             GeneralSetDepTag(const SetName & id, const std::string & source);
00248             ~GeneralSetDepTag();
00249 
00250             ///\}
00251 
00252             virtual std::string short_text() const;
00253 
00254             virtual std::string category() const;
00255 
00256             /**
00257              * From which repository or environment did we originate?
00258              */
00259             std::string source() const;
00260     };
00261 
00262     /**
00263      * DepTag subclass for dependencies.
00264      *
00265      * \ingroup g_dep_spec
00266      * \nosubgrouping
00267      */
00268     class PALUDIS_VISIBLE DependencyDepTag :
00269         public DepTag,
00270         public ImplementAcceptMethods<DepTag, DependencyDepTag>,
00271         private PrivateImplementationPattern<DependencyDepTag>
00272     {
00273         private:
00274             void _make_str() const;
00275 
00276         public:
00277             ///\name Basic operations
00278             ///\{
00279 
00280             DependencyDepTag(const std::tr1::shared_ptr<const PackageID> &, const PackageDepSpec &);
00281 
00282             ~DependencyDepTag();
00283 
00284             ///\}
00285 
00286             virtual std::string short_text() const;
00287 
00288             virtual std::string category() const;
00289 
00290             /**
00291              * The PackageID that contains our dependency.
00292              */
00293             const std::tr1::shared_ptr<const PackageID> package_id() const;
00294 
00295             /**
00296              * The PackageDepSpec that pulled us in.
00297              */
00298             const std::tr1::shared_ptr<const PackageDepSpec> dependency() const;
00299     };
00300 
00301     /**
00302      * DepTag subclass for explicit targets.
00303      *
00304      * \ingroup g_dep_spec
00305      * \nosubgrouping
00306      */
00307     class PALUDIS_VISIBLE TargetDepTag :
00308         public DepTag,
00309         public ImplementAcceptMethods<DepTag, TargetDepTag>
00310     {
00311         public:
00312             ///\name Basic operations
00313             ///\{
00314 
00315             TargetDepTag();
00316             ~TargetDepTag();
00317 
00318             ///\}
00319 
00320             virtual std::string short_text() const;
00321             virtual std::string category() const;
00322     };
00323 
00324     /**
00325      * Tags associated with a DepListEntry.
00326      *
00327      * The generation key is used internally by DepList. Its value is of no interest
00328      * to outside clients.
00329      *
00330      * \see DepListEntry
00331      * \ingroup g_dep_list
00332      * \nosubgrouping
00333      */
00334     struct DepTagEntry
00335     {
00336         NamedValue<n::generation, long> generation;
00337         NamedValue<n::tag, std::tr1::shared_ptr<const DepTag> > tag;
00338     };
00339 
00340     /**
00341      * Compare two DepListEntry structs by tag only.
00342      *
00343      * \see DepTagEntry
00344      * \ingroup g_dep_list
00345      * \since 0.34
00346      */
00347     struct PALUDIS_VISIBLE DepTagEntryComparator
00348     {
00349         bool operator() (const DepTagEntry &, const DepTagEntry &) const PALUDIS_ATTRIBUTE((warn_unused_result));
00350     };
00351 
00352 #ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
00353     extern template class InstantiationPolicy<DepTagCategoryFactory, instantiation_method::SingletonTag>;
00354     extern template class PrivateImplementationPattern<DependencyDepTag>;
00355     extern template class PrivateImplementationPattern<GeneralSetDepTag>;
00356 #endif
00357 
00358 }
00359 
00360 #endif

Generated on Mon Sep 21 10:36:08 2009 for paludis by  doxygen 1.5.4