paludis  Version 2.6.0
slot_requirement.hh
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2008, 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_SLOT_REQUIREMENT_HH
21 #define PALUDIS_GUARD_PALUDIS_SLOT_REQUIREMENT_HH 1
22 
23 #include <paludis/slot_requirement-fwd.hh>
24 #include <paludis/name-fwd.hh>
25 #include <paludis/util/visitor.hh>
26 #include <paludis/util/type_list.hh>
27 #include <memory>
28 
29 namespace paludis
30 {
31  /**
32  * A SlotRequirement represents a PackageDepSpec's slot
33  * requirement, such as <code>:3</code>, <code>:*</code>,
34  * <code>:=</code> or <code>:=3</code>.
35  *
36  * \ingroup g_dep_spec
37  */
39  public virtual DeclareAbstractAcceptMethods<SlotRequirement, MakeTypeList<
40  SlotExactPartialRequirement, SlotExactFullRequirement, SlotAnyAtAllLockedRequirement, SlotAnyPartialLockedRequirement, SlotAnyUnlockedRequirement, SlotUnknownRewrittenRequirement>::Type>
41  {
42  public:
43  /**
44  * String representation, including the leading colon. Not suitable
45  * for parsing.
46  */
47  virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
48 
49  /**
50  * If we are a rewritten slot, return what the original requirement
51  * would have been; otherwise, returns null.
52  *
53  * \since 0.79
54  */
55  virtual const std::shared_ptr<const SlotRequirement> maybe_original_requirement_if_rewritten() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
56  };
57 
58  /**
59  * A SlotExactPartialRequirement is a SlotRequirement for exact slot
60  * requirements on the main part of the slot, such as <code>:3</code> or
61  * <code>:3=3</code>.
62  *
63  * \ingroup g_dep_spec
64  */
66  public SlotRequirement,
67  public ImplementAcceptMethods<SlotRequirement, SlotExactPartialRequirement>
68  {
69  public:
70  /**
71  * The slot in question.
72  */
73  virtual const SlotName slot() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
74  };
75 
76  /**
77  * A SlotExactFullRequirement is a SlotRequirement for exact slot
78  * requirements on both parts of the slot, such as <code>:3/4</code>
79  * or <code>:3=3/4</code>.
80  *
81  * \ingroup g_dep_spec
82  */
84  public SlotRequirement,
85  public ImplementAcceptMethods<SlotRequirement, SlotExactFullRequirement>
86  {
87  public:
88  /**
89  * The slot parts in question.
90  */
91  virtual const std::pair<SlotName, SlotName> slots() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
92  };
93 
94  /**
95  * A SlotAnyAtAllLockedRequirement is a SlotRequirement for
96  * <code>:=</code> slot requirements.
97  *
98  * \ingroup g_dep_spec
99  */
101  public SlotRequirement,
102  public ImplementAcceptMethods<SlotRequirement, SlotAnyAtAllLockedRequirement>
103  {
104  };
105 
106  /**
107  * A SlotAnyPartialLockedRequirement is a SlotRequirement for
108  * <code>:3=</code> slot requirements that do not specify a sub-slot.
109  *
110  * \ingroup g_dep_spec
111  */
113  public SlotRequirement,
114  public ImplementAcceptMethods<SlotRequirement, SlotAnyPartialLockedRequirement>
115  {
116  public:
117  /**
118  * The slot in question.
119  */
120  virtual const SlotName slot() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
121  };
122 
123  /**
124  * A SlotAnyUnlockedRequirement is a SlotRequirement for
125  * <code>:*</code> slot requirements.
126  *
127  * \ingroup g_dep_spec
128  */
130  public SlotRequirement,
131  public ImplementAcceptMethods<SlotRequirement, SlotAnyUnlockedRequirement>
132  {
133  };
134 
135  /**
136  * A SlotUnknownRewrittenRequirement is a SlotRequirement for the
137  * <code>maybe_original_requirement_if_written()</code> method of
138  * <code>:3/3.1=</code> slot requirements that do not indicate whether
139  * they were originally of <code>:=</code> or <code>:3=</code> type.
140  *
141  * \ingroup g_dep_spec
142  */
144  public SlotRequirement,
145  public ImplementAcceptMethods<SlotRequirement, SlotUnknownRewrittenRequirement>
146  {
147  public:
148  /**
149  * The slot that the original spec might have specified, if
150  * it was of <code>:3=</code> type.
151  */
152  virtual const SlotName slot() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
153  };
154 }
155 
156 #endif
Definition: about_metadata-fwd.hh:23
Definition: visitor-fwd.hh:52
Definition: slot_requirement.hh:83
Definition: slot_requirement.hh:65
Definition: wrapped_value-fwd.hh:29
Definition: slot_requirement.hh:129
Definition: slot_requirement.hh:112
Definition: slot_requirement.hh:100
Definition: visitor-fwd.hh:49
Definition: slot_requirement.hh:38
Definition: slot_requirement.hh:143
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:53
#define PALUDIS_VISIBLE
Definition: attributes.hh:59