aboutsummaryrefslogtreecommitdiff
path: root/paludis/resolver/job_state.hh
blob: f8d4547ec8d9f0f48f29e34117c31208eee0f017 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* vim: set sw=4 sts=4 et foldmethod=syntax : */

/*
 * Copyright (c) 2010, 2011 Ciaran McCreesh
 *
 * This file is part of the Paludis package manager. Paludis is free software;
 * you can redistribute it and/or modify it under the terms of the GNU General
 * Public License version 2, as published by the Free Software Foundation.
 *
 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_JOB_STATE_HH
#define PALUDIS_GUARD_PALUDIS_RESOLVER_JOB_STATE_HH 1

#include <paludis/resolver/job_state-fwd.hh>
#include <paludis/util/visitor.hh>
#include <paludis/util/type_list.hh>
#include <paludis/util/pimp.hh>
#include <paludis/output_manager-fwd.hh>
#include <paludis/serialise-fwd.hh>
#include <memory>

namespace paludis
{
    namespace resolver
    {
        class PALUDIS_VISIBLE JobState :
            public virtual DeclareAbstractAcceptMethods<JobState, MakeTypeList<
                JobPendingState, JobActiveState, JobSucceededState, JobFailedState, JobSkippedState>::Type>
        {
            public:
                virtual ~JobState() = 0;

                virtual void serialise(Serialiser &) const = 0;
                static const std::shared_ptr<JobState> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
        };

        class PALUDIS_VISIBLE JobPendingState :
            public JobState,
            public ImplementAcceptMethods<JobState, JobPendingState>
        {
            public:
                virtual void serialise(Serialiser &) const;
                static const std::shared_ptr<JobPendingState> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
        };

        class PALUDIS_VISIBLE JobActiveState :
            public JobState,
            public ImplementAcceptMethods<JobState, JobActiveState>
        {
            private:
                Pimp<JobActiveState> _imp;

            public:
                JobActiveState();
                ~JobActiveState();

                void set_output_manager(const std::shared_ptr<OutputManager> &);
                const std::shared_ptr<JobSucceededState> succeeded() const PALUDIS_ATTRIBUTE((warn_unused_result));
                const std::shared_ptr<JobFailedState> failed() const PALUDIS_ATTRIBUTE((warn_unused_result));

                const std::shared_ptr<OutputManager> output_manager() const PALUDIS_ATTRIBUTE((warn_unused_result));

                virtual void serialise(Serialiser &) const;
                static const std::shared_ptr<JobActiveState> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
        };

        class PALUDIS_VISIBLE JobSucceededState :
            public JobState,
            public ImplementAcceptMethods<JobState, JobSucceededState>
        {
            private:
                Pimp<JobSucceededState> _imp;

            public:
                JobSucceededState(const std::shared_ptr<OutputManager> &);
                ~JobSucceededState();

                const std::shared_ptr<OutputManager> output_manager() const PALUDIS_ATTRIBUTE((warn_unused_result));

                virtual void serialise(Serialiser &) const;
                static const std::shared_ptr<JobSucceededState> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
        };

        class PALUDIS_VISIBLE JobFailedState :
            public JobState,
            public ImplementAcceptMethods<JobState, JobFailedState>
        {
            private:
                Pimp<JobFailedState> _imp;

            public:
                JobFailedState(const std::shared_ptr<OutputManager> &);
                ~JobFailedState();

                const std::shared_ptr<OutputManager> output_manager() const PALUDIS_ATTRIBUTE((warn_unused_result));

                virtual void serialise(Serialiser &) const;
                static const std::shared_ptr<JobFailedState> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
        };

        class PALUDIS_VISIBLE JobSkippedState :
            public JobState,
            public ImplementAcceptMethods<JobState, JobSkippedState>
        {
            public:
                virtual void serialise(Serialiser &) const;
                static const std::shared_ptr<JobSkippedState> deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
        };
    }
}

#endif