00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PALUDIS_GUARD_PALUDIS_REPOSITORY_FACTORY_HH
00021 #define PALUDIS_GUARD_PALUDIS_REPOSITORY_FACTORY_HH 1
00022
00023 #include <paludis/repository_factory-fwd.hh>
00024 #include <paludis/util/attributes.hh>
00025 #include <paludis/util/private_implementation_pattern.hh>
00026 #include <paludis/util/instantiation_policy.hh>
00027 #include <paludis/util/wrapped_forward_iterator-fwd.hh>
00028 #include <paludis/util/fs_entry-fwd.hh>
00029 #include <paludis/environment-fwd.hh>
00030 #include <paludis/repository-fwd.hh>
00031 #include <paludis/name-fwd.hh>
00032 #include <tr1/functional>
00033 #include <tr1/memory>
00034
00035 namespace paludis
00036 {
00037 class PALUDIS_VISIBLE RepositoryFactory :
00038 private PrivateImplementationPattern<RepositoryFactory>,
00039 public InstantiationPolicy<RepositoryFactory, instantiation_method::SingletonTag>
00040 {
00041 friend class InstantiationPolicy<RepositoryFactory, instantiation_method::SingletonTag>;
00042
00043 private:
00044 RepositoryFactory();
00045 ~RepositoryFactory();
00046
00047 void _load_dir(const FSEntry &);
00048
00049 public:
00050 typedef std::tr1::function<std::string (const std::string &)> KeyFunction;
00051
00052 typedef std::tr1::function<const std::tr1::shared_ptr<Repository>(
00053 Environment * const,
00054 const KeyFunction &
00055 )> CreateFunction;
00056
00057 typedef std::tr1::function<const std::tr1::shared_ptr<const RepositoryNameSet> (
00058 const Environment * const,
00059 const KeyFunction &
00060 )> DependenciesFunction;
00061
00062 typedef std::tr1::function<const RepositoryName (
00063 const Environment * const,
00064 const KeyFunction &
00065 )> NameFunction;
00066
00067 typedef std::tr1::function<int (
00068 const Environment * const,
00069 const KeyFunction &
00070 )> ImportanceFunction;
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 const std::tr1::shared_ptr<Repository> create(
00091 Environment * const env,
00092 const KeyFunction & key_function
00093 ) const PALUDIS_ATTRIBUTE((warn_unused_result));
00094
00095
00096
00097
00098
00099
00100
00101 const RepositoryName name(
00102 const Environment * const env,
00103 const KeyFunction & key_function
00104 ) const PALUDIS_ATTRIBUTE((warn_unused_result));
00105
00106
00107
00108
00109
00110
00111
00112 int importance(
00113 const Environment * const env,
00114 const KeyFunction & key_function
00115 ) const PALUDIS_ATTRIBUTE((warn_unused_result));
00116
00117
00118
00119
00120
00121
00122
00123 const std::tr1::shared_ptr<const RepositoryNameSet> dependencies(
00124 const Environment * const env,
00125 const KeyFunction & key_function
00126 ) const PALUDIS_ATTRIBUTE((warn_unused_result));
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 void add_repository_format(
00144 const std::tr1::shared_ptr<const Set<std::string> > & formats,
00145 const NameFunction & name_function,
00146 const ImportanceFunction & importance_function,
00147 const CreateFunction & create_function,
00148 const DependenciesFunction & dependencies_function
00149 );
00150
00151 struct ConstIteratorTag;
00152 typedef WrappedForwardIterator<ConstIteratorTag, const std::string> ConstIterator;
00153 ConstIterator begin_keys() const PALUDIS_ATTRIBUTE((warn_unused_result));
00154 ConstIterator end_keys() const PALUDIS_ATTRIBUTE((warn_unused_result));
00155 };
00156
00157 #ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
00158 extern template class PrivateImplementationPattern<RepositoryFactory>;
00159 extern template class InstantiationPolicy<RepositoryFactory, instantiation_method::SingletonTag>;
00160 #endif
00161 }
00162
00163 #endif