00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PALUDIS_GUARD_PALUDIS_ACTION_HH
00021 #define PALUDIS_GUARD_PALUDIS_ACTION_HH 1
00022
00023 #include <paludis/action-fwd.hh>
00024 #include <paludis/repository-fwd.hh>
00025 #include <paludis/package_id-fwd.hh>
00026 #include <paludis/util/attributes.hh>
00027 #include <paludis/util/simple_visitor.hh>
00028 #include <paludis/util/exception.hh>
00029 #include <paludis/util/private_implementation_pattern.hh>
00030 #include <paludis/util/sequence-fwd.hh>
00031 #include <paludis/util/named_value.hh>
00032 #include <paludis/util/fs_entry-fwd.hh>
00033 #include <paludis/output_manager-fwd.hh>
00034 #include <paludis/util/type_list.hh>
00035 #include <tr1/functional>
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 namespace paludis
00048 {
00049 namespace n
00050 {
00051 struct config_protect;
00052 struct destination;
00053 struct exclude_unmirrorable;
00054 struct failed_automatic_fetching;
00055 struct failed_integrity_checks;
00056 struct fetch_unneeded;
00057 struct if_for_install_id;
00058 struct ignore_for_unmerge;
00059 struct ignore_unfetched;
00060 struct is_overwrite;
00061 struct make_output_manager;
00062 struct perform_uninstall;
00063 struct replacing;
00064 struct requires_manual_fetching;
00065 struct safe_resume;
00066 struct target_file;
00067 struct want_phase;
00068 }
00069
00070
00071
00072
00073
00074
00075
00076
00077 struct FetchActionOptions
00078 {
00079
00080
00081
00082 NamedValue<n::exclude_unmirrorable, bool> exclude_unmirrorable;
00083
00084 NamedValue<n::fetch_unneeded, bool> fetch_unneeded;
00085
00086
00087
00088
00089
00090
00091
00092
00093 NamedValue<n::ignore_unfetched, bool> ignore_unfetched;
00094
00095
00096
00097
00098
00099
00100
00101 NamedValue<n::make_output_manager, std::tr1::function<std::tr1::shared_ptr<OutputManager> (
00102 const FetchAction &)> > make_output_manager;
00103
00104
00105 NamedValue<n::safe_resume, bool> safe_resume;
00106 };
00107
00108
00109
00110
00111
00112
00113
00114
00115 struct InstallActionOptions
00116 {
00117 NamedValue<n::destination, std::tr1::shared_ptr<Repository> > destination;
00118
00119
00120
00121
00122
00123
00124
00125 NamedValue<n::make_output_manager, std::tr1::function<std::tr1::shared_ptr<OutputManager> (
00126 const InstallAction &)> > make_output_manager;
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 NamedValue<n::perform_uninstall, std::tr1::function<void (
00138 const std::tr1::shared_ptr<const PackageID> &,
00139 const UninstallActionOptions &
00140 )> > perform_uninstall;
00141
00142
00143
00144
00145
00146
00147 NamedValue<n::replacing, std::tr1::shared_ptr<const PackageIDSequence> > replacing;
00148
00149 NamedValue<n::want_phase, std::tr1::function<WantPhase (const std::string &)> > want_phase;
00150 };
00151
00152
00153
00154
00155
00156
00157
00158
00159 struct UninstallActionOptions
00160 {
00161 NamedValue<n::config_protect, std::string> config_protect;
00162
00163
00164
00165
00166
00167
00168
00169 NamedValue<n::if_for_install_id, std::tr1::shared_ptr<const PackageID> > if_for_install_id;
00170
00171
00172
00173
00174
00175
00176 NamedValue<n::ignore_for_unmerge, std::tr1::function<bool (const FSEntry &)> > ignore_for_unmerge;
00177
00178
00179
00180
00181
00182
00183
00184 NamedValue<n::is_overwrite, bool> is_overwrite;
00185
00186
00187
00188
00189
00190
00191
00192 NamedValue<n::make_output_manager, std::tr1::function<std::tr1::shared_ptr<OutputManager> (
00193 const UninstallAction &)> > make_output_manager;
00194 };
00195
00196
00197
00198
00199
00200
00201
00202
00203 struct FetchActionFailure
00204 {
00205 NamedValue<n::failed_automatic_fetching, bool> failed_automatic_fetching;
00206 NamedValue<n::failed_integrity_checks, std::string> failed_integrity_checks;
00207 NamedValue<n::requires_manual_fetching, bool> requires_manual_fetching;
00208 NamedValue<n::target_file, std::string> target_file;
00209 };
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 class PALUDIS_VISIBLE Action :
00220 public virtual DeclareAbstractAcceptMethods<Action, MakeTypeList<
00221 InstallAction, InstalledAction, UninstallAction, PretendAction, ConfigAction, FetchAction,
00222 InfoAction, PretendFetchAction>::Type>
00223 {
00224 public:
00225
00226
00227
00228 virtual ~Action() = 0;
00229
00230
00231 };
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 class PALUDIS_VISIBLE InstallAction :
00242 public Action,
00243 private PrivateImplementationPattern<InstallAction>,
00244 public ImplementAcceptMethods<Action, InstallAction>
00245 {
00246 public:
00247
00248
00249
00250 InstallAction(const InstallActionOptions &);
00251 ~InstallAction();
00252
00253
00254
00255
00256 const InstallActionOptions & options;
00257 };
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 class PALUDIS_VISIBLE FetchAction :
00268 public Action,
00269 private PrivateImplementationPattern<FetchAction>,
00270 public ImplementAcceptMethods<Action, FetchAction>
00271 {
00272 public:
00273
00274
00275
00276 FetchAction(const FetchActionOptions &);
00277 ~FetchAction();
00278
00279
00280
00281
00282 const FetchActionOptions & options;
00283 };
00284
00285
00286
00287
00288
00289
00290
00291
00292 class PALUDIS_VISIBLE UninstallAction :
00293 public Action,
00294 private PrivateImplementationPattern<UninstallAction>,
00295 public ImplementAcceptMethods<Action, UninstallAction>
00296 {
00297 public:
00298
00299
00300
00301 UninstallAction(const UninstallActionOptions &);
00302 ~UninstallAction();
00303
00304
00305
00306
00307 const UninstallActionOptions & options;
00308 };
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320 class PALUDIS_VISIBLE InstalledAction :
00321 public Action,
00322 public ImplementAcceptMethods<Action, InstalledAction>
00323 {
00324 };
00325
00326
00327
00328
00329
00330
00331
00332
00333 struct PretendActionOptions
00334 {
00335
00336
00337
00338
00339
00340
00341 NamedValue<n::make_output_manager, std::tr1::function<std::tr1::shared_ptr<OutputManager> (
00342 const PretendAction &)> > make_output_manager;
00343 };
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353 class PALUDIS_VISIBLE PretendAction :
00354 public Action,
00355 private PrivateImplementationPattern<PretendAction>,
00356 public ImplementAcceptMethods<Action, PretendAction>
00357 {
00358 public:
00359
00360
00361
00362
00363
00364
00365 PretendAction(const PretendActionOptions &);
00366 ~PretendAction();
00367
00368
00369
00370
00371 bool failed() const PALUDIS_ATTRIBUTE((warn_unused_result));
00372
00373
00374 void set_failed();
00375
00376
00377
00378
00379 const PretendActionOptions & options;
00380 };
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390 class PALUDIS_VISIBLE PretendFetchAction :
00391 public Action,
00392 private PrivateImplementationPattern<PretendFetchAction>,
00393 public ImplementAcceptMethods<Action, PretendFetchAction>
00394 {
00395 public:
00396
00397
00398
00399 PretendFetchAction(const FetchActionOptions &);
00400 ~PretendFetchAction();
00401
00402
00403
00404
00405 const FetchActionOptions & options;
00406
00407
00408 virtual void will_fetch(const FSEntry & destination, const unsigned long size_in_bytes) = 0;
00409 };
00410
00411
00412
00413
00414
00415
00416
00417
00418 struct ConfigActionOptions
00419 {
00420
00421
00422
00423
00424
00425
00426 NamedValue<n::make_output_manager, std::tr1::function<std::tr1::shared_ptr<OutputManager> (
00427 const ConfigAction &)> > make_output_manager;
00428 };
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439 class PALUDIS_VISIBLE ConfigAction :
00440 public Action,
00441 private PrivateImplementationPattern<ConfigAction>,
00442 public ImplementAcceptMethods<Action, ConfigAction>
00443 {
00444 public:
00445
00446
00447
00448
00449
00450
00451 ConfigAction(const ConfigActionOptions &);
00452 ~ConfigAction();
00453
00454
00455
00456
00457
00458
00459 const ConfigActionOptions & options;
00460 };
00461
00462
00463
00464
00465
00466
00467
00468
00469 struct InfoActionOptions
00470 {
00471
00472
00473
00474
00475
00476
00477 NamedValue<n::make_output_manager, std::tr1::function<std::tr1::shared_ptr<OutputManager> (
00478 const InfoAction &)> > make_output_manager;
00479 };
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494 class PALUDIS_VISIBLE InfoAction:
00495 public Action,
00496 private PrivateImplementationPattern<InfoAction>,
00497 public ImplementAcceptMethods<Action, InfoAction>
00498 {
00499 public:
00500
00501
00502
00503
00504
00505
00506 InfoAction(const InfoActionOptions &);
00507
00508 ~InfoAction();
00509
00510
00511
00512
00513
00514
00515 const InfoActionOptions & options;
00516 };
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526 class PALUDIS_VISIBLE SupportsActionTestBase :
00527 public virtual DeclareAbstractAcceptMethods<SupportsActionTestBase, MakeTypeList<
00528 SupportsActionTest<InstallAction>, SupportsActionTest<InstalledAction>, SupportsActionTest<UninstallAction>,
00529 SupportsActionTest<PretendAction>, SupportsActionTest<ConfigAction>, SupportsActionTest<FetchAction>,
00530 SupportsActionTest<InfoAction>, SupportsActionTest<PretendFetchAction> >::Type>
00531 {
00532 public:
00533 virtual ~SupportsActionTestBase() = 0;
00534 };
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551 template <typename A_>
00552 class PALUDIS_VISIBLE SupportsActionTest :
00553 public SupportsActionTestBase,
00554 public ImplementAcceptMethods<SupportsActionTestBase, SupportsActionTest<A_> >
00555 {
00556 };
00557
00558
00559
00560
00561
00562
00563
00564
00565 std::ostream & operator<< (std::ostream &, const Action &) PALUDIS_VISIBLE;
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575 class PALUDIS_VISIBLE ActionError :
00576 public Exception
00577 {
00578 public:
00579
00580
00581
00582 ActionError(const std::string & msg) throw ();
00583
00584
00585 };
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596 class PALUDIS_VISIBLE UnsupportedActionError :
00597 public ActionError
00598 {
00599 public:
00600
00601
00602
00603 UnsupportedActionError(const PackageID &, const Action &) throw ();
00604
00605
00606 };
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616 class PALUDIS_VISIBLE InstallActionError : public ActionError
00617 {
00618 public:
00619
00620
00621
00622 InstallActionError(const std::string & msg) throw ();
00623
00624
00625 };
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635 class PALUDIS_VISIBLE FetchActionError :
00636 public ActionError
00637 {
00638 private:
00639 const std::tr1::shared_ptr<const Sequence<FetchActionFailure> > _failures;
00640
00641 public:
00642
00643
00644
00645 FetchActionError(const std::string &) throw ();
00646 FetchActionError(const std::string &, const std::tr1::shared_ptr<const Sequence<FetchActionFailure> > &) throw ();
00647 ~FetchActionError() throw ();
00648
00649
00650
00651
00652 const std::tr1::shared_ptr<const Sequence<FetchActionFailure> > failures() const PALUDIS_ATTRIBUTE((warn_unused_result));
00653 };
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663 class PALUDIS_VISIBLE UninstallActionError : public ActionError
00664 {
00665 public:
00666
00667
00668
00669 UninstallActionError(const std::string & msg) throw ();
00670
00671
00672 };
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682 class PALUDIS_VISIBLE ConfigActionError : public ActionError
00683 {
00684 public:
00685
00686
00687
00688 ConfigActionError(const std::string & msg) throw ();
00689
00690
00691 };
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701 class PALUDIS_VISIBLE InfoActionError : public ActionError
00702 {
00703 public:
00704
00705
00706
00707 InfoActionError(const std::string & msg) throw ();
00708
00709
00710 };
00711
00712 #ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
00713 extern template class PrivateImplementationPattern<FetchAction>;
00714 extern template class PrivateImplementationPattern<InstallAction>;
00715 extern template class PrivateImplementationPattern<PretendAction>;
00716 extern template class PrivateImplementationPattern<PretendFetchAction>;
00717 extern template class PrivateImplementationPattern<UninstallAction>;
00718 extern template class PrivateImplementationPattern<InfoAction>;
00719 extern template class PrivateImplementationPattern<ConfigAction>;
00720 #endif
00721 }
00722
00723 #endif