contents.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, 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_CONTENTS_HH
00021 #define PALUDIS_GUARD_PALUDIS_CONTENTS_HH 1
00022 
00023 #include <paludis/contents-fwd.hh>
00024 #include <paludis/util/simple_visitor.hh>
00025 #include <paludis/util/instantiation_policy.hh>
00026 #include <paludis/util/private_implementation_pattern.hh>
00027 #include <paludis/util/type_list.hh>
00028 #include <paludis/util/wrapped_forward_iterator-fwd.hh>
00029 #include <paludis/util/fs_entry-fwd.hh>
00030 #include <paludis/metadata_key_holder.hh>
00031 #include <tr1/memory>
00032 #include <string>
00033 
00034 /** \file
00035  * Declarations for the Contents classes.
00036  *
00037  * \ingroup g_contents
00038  *
00039  * \section Examples
00040  *
00041  * - \ref example_contents.cc "example_contents.cc"
00042  */
00043 
00044 namespace paludis
00045 {
00046     /**
00047      * Base class for a contents entry.
00048      *
00049      * \since 0.36 for MetadataKeyHolder methods.
00050      *
00051      * \ingroup g_contents
00052      * \nosubgrouping
00053      */
00054     class PALUDIS_VISIBLE ContentsEntry :
00055         private PrivateImplementationPattern<ContentsEntry>,
00056         public MetadataKeyHolder,
00057         public virtual DeclareAbstractAcceptMethods<ContentsEntry, MakeTypeList<
00058             ContentsFileEntry, ContentsDirEntry, ContentsSymEntry, ContentsOtherEntry>::Type>
00059     {
00060         private:
00061             PrivateImplementationPattern<ContentsEntry>::ImpPtr & _imp;
00062 
00063         protected:
00064             virtual void need_keys_added() const;
00065 
00066         public:
00067             ///\name Basic operations
00068             ///\{
00069 
00070             ContentsEntry(const FSEntry & path);
00071             virtual ~ContentsEntry() = 0;
00072 
00073             ///\}
00074 
00075             ///\name Metadata key operations
00076             ///\{
00077 
00078             /**
00079              * Must be called straight after construction.
00080              *
00081              * \since 0.36
00082              */
00083             using MetadataKeyHolder::add_metadata_key;
00084 
00085             ///\}
00086 
00087             ///\name Specific metadata keys
00088             ///\{
00089 
00090             /**
00091              * Our path on disk. Must not be zero. Not modified for root.
00092              *
00093              * \since 0.36
00094              */
00095             const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > location_key() const;
00096 
00097             ///\}
00098 
00099             ///\}
00100     };
00101 
00102     /**
00103      * A file contents entry.
00104      *
00105      * \ingroup g_contents
00106      * \nosubgrouping
00107      */
00108     class PALUDIS_VISIBLE ContentsFileEntry :
00109         public ContentsEntry,
00110         public ImplementAcceptMethods<ContentsEntry, ContentsFileEntry>
00111     {
00112         public:
00113             ///\name Basic operations
00114             ///\{
00115 
00116             ContentsFileEntry(const FSEntry &);
00117 
00118             ///\}
00119     };
00120 
00121     /**
00122      * A directory contents entry.
00123      *
00124      * \ingroup g_contents
00125      * \nosubgrouping
00126      */
00127     class PALUDIS_VISIBLE ContentsDirEntry :
00128         public ContentsEntry,
00129         public ImplementAcceptMethods<ContentsEntry, ContentsDirEntry>
00130     {
00131         public:
00132             ///\name Basic operations
00133             ///\{
00134 
00135             ContentsDirEntry(const FSEntry &);
00136 
00137             ///\}
00138     };
00139 
00140     /**
00141      * An 'other' contents entry, which we can't handle.
00142      *
00143      * \since 0.36
00144      * \ingroup g_contents
00145      * \nosubgrouping
00146      */
00147     class PALUDIS_VISIBLE ContentsOtherEntry :
00148         public ContentsEntry,
00149         public ImplementAcceptMethods<ContentsEntry, ContentsOtherEntry>
00150     {
00151         public:
00152             ///\name Basic operations
00153             ///\{
00154 
00155             ContentsOtherEntry(const FSEntry &);
00156 
00157             ///\}
00158     };
00159 
00160     /**
00161      * A sym contents entry.
00162      *
00163      * \ingroup g_contents
00164      * \nosubgrouping
00165      */
00166     class PALUDIS_VISIBLE ContentsSymEntry :
00167         private PrivateImplementationPattern<ContentsSymEntry>,
00168         public ContentsEntry,
00169         public ImplementAcceptMethods<ContentsEntry, ContentsSymEntry>
00170     {
00171         private:
00172             PrivateImplementationPattern<ContentsSymEntry>::ImpPtr & _imp;
00173 
00174         public:
00175             ///\name Basic operations
00176             ///\{
00177 
00178             ContentsSymEntry(const FSEntry &, const std::string & target);
00179             ~ContentsSymEntry();
00180 
00181             ///\}
00182 
00183             ///\name Specific metadata keys
00184             ///\{
00185 
00186             /**
00187              * Our target, as per readlink. Must not be zero.
00188              *
00189              * \since 0.36
00190              */
00191             const std::tr1::shared_ptr<const MetadataValueKey<std::string> > target_key() const;
00192 
00193             ///\}
00194     };
00195 
00196     /**
00197      * A package's contents, obtainable by PackageID::contents_key.
00198      *
00199      * \ingroup g_contents
00200      * \nosubgrouping
00201      */
00202     class PALUDIS_VISIBLE Contents :
00203         private InstantiationPolicy<Contents, instantiation_method::NonCopyableTag>,
00204         private PrivateImplementationPattern<Contents>
00205     {
00206         public:
00207             ///\name Basic operations
00208             ///\{
00209 
00210             Contents();
00211             ~Contents();
00212 
00213             ///\}
00214 
00215             /// Add a new entry.
00216             void add(const std::tr1::shared_ptr<const ContentsEntry> & c);
00217 
00218             ///\name Iterate over our entries
00219             ///\{
00220 
00221             struct ConstIteratorTag;
00222             typedef WrappedForwardIterator<ConstIteratorTag, const std::tr1::shared_ptr<const ContentsEntry> > ConstIterator;
00223 
00224             ConstIterator begin() const
00225                 PALUDIS_ATTRIBUTE((warn_unused_result));
00226 
00227             ConstIterator end() const
00228                 PALUDIS_ATTRIBUTE((warn_unused_result));
00229 
00230             ///\}
00231     };
00232 
00233 #ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
00234     extern template class InstantiationPolicy<Contents, instantiation_method::NonCopyableTag>;
00235     extern template class PrivateImplementationPattern<Contents>;
00236     extern template class PrivateImplementationPattern<ContentsEntry>;
00237     extern template class PrivateImplementationPattern<ContentsSymEntry>;
00238 #endif
00239 }
00240 
00241 #endif

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