paludis  Version 2.6.0
hooker.hh
Go to the documentation of this file.
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2007, 2008, 2010, 2011 Ciaran McCreesh
5  *
6  * This file is part of the Paludis package manager. Paludis is free software;
7  * you can redistribute it and/or modify it under the terms of the GNU General
8  * Public License version 2, as published by the Free Software Foundation.
9  *
10  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17  * Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef PALUDIS_GUARD_PALUDIS_HOOKER_HH
21 #define PALUDIS_GUARD_PALUDIS_HOOKER_HH 1
22 
24 #include <paludis/util/pimp.hh>
27 #include <paludis/util/fs_path-fwd.hh>
28 #include <paludis/output_manager-fwd.hh>
29 #include <memory>
30 #include <string>
31 
32 /** \file
33  * Declarations for the Hooker class, which is used to run hooks.
34  *
35  * \ingroup g_hooks
36  *
37  * \section Examples
38  *
39  * - None at this time.
40  */
41 
42 namespace paludis
43 {
44  class Environment;
45  class Hook;
46  struct HookResult;
47 
48  /**
49  * A HookFile provides an abstraction of a hook file.
50  *
51  * \ingroup g_hooks
52  * \nosubgrouping
53  */
55  {
56  public:
57  ///\name Basic operations
58  ///\{
59 
60  HookFile() = default;
61  virtual ~HookFile();
62 
63  HookFile(const HookFile &) = delete;
64  HookFile & operator= (const HookFile &) = delete;
65 
66  ///\}
67 
68  /**
69  * \since 0.53 takes optional_output_manager
70  */
71  virtual HookResult run(
72  const Hook &,
73  const std::shared_ptr<OutputManager> & optional_output_manager) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
74 
75  virtual const FSPath file_name() const = 0;
76 
77  virtual void add_dependencies(const Hook &, DirectedGraph<std::string, int> &) = 0;
78 
79  virtual const std::shared_ptr<const Sequence<std::string> > auto_hook_names() const = 0;
80  };
81 
82  /**
83  * Handles executing hooks.
84  *
85  * \ingroup g_hooks
86  * \nosubgrouping
87  */
89  {
90  private:
91  Pimp<Hooker> _imp;
92 
93  std::shared_ptr<Sequence<std::shared_ptr<HookFile> > > _find_hooks(const Hook &) const;
94 
95  public:
96  ///\name Basic operations
97  ///\{
98 
99  Hooker(const Environment * const) PALUDIS_ATTRIBUTE((nonnull(2)));
100  ~Hooker();
101 
102  Hooker(const Hooker &) = delete;
103  Hooker & operator= (const Hooker &) = delete;
104 
105  ///\}
106 
107  /**
108  * Perform a hook, return HookResult.
109  *
110  * \since 0.53 takes optional_output_manager
111  */
112  HookResult perform_hook(
113  const Hook &,
114  const std::shared_ptr<OutputManager> & optional_output_manager) const PALUDIS_ATTRIBUTE((warn_unused_result));
115 
116  /**
117  * Add a new hook directory.
118  */
119  void add_dir(const FSPath &, const bool output_prefixed);
120  };
121 }
122 
123 #endif
Definition: pimp.hh:51
Definition: about_metadata-fwd.hh:23
Definition: hooker.hh:88
Definition: hooker.hh:54
Definition: hook.hh:61
Definition: environment.hh:200
Definition: hook.hh:74
Definition: fs_path.hh:33
Definition: graph-fwd.hh:37
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:53
#define PALUDIS_VISIBLE
Definition: attributes.hh:59