stage_builder_task.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2006 Danny van Dyk
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_STAGE_BUILDER_TASK_HH
00021 #define PALUDIS_GUARD_PALUDIS_STAGE_BUILDER_TASK_HH 1
00022 
00023 #include <paludis/util/instantiation_policy.hh>
00024 #include <paludis/util/private_implementation_pattern.hh>
00025 #include <paludis/util/exception.hh>
00026 #include <paludis/util/wrapped_forward_iterator-fwd.hh>
00027 #include <tr1/memory>
00028 
00029 /** \file
00030  * Declarations for StageBuilderTask.
00031  *
00032  * \ingroup g_tasks
00033  *
00034  * \section Examples
00035  *
00036  * - None at this time.
00037  */
00038 
00039 namespace paludis
00040 {
00041     /**
00042      * Thrown if a stage build fails.
00043      *
00044      * \ingroup g_tasks
00045      * \ingroup g_exceptions
00046      * \nosubgrouping
00047      */
00048     class PALUDIS_VISIBLE StageBuildError :
00049         public Exception
00050     {
00051         public:
00052             /**
00053              * Constructor
00054              *
00055              * \param message Message associated with the build error.
00056              */
00057             StageBuildError(const std::string & message) throw ();
00058     };
00059 
00060 #include <paludis/stage_options-sr.hh>
00061 
00062     /**
00063      * Represents the base class for all stages which can be build by
00064      * StageBuilderTask.
00065      *
00066      * \ingroup g_tasks
00067      * \nosubgrouping
00068      */
00069     class PALUDIS_VISIBLE StageBase
00070     {
00071         public:
00072             virtual ~StageBase();
00073 
00074             /// Build the stage.
00075             virtual int build(const StageOptions &) const = 0;
00076 
00077             /// Verbose description for this stage.
00078             virtual std::string description() const = 0;
00079 
00080             /// Has this stage ever been built before?
00081             virtual bool is_rebuild() const = 0;
00082 
00083             /// Short name for this stage.
00084             virtual std::string short_name() const = 0;
00085     };
00086 
00087     /**
00088      * Task to handle building for of one or more descendants of StageBase.
00089      *
00090      * \ingroup g_tasks
00091      * \nosubgrouping
00092      */
00093     class PALUDIS_VISIBLE StageBuilderTask :
00094         PrivateImplementationPattern<StageBuilderTask>,
00095         InstantiationPolicy<StageBuilderTask, instantiation_method::NonCopyableTag>
00096     {
00097         protected:
00098             ///\name Basic operations
00099             ///\{
00100 
00101             StageBuilderTask(const StageOptions &);
00102 
00103             ///\}
00104 
00105         public:
00106             ///\name Basic operations
00107             ///\{
00108 
00109             virtual ~StageBuilderTask();
00110 
00111             ///\}
00112 
00113             ///\name Queue stage in build list
00114             ///\{
00115 
00116             void queue_stage(const std::tr1::shared_ptr<const StageBase> &);
00117 
00118             ///\}
00119 
00120             ///\name Iterate over our stages
00121             ///\{
00122 
00123             struct StageConstIteratorTag;
00124             typedef WrappedForwardIterator<StageConstIteratorTag, const std::tr1::shared_ptr<const StageBase> > StageConstIterator;
00125             StageConstIterator begin_stages() const;
00126             StageConstIterator end_stages() const;
00127 
00128             ///\}
00129 
00130             ///\name Event callbacks
00131             ///\{
00132 
00133             virtual void on_build_all_pre() = 0;
00134             virtual void on_build_pre(const std::tr1::shared_ptr<const StageBase> &) = 0;
00135             virtual void on_build_post(const std::tr1::shared_ptr<const StageBase> &) = 0;
00136             virtual void on_build_fail(const std::tr1::shared_ptr<const StageBase> &, const StageBuildError &) = 0;
00137             virtual void on_build_skipped(const std::tr1::shared_ptr<const StageBase> &) = 0;
00138             virtual void on_build_succeed(const std::tr1::shared_ptr<const StageBase> &) = 0;
00139             virtual void on_build_all_post() = 0;
00140 
00141             ///\}
00142 
00143             /**
00144              * Run the task
00145              */
00146 
00147             void execute();
00148     };
00149 }
00150 
00151 #endif

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