aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-24 19:26:33 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-24 19:26:33 +0000
commit8cb83fa3d60d73cfb37afc79ab3c7cdd95b2429d (patch)
treec9eb98873748df6d53a43e91e0fd82529f858fa5
parente70149061e11dfe3dd2abd7db6846e246b1e771b (diff)
downloadpaludis-8cb83fa3d60d73cfb37afc79ab3c7cdd95b2429d.tar.gz
paludis-8cb83fa3d60d73cfb37afc79ab3c7cdd95b2429d.tar.xz
Move states to resolver/
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/job_state-fwd.hh35
-rw-r--r--paludis/resolver/job_state.cc180
-rw-r--r--paludis/resolver/job_state.hh114
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc129
5 files changed, 334 insertions, 126 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index e3c5a7b..f479e56 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -27,6 +27,7 @@ noinst_HEADERS = \
constraint.hh constraint-fwd.hh \
job.hh job-fwd.hh \
job_id.hh job_id-fwd.hh \
+ job_state.hh job_state-fwd.hh \
jobs.hh jobs-fwd.hh \
decider.hh decider-fwd.hh \
decision.hh decision-fwd.hh \
@@ -59,6 +60,7 @@ libpaludisresolver_a_SOURCES = \
failure_kinds.cc \
job.cc \
job_id.cc \
+ job_state.cc \
jobs.cc \
orderer.cc \
reason.cc \
diff --git a/paludis/resolver/job_state-fwd.hh b/paludis/resolver/job_state-fwd.hh
new file mode 100644
index 0000000..fab624e
--- /dev/null
+++ b/paludis/resolver/job_state-fwd.hh
@@ -0,0 +1,35 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 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_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_JOB_STATE_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct JobState;
+ struct JobPendingState;
+ struct JobSucceededState;
+ struct JobFailedState;
+ struct JobSkippedState;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/job_state.cc b/paludis/resolver/job_state.cc
new file mode 100644
index 0000000..60afc2c
--- /dev/null
+++ b/paludis/resolver/job_state.cc
@@ -0,0 +1,180 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 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
+ */
+
+#include <paludis/resolver/job_state.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <list>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+JobState::~JobState()
+{
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<JobPendingState>
+ {
+ const std::tr1::shared_ptr<const Job> job;
+
+ Implementation(const std::tr1::shared_ptr<const Job> & j) :
+ job(j)
+ {
+ }
+ };
+
+ template <>
+ struct Implementation<JobSucceededState>
+ {
+ const std::tr1::shared_ptr<const Job> job;
+ std::list<std::tr1::shared_ptr<OutputManager> > output_managers;
+
+ Implementation(const std::tr1::shared_ptr<const Job> & j) :
+ job(j)
+ {
+ }
+ };
+
+ template <>
+ struct Implementation<JobFailedState>
+ {
+ const std::tr1::shared_ptr<const Job> job;
+ std::list<std::tr1::shared_ptr<OutputManager> > output_managers;
+
+ Implementation(const std::tr1::shared_ptr<const Job> & j) :
+ job(j)
+ {
+ }
+ };
+
+ template <>
+ struct Implementation<JobSkippedState>
+ {
+ const std::tr1::shared_ptr<const Job> job;
+
+ Implementation(const std::tr1::shared_ptr<const Job> & j) :
+ job(j)
+ {
+ }
+ };
+}
+
+JobPendingState::JobPendingState(const std::tr1::shared_ptr<const Job> & j) :
+ PrivateImplementationPattern<JobPendingState>(new Implementation<JobPendingState>(j))
+{
+}
+
+JobPendingState::~JobPendingState()
+{
+}
+
+const std::tr1::shared_ptr<const Job>
+JobPendingState::job() const
+{
+ return _imp->job;
+}
+
+const std::string
+JobPendingState::state_name() const
+{
+ return "pending";
+}
+
+JobSucceededState::JobSucceededState(const std::tr1::shared_ptr<const Job> & j) :
+ PrivateImplementationPattern<JobSucceededState>(new Implementation<JobSucceededState>(j))
+{
+}
+
+JobSucceededState::~JobSucceededState()
+{
+}
+
+const std::tr1::shared_ptr<const Job>
+JobSucceededState::job() const
+{
+ return _imp->job;
+}
+
+const std::string
+JobSucceededState::state_name() const
+{
+ return "succeeded";
+}
+
+void
+JobSucceededState::add_output_manager(const std::tr1::shared_ptr<OutputManager> & o)
+{
+ _imp->output_managers.push_back(o);
+}
+
+JobFailedState::JobFailedState(const std::tr1::shared_ptr<const Job> & j) :
+ PrivateImplementationPattern<JobFailedState>(new Implementation<JobFailedState>(j))
+{
+}
+
+JobFailedState::~JobFailedState()
+{
+}
+
+const std::tr1::shared_ptr<const Job>
+JobFailedState::job() const
+{
+ return _imp->job;
+}
+
+void
+JobFailedState::add_output_manager(const std::tr1::shared_ptr<OutputManager> & o)
+{
+ _imp->output_managers.push_back(o);
+}
+
+const std::string
+JobFailedState::state_name() const
+{
+ return "failed";
+}
+
+JobSkippedState::JobSkippedState(const std::tr1::shared_ptr<const Job> & j) :
+ PrivateImplementationPattern<JobSkippedState>(new Implementation<JobSkippedState>(j))
+{
+}
+
+JobSkippedState::~JobSkippedState()
+{
+}
+
+const std::tr1::shared_ptr<const Job>
+JobSkippedState::job() const
+{
+ return _imp->job;
+}
+
+const std::string
+JobSkippedState::state_name() const
+{
+ return "skipped";
+}
+
+template class PrivateImplementationPattern<JobPendingState>;
+template class PrivateImplementationPattern<JobSucceededState>;
+template class PrivateImplementationPattern<JobFailedState>;
+template class PrivateImplementationPattern<JobSkippedState>;
+
diff --git a/paludis/resolver/job_state.hh b/paludis/resolver/job_state.hh
new file mode 100644
index 0000000..1479e76
--- /dev/null
+++ b/paludis/resolver/job_state.hh
@@ -0,0 +1,114 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 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/resolver/job-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/simple_visitor.hh>
+#include <paludis/util/type_list.hh>
+#include <paludis/output_manager-fwd.hh>
+#include <tr1/memory>
+#include <string>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE JobState :
+ public virtual DeclareAbstractAcceptMethods<JobState, MakeTypeList<
+ JobPendingState, JobSucceededState, JobFailedState, JobSkippedState>::Type>
+ {
+ public:
+ virtual ~JobState() = 0;
+
+ virtual const std::tr1::shared_ptr<const Job> job() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual const std::string state_name() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ class PALUDIS_VISIBLE JobPendingState :
+ public JobState,
+ public ImplementAcceptMethods<JobState, JobPendingState>,
+ private PrivateImplementationPattern<JobPendingState>
+ {
+ public:
+ JobPendingState(const std::tr1::shared_ptr<const Job> &);
+ ~JobPendingState();
+
+ virtual const std::tr1::shared_ptr<const Job> job() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string state_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE JobSucceededState :
+ public JobState,
+ public ImplementAcceptMethods<JobState, JobSucceededState>,
+ private PrivateImplementationPattern<JobSucceededState>
+ {
+ public:
+ JobSucceededState(const std::tr1::shared_ptr<const Job> &);
+ ~JobSucceededState();
+
+ virtual const std::tr1::shared_ptr<const Job> job() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string state_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ void add_output_manager(const std::tr1::shared_ptr<OutputManager> &);
+ };
+
+ class PALUDIS_VISIBLE JobFailedState :
+ public JobState,
+ public ImplementAcceptMethods<JobState, JobFailedState>,
+ private PrivateImplementationPattern<JobFailedState>
+ {
+ public:
+ JobFailedState(const std::tr1::shared_ptr<const Job> &);
+ ~JobFailedState();
+
+ virtual const std::tr1::shared_ptr<const Job> job() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string state_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ void add_output_manager(const std::tr1::shared_ptr<OutputManager> &);
+ };
+
+ class PALUDIS_VISIBLE JobSkippedState :
+ public JobState,
+ public ImplementAcceptMethods<JobState, JobSkippedState>,
+ private PrivateImplementationPattern<JobSkippedState>
+ {
+ public:
+ JobSkippedState(const std::tr1::shared_ptr<const Job> &);
+ ~JobSkippedState();
+
+ virtual const std::tr1::shared_ptr<const Job> job() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string state_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+ }
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<resolver::JobPendingState>;
+ extern template class PrivateImplementationPattern<resolver::JobSucceededState>;
+ extern template class PrivateImplementationPattern<resolver::JobFailedState>;
+ extern template class PrivateImplementationPattern<resolver::JobSkippedState>;
+#endif
+}
+
+#endif
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index 5dd1841..06a8b64 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -50,6 +50,7 @@
#include <paludis/resolver/jobs.hh>
#include <paludis/resolver/job.hh>
#include <paludis/resolver/job_id.hh>
+#include <paludis/resolver/job_state.hh>
#include <paludis/resolver/arrow.hh>
#include <paludis/package_id.hh>
#include <paludis/version_spec.hh>
@@ -121,130 +122,6 @@ namespace
}
};
- struct JobPendingState;
- struct JobSucceededState;
- struct JobFailedState;
- struct JobSkippedState;
-
- class JobState :
- public virtual DeclareAbstractAcceptMethods<JobState, MakeTypeList<
- JobPendingState, JobSucceededState, JobFailedState, JobSkippedState>::Type >
- {
- private:
- const std::tr1::shared_ptr<const Job> _job;
-
- public:
- JobState(const std::tr1::shared_ptr<const Job> & j) :
- _job(j)
- {
- }
-
- virtual ~JobState() = 0;
-
- const std::tr1::shared_ptr<const Job> job() PALUDIS_ATTRIBUTE((warn_unused_result))
- {
- return _job;
- }
-
- virtual const std::string state() const = 0;
- };
-
- JobState::~JobState()
- {
- }
-
- class JobPendingState :
- public JobState,
- public ImplementAcceptMethods<JobState, JobPendingState>
- {
- public:
- JobPendingState(const std::tr1::shared_ptr<const Job> & j) :
- JobState(j)
- {
- }
-
- virtual const std::string state() const
- {
- return "pending";
- }
- };
-
- class JobSucceededState :
- public JobState,
- public ImplementAcceptMethods<JobState, JobSucceededState>
- {
- private:
- std::list<std::tr1::shared_ptr<OutputManager> > _output_managers;
-
- public:
- JobSucceededState(const std::tr1::shared_ptr<const Job> & j) :
- JobState(j)
- {
- }
-
- void add_output_manager(const std::tr1::shared_ptr<OutputManager> & o)
- {
- _output_managers.push_back(o);
- }
-
- virtual const std::string state() const
- {
- return "succeeded";
- }
- };
-
- class JobFailedState :
- public JobState,
- public ImplementAcceptMethods<JobState, JobFailedState>
- {
- private:
- std::list<std::tr1::shared_ptr<OutputManager> > _output_managers;
-
- public:
- JobFailedState(const std::tr1::shared_ptr<const Job> & j) :
- JobState(j)
- {
- }
-
- void add_output_manager(const std::tr1::shared_ptr<OutputManager> & o)
- {
- _output_managers.push_back(o);
- }
-
- virtual const std::string state() const
- {
- return "failed";
- }
- };
-
- class JobSkippedState :
- public JobState,
- public ImplementAcceptMethods<JobState, JobSkippedState>
- {
- private:
- const std::tr1::shared_ptr<OutputManager> _output_manager;
- const JobID _because;
-
- public:
- JobSkippedState(
- const std::tr1::shared_ptr<const Job> & j,
- const JobID & b) :
- JobState(j),
- _because(b)
- {
- }
-
- const JobID because()
- {
- return _because;
- }
-
- virtual const std::string state() const
- {
- return "skipped";
- }
- };
-
bool do_pretend(
const std::tr1::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
@@ -797,13 +674,13 @@ namespace
{
if (! simple_visitor_cast<const JobPendingState>(*s->second))
throw InternalError(PALUDIS_HERE, "not pending: " + stringify((*p)->job()->id().string_id()) + " -> "
- + stringify(a->comes_after().string_id()) + " " + s->second->state());
+ + stringify(a->comes_after().string_id()) + " " + s->second->state_name());
}
else
{
if (! simple_visitor_cast<const JobSucceededState>(*s->second))
throw InternalError(PALUDIS_HERE, "didn't succeed: " + stringify((*p)->job()->id().string_id()) + " -> "
- + stringify(a->comes_after().string_id()) + " " + s->second->state());
+ + stringify(a->comes_after().string_id()) + " " + s->second->state_name());
}
}