syncer.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_SYNCER_HH
00021 #define PALUDIS_GUARD_PALUDIS_SYNCER_HH 1
00022 
00023 #include <paludis/util/exception.hh>
00024 #include <paludis/repository.hh>
00025 #include <string>
00026 
00027 /** \file
00028  * Declarations for the Syncer class, which can be used by repositories to
00029  * simplify syncing.
00030  *
00031  * \ingroup g_repository
00032  *
00033  * \section Examples
00034  *
00035  * - None at this time.
00036  */
00037 
00038 namespace paludis
00039 {
00040     namespace n
00041     {
00042         struct environment;
00043         struct filter_file;
00044         struct local;
00045         struct options;
00046         struct output_deviant;
00047         struct output_prefix;
00048         struct remote;
00049     }
00050 
00051     /**
00052      * Options used by Syncer.
00053      *
00054      * \see Syncer
00055      * \ingroup g_repository
00056      * \nosubgrouping
00057      */
00058     struct SyncOptions
00059     {
00060         NamedValue<n::filter_file, FSEntry> filter_file;
00061         NamedValue<n::options, std::string> options;
00062 
00063         /**
00064          * May be a zero pointer.
00065          * \since 0.32
00066          */
00067         NamedValue<n::output_deviant, std::tr1::shared_ptr<const OutputDeviant> > output_deviant;
00068 
00069         NamedValue<n::output_prefix, std::string> output_prefix;
00070     };
00071 
00072     /**
00073      * Parameters for a Syncer.
00074      *
00075      * \see Syncer
00076      * \ingroup g_repository
00077      * \nosubgrouping
00078      */
00079     struct SyncerParams
00080     {
00081         NamedValue<n::environment, const Environment *> environment;
00082         NamedValue<n::local, std::string> local;
00083         NamedValue<n::remote, std::string> remote;
00084     };
00085 
00086     /**
00087      * A Syncer subclass handles syncing Repository instances.
00088      *
00089      * \ingroup g_repository
00090      */
00091     class PALUDIS_VISIBLE Syncer :
00092         private InstantiationPolicy<Syncer, instantiation_method::NonCopyableTag>
00093     {
00094         protected:
00095             /**
00096              * Constructor.
00097              */
00098             Syncer();
00099 
00100         public:
00101             /**
00102              * Destructor.
00103              */
00104             virtual ~Syncer();
00105 
00106             /**
00107              * Perform the sync.
00108              */
00109             virtual void sync(const SyncOptions &) const = 0;
00110     };
00111 
00112     /**
00113      * A Syncer subclass that uses a program from the syncers/ directory.
00114      *
00115      * \ingroup g_repository
00116      */
00117     class PALUDIS_VISIBLE DefaultSyncer :
00118         public Syncer
00119     {
00120         private:
00121             std::string _local, _remote;
00122             const Environment *_environment;
00123 
00124             std::string _syncer;
00125 
00126         public:
00127             /**
00128              * Constructor.
00129              */
00130             DefaultSyncer(const SyncerParams &);
00131 
00132             /**
00133              * Destructor.
00134              */
00135             virtual ~DefaultSyncer();
00136 
00137             /**
00138              * Perform the sync.
00139              */
00140             virtual void sync(const SyncOptions &) const;
00141     };
00142 
00143     /**
00144      * Thrown if a sync fails.
00145      *
00146      * \ingroup g_repository
00147      * \ingroup g_exceptions
00148      */
00149     class PALUDIS_VISIBLE SyncFailedError :
00150         public Exception
00151     {
00152         public:
00153             /**
00154              * Constructor.
00155              */
00156             SyncFailedError(const std::string & msg) throw ();
00157 
00158             /**
00159              * Constructor.
00160              */
00161             SyncFailedError(const std::string & local, const std::string & remote) throw ();
00162     };
00163 
00164     /**
00165      * Thrown if a syncer of the specified type does not exist.
00166      *
00167      * \ingroup g_repository
00168      * \ingroup g_exceptions
00169      */
00170     class PALUDIS_VISIBLE NoSuchSyncerError : public SyncFailedError
00171     {
00172         public:
00173             /**
00174              * Constructor.
00175              */
00176             NoSuchSyncerError(const std::string & format) throw ();
00177     };
00178 }
00179 
00180 #endif

Generated on Mon Dec 22 19:43:51 2008 for paludis by  doxygen 1.5.7.1