paludis Version 3.0.2
The one true package mangler
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
42namespace 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 */
54 class PALUDIS_VISIBLE HookFile
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 */
88 class PALUDIS_VISIBLE Hooker
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 */
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 graph.hh:151
Definition environment.hh:203
Definition fs_path.hh:34
virtual HookResult run(const Hook &, const std::shared_ptr< OutputManager > &optional_output_manager) const PALUDIS_ATTRIBUTE((warn_unused_result))=0
Definition hook.hh:75
HookResult perform_hook(const Hook &, const std::shared_ptr< OutputManager > &optional_output_manager) const PALUDIS_ATTRIBUTE((warn_unused_result))
void add_dir(const FSPath &, const bool output_prefixed)
Definition pimp.hh:52
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24
Definition hook.hh:62