00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PALUDIS_GUARD_PALUDIS_CHOICE_HH
00021 #define PALUDIS_GUARD_PALUDIS_CHOICE_HH 1
00022
00023 #include <paludis/choice-fwd.hh>
00024 #include <paludis/util/attributes.hh>
00025 #include <paludis/util/wrapped_forward_iterator-fwd.hh>
00026 #include <paludis/util/private_implementation_pattern.hh>
00027 #include <paludis/util/exception.hh>
00028 #include <paludis/util/named_value.hh>
00029 #include <paludis/util/validated.hh>
00030 #include <tr1/memory>
00031 #include <string>
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 namespace paludis
00045 {
00046 namespace n
00047 {
00048 struct consider_added_or_changed;
00049 struct contains_every_value;
00050 struct hidden;
00051 struct human_name;
00052 struct prefix;
00053 struct raw_name;
00054 struct show_with_no_prefix;
00055 }
00056
00057
00058
00059
00060
00061
00062
00063
00064 class PALUDIS_VISIBLE ChoicePrefixNameError :
00065 public NameError
00066 {
00067 public:
00068 ChoicePrefixNameError(const std::string &) throw ();
00069 };
00070
00071
00072
00073
00074
00075
00076
00077
00078 class PALUDIS_VISIBLE ChoiceNameWithPrefixError :
00079 public NameError
00080 {
00081 public:
00082 ChoiceNameWithPrefixError(const std::string &) throw ();
00083 };
00084
00085
00086
00087
00088
00089
00090
00091
00092 class PALUDIS_VISIBLE UnprefixedChoiceNameError :
00093 public NameError
00094 {
00095 public:
00096 UnprefixedChoiceNameError(const std::string &) throw ();
00097 };
00098
00099
00100
00101
00102
00103
00104
00105 struct PALUDIS_VISIBLE ChoicePrefixNameValidator :
00106 private InstantiationPolicy<ChoicePrefixNameValidator, instantiation_method::NonInstantiableTag>
00107 {
00108
00109
00110
00111
00112 static void validate(const std::string &);
00113 };
00114
00115
00116
00117
00118
00119
00120
00121 struct PALUDIS_VISIBLE ChoiceNameWithPrefixValidator :
00122 private InstantiationPolicy<ChoiceNameWithPrefixValidator, instantiation_method::NonInstantiableTag>
00123 {
00124
00125
00126
00127
00128 static void validate(const std::string &);
00129 };
00130
00131
00132
00133
00134
00135
00136
00137 struct PALUDIS_VISIBLE UnprefixedChoiceNameValidator :
00138 private InstantiationPolicy<UnprefixedChoiceNameValidator, instantiation_method::NonInstantiableTag>
00139 {
00140
00141
00142
00143
00144 static void validate(const std::string &);
00145 };
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 class PALUDIS_VISIBLE Choices :
00159 private PrivateImplementationPattern<Choices>
00160 {
00161 public:
00162
00163
00164
00165 Choices();
00166 ~Choices();
00167
00168
00169
00170
00171
00172
00173 void add(const std::tr1::shared_ptr<const Choice> &);
00174
00175
00176
00177
00178 struct ConstIteratorTag;
00179 typedef WrappedForwardIterator<ConstIteratorTag, const std::tr1::shared_ptr<const Choice> > ConstIterator;
00180 ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result));
00181 ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result));
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 const std::tr1::shared_ptr<const ChoiceValue> find_by_name_with_prefix(
00196 const ChoiceNameWithPrefix &) const PALUDIS_ATTRIBUTE((warn_unused_result));
00197
00198
00199
00200
00201
00202
00203
00204
00205 bool has_matching_contains_every_value_prefix(const ChoiceNameWithPrefix &) const PALUDIS_ATTRIBUTE((warn_unused_result));
00206 };
00207
00208
00209
00210
00211
00212
00213
00214 struct ChoiceParams
00215 {
00216 NamedValue<n::consider_added_or_changed, bool> consider_added_or_changed;
00217 NamedValue<n::contains_every_value, bool> contains_every_value;
00218 NamedValue<n::hidden, bool> hidden;
00219 NamedValue<n::human_name, std::string> human_name;
00220 NamedValue<n::prefix, ChoicePrefixName> prefix;
00221 NamedValue<n::raw_name, std::string> raw_name;
00222 NamedValue<n::show_with_no_prefix, bool> show_with_no_prefix;
00223 };
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 class PALUDIS_VISIBLE Choice :
00235 private PrivateImplementationPattern<Choice>
00236 {
00237 public:
00238
00239
00240
00241
00242 Choice(const ChoiceParams &);
00243 ~Choice();
00244
00245
00246
00247
00248
00249
00250 void add(const std::tr1::shared_ptr<const ChoiceValue> &);
00251
00252
00253
00254
00255
00256
00257
00258 const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
00259
00260
00261
00262
00263 const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
00264
00265
00266
00267
00268
00269
00270 const ChoicePrefixName prefix() const PALUDIS_ATTRIBUTE((warn_unused_result));
00271
00272
00273
00274
00275
00276
00277
00278
00279 bool contains_every_value() const PALUDIS_ATTRIBUTE((warn_unused_result));
00280
00281
00282
00283
00284 bool hidden() const PALUDIS_ATTRIBUTE((warn_unused_result));
00285
00286
00287
00288
00289
00290
00291
00292 bool show_with_no_prefix() const PALUDIS_ATTRIBUTE((warn_unused_result));
00293
00294
00295
00296
00297
00298
00299
00300 bool consider_added_or_changed() const PALUDIS_ATTRIBUTE((warn_unused_result));
00301
00302
00303
00304
00305
00306
00307 struct ConstIteratorTag;
00308 typedef WrappedForwardIterator<ConstIteratorTag, const std::tr1::shared_ptr<const ChoiceValue> > ConstIterator;
00309 ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result));
00310 ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result));
00311
00312
00313 };
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326 class PALUDIS_VISIBLE ChoiceValue
00327 {
00328 public:
00329
00330
00331
00332 virtual ~ChoiceValue() = 0;
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342 virtual const UnprefixedChoiceName unprefixed_name() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
00343
00344
00345
00346
00347 virtual const ChoiceNameWithPrefix name_with_prefix() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
00348
00349
00350
00351
00352 virtual bool enabled() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
00353
00354
00355
00356
00357
00358 virtual bool enabled_by_default() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
00359
00360
00361
00362
00363 virtual bool locked() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
00364
00365
00366
00367
00368 virtual const std::string description() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
00369
00370
00371
00372
00373
00374
00375
00376 virtual bool explicitly_listed() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
00377
00378
00379
00380
00381
00382
00383 virtual const std::string parameter() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
00384
00385
00386 };
00387
00388 #ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
00389 extern template class PrivateImplementationPattern<Choices>;
00390 extern template class PrivateImplementationPattern<Choice>;
00391 #endif
00392 }
00393
00394 #endif