summaryrefslogtreecommitdiff
path: root/src/generic/problemresolver
diff options
context:
space:
mode:
authorDaniel Burrows <dburrows@debian.org>2010-01-30 18:54:30 -0800
committerDaniel Burrows <dburrows@debian.org>2010-01-30 18:54:30 -0800
commitdb301b68d3a8f9d95a73087b415ffafca30fca37 (patch)
tree52d21fcf92dee7741ef1f290020291f0957d0a20 /src/generic/problemresolver
parentd7591b66e4eea8837b337011894d8f36b8592fa2 (diff)
downloadaptitude-db301b68d3a8f9d95a73087b415ffafca30fca37.tar.gz
Write the code to dump a tier operation to an ostream.
Diffstat (limited to 'src/generic/problemresolver')
-rw-r--r--src/generic/problemresolver/tier_operation.cc29
-rw-r--r--src/generic/problemresolver/tier_operation.h8
2 files changed, 37 insertions, 0 deletions
diff --git a/src/generic/problemresolver/tier_operation.cc b/src/generic/problemresolver/tier_operation.cc
index 4b619ccf..786c2a9a 100644
--- a/src/generic/problemresolver/tier_operation.cc
+++ b/src/generic/problemresolver/tier_operation.cc
@@ -20,6 +20,8 @@
#include "tier_operation.h"
+#include <ostream>
+
tier tier_operation::levelwise_maximum(const tier &t1, const tier &t2)
{
const int out_structural_level =
@@ -123,3 +125,30 @@ tier tier_operation::apply(const tier &t) const
const tier increased = levelwise_maximum(t, increase_levels);
return levelwise_add(t, add_levels);
}
+
+void tier_operation::dump(std::ostream &out) const
+{
+ out << "(";
+
+ bool first = true;
+
+ if(increase_levels != tier())
+ {
+ out << "increase: " << increase_levels;
+ first = false;
+ }
+
+ if(add_levels != tier(0))
+ {
+ if(first)
+ out << ", ";
+ out << "add: " << add_levels;
+ }
+}
+
+std::ostream &operator<<(std::ostream &out, const tier_operation &t)
+{
+ t.dump(out);
+
+ return out;
+}
diff --git a/src/generic/problemresolver/tier_operation.h b/src/generic/problemresolver/tier_operation.h
index 57be296c..8ad5dc67 100644
--- a/src/generic/problemresolver/tier_operation.h
+++ b/src/generic/problemresolver/tier_operation.h
@@ -23,6 +23,8 @@
#include "exceptions.h"
#include "tier.h"
+#include <iosfwd>
+
/** \brief A tier operation describes how any solution's tier will
* change as a result of adding a choice.
*
@@ -149,6 +151,12 @@ public:
* \param t The tier that this operation should modify.
*/
tier apply(const tier &t) const;
+
+ /** \brief Write a description of a tier operation to an ostream.
+ */
+ void dump(std::ostream &out) const;
};
+std::ostream &operator<<(std::ostream &out, const tier_operation &t);
+
#endif // TIER_OPERATION_H