fake_package_id.hh

00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2007, 2008, 2009 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_REPOSITORIES_FAKE_FAKE_PACKAGE_ID_HH
00021 #define PALUDIS_GUARD_PALUDIS_REPOSITORIES_FAKE_FAKE_PACKAGE_ID_HH 1
00022 
00023 #include <paludis/package_id.hh>
00024 #include <paludis/metadata_key.hh>
00025 #include <paludis/mask.hh>
00026 #include <paludis/util/set.hh>
00027 #include <tr1/functional>
00028 
00029 namespace paludis
00030 {
00031     class FakeRepositoryBase;
00032 
00033     template <typename C_>
00034     class PALUDIS_VISIBLE FakeMetadataCollectionKey :
00035         public MetadataCollectionKey<C_>,
00036         private PrivateImplementationPattern<FakeMetadataCollectionKey<C_> >
00037     {
00038         protected:
00039             typename PrivateImplementationPattern<FakeMetadataCollectionKey<C_> >::ImpPtr & _imp;
00040 
00041             FakeMetadataCollectionKey(const std::string &, const std::string &, const MetadataKeyType,
00042                     const PackageID * const, const Environment * const);
00043 
00044         public:
00045             ~FakeMetadataCollectionKey();
00046 
00047             virtual const std::tr1::shared_ptr<const C_> value() const PALUDIS_ATTRIBUTE((warn_unused_result));
00048 
00049             virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
00050             virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
00051             virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
00052     };
00053 
00054     class PALUDIS_VISIBLE FakeMetadataKeywordSetKey :
00055         public FakeMetadataCollectionKey<KeywordNameSet>
00056     {
00057         public:
00058             FakeMetadataKeywordSetKey(const std::string &, const std::string &, const std::string &, const MetadataKeyType,
00059                     const PackageID * const, const Environment * const);
00060 
00061             void set_from_string(const std::string &);
00062 
00063             virtual std::string pretty_print_flat(const Formatter<KeywordName> &) const
00064                 PALUDIS_ATTRIBUTE((warn_unused_result));
00065     };
00066 
00067     template <typename C_>
00068     class PALUDIS_VISIBLE FakeMetadataSpecTreeKey :
00069         public MetadataSpecTreeKey<C_>,
00070         private PrivateImplementationPattern<FakeMetadataSpecTreeKey<C_> >
00071     {
00072         private:
00073             typename PrivateImplementationPattern<FakeMetadataSpecTreeKey<C_> >::ImpPtr & _imp;
00074 
00075         public:
00076             FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &,
00077                     const std::tr1::function<const std::tr1::shared_ptr<const C_> (const std::string &)> &, const MetadataKeyType);
00078             ~FakeMetadataSpecTreeKey();
00079 
00080             virtual const std::tr1::shared_ptr<const C_> value() const
00081                 PALUDIS_ATTRIBUTE((warn_unused_result));
00082 
00083             void set_from_string(const std::string &);
00084 
00085             virtual std::string pretty_print(const typename C_::ItemFormatter &) const
00086                 PALUDIS_ATTRIBUTE((warn_unused_result));
00087 
00088             virtual std::string pretty_print_flat(const typename C_::ItemFormatter &) const
00089                 PALUDIS_ATTRIBUTE((warn_unused_result));
00090 
00091             virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
00092             virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
00093             virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
00094     };
00095 
00096     template <>
00097     class PALUDIS_VISIBLE FakeMetadataSpecTreeKey<FetchableURISpecTree> :
00098         public MetadataSpecTreeKey<FetchableURISpecTree>,
00099         private PrivateImplementationPattern<FakeMetadataSpecTreeKey<FetchableURISpecTree> >
00100     {
00101         private:
00102             PrivateImplementationPattern<FakeMetadataSpecTreeKey<FetchableURISpecTree> >::ImpPtr & _imp;
00103 
00104         public:
00105             FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &,
00106                     const std::tr1::function<const std::tr1::shared_ptr<const FetchableURISpecTree> (const std::string &)> &,
00107                     const MetadataKeyType);
00108             ~FakeMetadataSpecTreeKey();
00109 
00110             virtual const std::tr1::shared_ptr<const FetchableURISpecTree> value() const
00111                 PALUDIS_ATTRIBUTE((warn_unused_result));
00112 
00113             void set_from_string(const std::string &);
00114 
00115             virtual std::string pretty_print(const FetchableURISpecTree::ItemFormatter &) const
00116                 PALUDIS_ATTRIBUTE((warn_unused_result));
00117 
00118             virtual std::string pretty_print_flat(const FetchableURISpecTree::ItemFormatter &) const
00119                 PALUDIS_ATTRIBUTE((warn_unused_result));
00120 
00121             virtual const std::tr1::shared_ptr<const URILabel> initial_label() const
00122                 PALUDIS_ATTRIBUTE((warn_unused_result));
00123 
00124             virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
00125             virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
00126             virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
00127     };
00128 
00129     template <>
00130     class PALUDIS_VISIBLE FakeMetadataSpecTreeKey<DependencySpecTree> :
00131         public MetadataSpecTreeKey<DependencySpecTree>,
00132         private PrivateImplementationPattern<FakeMetadataSpecTreeKey<DependencySpecTree> >
00133     {
00134         private:
00135             PrivateImplementationPattern<FakeMetadataSpecTreeKey<DependencySpecTree> >::ImpPtr & _imp;
00136 
00137         public:
00138             FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &,
00139                     const std::tr1::function<const std::tr1::shared_ptr<const DependencySpecTree> (const std::string &)> &,
00140                     const std::tr1::shared_ptr<const DependencyLabelSequence> &,
00141                     const MetadataKeyType);
00142             ~FakeMetadataSpecTreeKey();
00143 
00144             virtual const std::tr1::shared_ptr<const DependencySpecTree> value() const
00145                 PALUDIS_ATTRIBUTE((warn_unused_result));
00146 
00147             void set_from_string(const std::string &);
00148 
00149             virtual std::string pretty_print(const DependencySpecTree::ItemFormatter &) const
00150                 PALUDIS_ATTRIBUTE((warn_unused_result));
00151 
00152             virtual std::string pretty_print_flat(const DependencySpecTree::ItemFormatter &) const
00153                 PALUDIS_ATTRIBUTE((warn_unused_result));
00154 
00155             virtual const std::tr1::shared_ptr<const DependencyLabelSequence> initial_labels() const
00156                 PALUDIS_ATTRIBUTE((warn_unused_result));
00157 
00158             virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
00159             virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
00160             virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
00161     };
00162 
00163     class PALUDIS_VISIBLE FakeMetadataChoicesKey :
00164         public MetadataValueKey<std::tr1::shared_ptr<const Choices> >,
00165         private PrivateImplementationPattern<FakeMetadataChoicesKey>
00166     {
00167         private:
00168             PrivateImplementationPattern<FakeMetadataChoicesKey>::ImpPtr & _imp;
00169 
00170         public:
00171             FakeMetadataChoicesKey(
00172                     const Environment * const,
00173                     const std::tr1::shared_ptr<const PackageID> &);
00174             ~FakeMetadataChoicesKey();
00175 
00176             void add(const std::string &, const std::string &);
00177             const std::tr1::shared_ptr<const Choices> value() const PALUDIS_ATTRIBUTE((warn_unused_result));
00178 
00179             virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
00180             virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
00181             virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
00182     };
00183 
00184     class PALUDIS_VISIBLE FakeUnacceptedMask :
00185         public UnacceptedMask,
00186         private PrivateImplementationPattern<FakeUnacceptedMask>
00187     {
00188         public:
00189             FakeUnacceptedMask(const char, const std::string &, const std::tr1::shared_ptr<const MetadataKey> &);
00190             ~FakeUnacceptedMask();
00191 
00192             char key() const;
00193             const std::string description() const;
00194             const std::tr1::shared_ptr<const MetadataKey> unaccepted_key() const;
00195     };
00196 
00197     class PALUDIS_VISIBLE FakeUnsupportedMask :
00198         public UnsupportedMask
00199     {
00200         public:
00201             FakeUnsupportedMask();
00202             ~FakeUnsupportedMask();
00203 
00204             char key() const;
00205             const std::string description() const;
00206             const std::string explanation() const;
00207     };
00208 
00209     /**
00210      * A PackageID in a FakeRepository or a FakeInstalledRepository.
00211      *
00212      * Various keys can be modified.
00213      *
00214      * \ingroup g_fake_repository
00215      * \since 0.26
00216      */
00217     class PALUDIS_VISIBLE FakePackageID :
00218         public PackageID,
00219         private PrivateImplementationPattern<FakePackageID>,
00220         public std::tr1::enable_shared_from_this<FakePackageID>
00221     {
00222         private:
00223             PrivateImplementationPattern<FakePackageID>::ImpPtr & _imp;
00224 
00225         protected:
00226             virtual void need_keys_added() const;
00227             virtual void need_masks_added() const;
00228 
00229         public:
00230             ///\name Basic operations
00231             ///\{
00232 
00233             FakePackageID(const Environment * const e,
00234                     const std::tr1::shared_ptr<const FakeRepositoryBase> &,
00235                     const QualifiedPackageName &, const VersionSpec &);
00236             ~FakePackageID();
00237 
00238             ///\}
00239 
00240             virtual const std::string canonical_form(const PackageIDCanonicalForm) const;
00241 
00242             virtual const QualifiedPackageName name() const;
00243             virtual const VersionSpec version() const;
00244             virtual const std::tr1::shared_ptr<const Repository> repository() const;
00245             virtual PackageDepSpec uniquely_identifying_spec() const;
00246 
00247             virtual const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
00248             virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for_key() const;
00249             virtual const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
00250             virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
00251             virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > dependencies_key() const;
00252             virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key() const;
00253             virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key() const;
00254             virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > post_dependencies_key() const;
00255             virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > suggested_dependencies_key() const;
00256             virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> > fetches_key() const;
00257             virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> > homepage_key() const;
00258             virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > short_description_key() const;
00259             virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > long_description_key() const;
00260             virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const Contents> > > contents_key() const;
00261             virtual const std::tr1::shared_ptr<const MetadataTimeKey> installed_time_key() const;
00262             virtual const std::tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > contains_key() const;
00263             virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > contained_in_key() const;
00264             virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > fs_location_key() const;
00265             virtual const std::tr1::shared_ptr<const MetadataValueKey<long> > size_of_download_required_key() const;
00266             virtual const std::tr1::shared_ptr<const MetadataValueKey<long> > size_of_all_distfiles_key() const;
00267             virtual const std::tr1::shared_ptr<const MetadataValueKey<bool> > transient_key() const;
00268             virtual const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > from_repositories_key() const;
00269             virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const Choices> > > choices_key() const;
00270 
00271             const std::tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > license_key() const;
00272 
00273             ///\name Modifiable keys
00274             ///\{
00275 
00276             const std::tr1::shared_ptr<FakeMetadataKeywordSetKey> keywords_key();
00277             const std::tr1::shared_ptr<FakeMetadataSpecTreeKey<ProvideSpecTree> > provide_key();
00278             const std::tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key();
00279             const std::tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key();
00280             const std::tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > post_dependencies_key();
00281             const std::tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > suggested_dependencies_key();
00282             const std::tr1::shared_ptr<FakeMetadataSpecTreeKey<FetchableURISpecTree> > fetches_key();
00283             const std::tr1::shared_ptr<FakeMetadataSpecTreeKey<SimpleURISpecTree> > homepage_key();
00284             const std::tr1::shared_ptr<FakeMetadataChoicesKey> choices_key();
00285 
00286             void set_slot(const SlotName &);
00287 
00288             ///\}
00289 
00290             char use_expand_separator() const;
00291 
00292             virtual bool arbitrary_less_than_comparison(const PackageID &) const;
00293             virtual std::size_t extra_hash_value() const;
00294 
00295             virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
00296             virtual void perform_action(Action &) const;
00297 
00298             virtual std::tr1::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
00299 
00300             virtual void invalidate_masks() const;
00301 
00302             void make_unsupported();
00303 
00304     };
00305 }
00306 
00307 #endif

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