paludis  Version 2.6.0
hook.hh
Go to the documentation of this file.
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
5  * Copyright (c) 2007 Piotr JaroszyƄski
6  *
7  * This file is part of the Paludis package manager. Paludis is free software;
8  * you can redistribute it and/or modify it under the terms of the GNU General
9  * Public License version 2, as published by the Free Software Foundation.
10  *
11  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18  * Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 #ifndef PALUDIS_GUARD_PALUDIS_HOOK_HH
22 #define PALUDIS_GUARD_PALUDIS_HOOK_HH 1
23 
24 #include <paludis/hook-fwd.hh>
28 #include <paludis/util/pimp.hh>
29 #include <paludis/util/wrapped_forward_iterator.hh>
31 #include <paludis/util/named_value.hh>
32 #include <paludis/output_manager-fwd.hh>
33 #include <memory>
34 #include <string>
35 
36 /** \file
37  * Declarations for the Hook classes.
38  *
39  * \ingroup g_hooks
40  *
41  * \section Examples
42  *
43  * - None at this time.
44  */
45 
46 namespace paludis
47 {
48  namespace n
49  {
50  typedef Name<struct name_max_exit_status> max_exit_status;
51  typedef Name<struct name_output> output;
52  }
53 
54  /**
55  * Result of a Hook.
56  *
57  * \see Hook
58  * \ingroup g_hooks
59  * \nosubgrouping
60  */
61  struct HookResult
62  {
65  };
66 
67  /**
68  * Represents the data for a hook call.
69  *
70  * \see Environment::perform_hook
71  * \ingroup g_hooks
72  * \nosubgrouping
73  */
75  {
76  private:
77  Pimp<Hook> _imp;
78 
79  public:
80  ///\name Basic operations
81  ///\{
82 
83  class AllowedOutputValues;
84 
85  HookOutputDestination output_dest;
86 
87  Hook(const std::string & name);
88 
89  Hook(const Hook &);
90 
91  ~Hook();
92 
93  ///\}
94 
95  /// Add data to the hook.
96  Hook operator() (const std::string & key, const std::string & value) const
97  PALUDIS_ATTRIBUTE((warn_unused_result));
98 
99  /// Get data from the hook.
100  std::string get(const std::string & key) const
101  PALUDIS_ATTRIBUTE((warn_unused_result));
102 
103  Hook grab_output(const AllowedOutputValues & av);
104 
105  bool validate_value(const std::string & value) const;
106 
107  ///\name Iterate over environment data
108  ///\{
109 
110  struct ConstIteratorTag;
112 
113  ConstIterator begin() const
114  PALUDIS_ATTRIBUTE((warn_unused_result));
115 
116  ConstIterator end() const
117  PALUDIS_ATTRIBUTE((warn_unused_result));
118 
119  ///\}
120 
121  /// Our name.
122  std::string name() const
123  PALUDIS_ATTRIBUTE((warn_unused_result));
124  };
125 
126  /**
127  * Hooks with grabbed output can specify that only certain output values are
128  * allowed.
129  *
130  * \ingroup g_hooks
131  * \since 0.26
132  * \nosubgrouping
133  */
134  class PALUDIS_VISIBLE Hook::AllowedOutputValues
135  {
136  friend class Hook;
137 
138  private:
140 
141  public:
142  ///\name Basic operations
143  ///\{
144 
145  AllowedOutputValues();
146 
147  AllowedOutputValues(const AllowedOutputValues & other);
148 
149  ~AllowedOutputValues();
150 
151  ///\}
152 
153  /// Add a new allowed value.
154  AllowedOutputValues operator() (const std::string & v) const
155  PALUDIS_ATTRIBUTE((warn_unused_result));
156  };
157 
159 }
160 
161 extern "C" paludis::HookResult PALUDIS_VISIBLE paludis_hook_run_3(
162  const paludis::Environment *, const paludis::Hook &, const std::shared_ptr<paludis::OutputManager> &);
163 
164 extern "C" void PALUDIS_VISIBLE paludis_hook_add_dependencies(
166 
167 extern "C" const std::shared_ptr<const paludis::Sequence<std::string> > PALUDIS_VISIBLE paludis_hook_auto_phases(
168  const paludis::Environment *);
169 
170 #endif
Definition: pimp.hh:51
Definition: about_metadata-fwd.hh:23
Definition: hook.hh:61
Definition: environment.hh:200
Definition: hook.hh:74
Definition: wrapped_forward_iterator-fwd.hh:26
HookOutputDestination
Definition: hook-fwd.hh:13
Definition: graph-fwd.hh:37
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:53
#define PALUDIS_VISIBLE
Definition: attributes.hh:59