hooker.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 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_HOOKER_HH
00021 #define PALUDIS_GUARD_PALUDIS_HOOKER_HH 1
00022 
00023 #include <paludis/util/instantiation_policy.hh>
00024 #include <paludis/util/private_implementation_pattern.hh>
00025 #include <paludis/util/graph-fwd.hh>
00026 #include <paludis/util/sequence-fwd.hh>
00027 #include <tr1/memory>
00028 #include <string>
00029 
00030 /** \file
00031  * Declarations for the Hooker class, which is used to run hooks.
00032  *
00033  * \ingroup g_hooks
00034  *
00035  * \section Examples
00036  *
00037  * - None at this time.
00038  */
00039 
00040 namespace paludis
00041 {
00042     class FSEntry;
00043     class Environment;
00044     class Hook;
00045     class HookResult;
00046 
00047     /**
00048      * A HookFile provides an abstraction of a hook file.
00049      *
00050      * \ingroup g_hooks
00051      * \nosubgrouping
00052      */
00053     class PALUDIS_VISIBLE HookFile :
00054         private InstantiationPolicy<HookFile, instantiation_method::NonCopyableTag>
00055     {
00056         public:
00057             ///\name Basic operations
00058             ///\{
00059 
00060             virtual ~HookFile();
00061 
00062             ///\}
00063 
00064             virtual HookResult run(const Hook &) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
00065             virtual const FSEntry file_name() const = 0;
00066             virtual void add_dependencies(const Hook &, DirectedGraph<std::string, int> &) = 0;
00067             virtual const std::tr1::shared_ptr<const Sequence<std::string> > auto_hook_names() const = 0;
00068     };
00069 
00070     /**
00071      * Handles executing hooks.
00072      *
00073      * \ingroup g_hooks
00074      * \nosubgrouping
00075      */
00076     class PALUDIS_VISIBLE Hooker :
00077         private PrivateImplementationPattern<Hooker>,
00078         private InstantiationPolicy<Hooker, instantiation_method::NonCopyableTag>
00079     {
00080         private:
00081             std::tr1::shared_ptr<Sequence<std::tr1::shared_ptr<HookFile> > > _find_hooks(const Hook &) const;
00082 
00083         public:
00084             ///\name Basic operations
00085             ///\{
00086 
00087             Hooker(const Environment * const) PALUDIS_ATTRIBUTE((nonnull(1)));
00088             ~Hooker();
00089 
00090             ///\}
00091 
00092             /**
00093              * Perform a hook, return HookResult.
00094              */
00095             HookResult perform_hook(const Hook &) const PALUDIS_ATTRIBUTE((warn_unused_result));
00096 
00097             /**
00098              * Add a new hook directory.
00099              */
00100             void add_dir(const FSEntry &, const bool output_prefixed);
00101     };
00102 }
00103 
00104 #endif

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