aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-24 15:59:55 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-24 15:59:55 +0000
commitf13aa4c0963548f6827744f2d5685c852684e80b (patch)
tree6d59228cfd61e880243cb9adce90597b47a35ad9
parentd4ec805ae4a2b96f5b4a0c386cdc7c163060454a (diff)
downloadpaludis-f13aa4c0963548f6827744f2d5685c852684e80b.tar.gz
paludis-f13aa4c0963548f6827744f2d5685c852684e80b.tar.xz
Death to dynamic_cast.
-rw-r--r--paludis/dep_atom.cc7
-rw-r--r--paludis/dep_atom.hh14
-rw-r--r--paludis/dep_list.cc5
-rw-r--r--paludis/use_dep_atom.cc6
-rw-r--r--paludis/use_dep_atom.hh2
5 files changed, 28 insertions, 6 deletions
diff --git a/paludis/dep_atom.cc b/paludis/dep_atom.cc
index 58f0df9..427ef23 100644
--- a/paludis/dep_atom.cc
+++ b/paludis/dep_atom.cc
@@ -18,6 +18,7 @@
*/
#include "dep_atom.hh"
+#include "use_dep_atom.hh"
using namespace paludis;
@@ -29,3 +30,9 @@ DepAtom::~DepAtom()
{
}
+const UseDepAtom *
+DepAtom::as_use_dep_atom() const
+{
+ return 0;
+}
+
diff --git a/paludis/dep_atom.hh b/paludis/dep_atom.hh
index 1029d47..32bf5fe 100644
--- a/paludis/dep_atom.hh
+++ b/paludis/dep_atom.hh
@@ -20,11 +20,12 @@
#ifndef PALUDIS_GUARD_PALUDIS_DEP_ATOM_HH
#define PALUDIS_GUARD_PALUDIS_DEP_ATOM_HH 1
-#include <paludis/visitor.hh>
-#include <paludis/dep_atom_visitor.hh>
+#include <paludis/attributes.hh>
#include <paludis/composite_pattern.hh>
-#include <paludis/instantiation_policy.hh>
#include <paludis/counted_ptr.hh>
+#include <paludis/dep_atom_visitor.hh>
+#include <paludis/instantiation_policy.hh>
+#include <paludis/visitor.hh>
/** \file
* Declarations for the DepAtom class.
@@ -35,6 +36,7 @@
namespace paludis
{
class CompositeDepAtom;
+ class UseDepAtom;
/**
* Base class for a dependency atom.
@@ -52,6 +54,12 @@ namespace paludis
public:
virtual ~DepAtom();
+
+ /**
+ * Return us as a UseDepAtom, or 0 if we are not a
+ * UseDepAtom.
+ */
+ virtual const UseDepAtom * as_use_dep_atom() const PALUDIS_ATTRIBUTE((pure));
};
}
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 17e0a15..4443681 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -352,9 +352,8 @@ struct IsViable :
bool operator() (DepAtom::ConstPointer a)
{
- /// \todo don't use dynamic_cast<>, it sucks
- const UseDepAtom * u(0);
- if (0 != ((u = dynamic_cast<const UseDepAtom *>(a.raw_pointer()))))
+ const UseDepAtom * const u(a->as_use_dep_atom());
+ if (0 != u)
return _impl.environment->query_use(u->flag(),
_impl.current_package) ^ u->inverse();
else
diff --git a/paludis/use_dep_atom.cc b/paludis/use_dep_atom.cc
index 3448b64..6541664 100644
--- a/paludis/use_dep_atom.cc
+++ b/paludis/use_dep_atom.cc
@@ -31,3 +31,9 @@ UseDepAtom::UseDepAtom(const UseFlagName & flag, bool inverse) :
{
}
+const UseDepAtom *
+UseDepAtom::as_use_dep_atom() const
+{
+ return this;
+}
+
diff --git a/paludis/use_dep_atom.hh b/paludis/use_dep_atom.hh
index c1dc54b..78689a9 100644
--- a/paludis/use_dep_atom.hh
+++ b/paludis/use_dep_atom.hh
@@ -66,6 +66,8 @@ namespace paludis
{
return _inverse;
}
+
+ virtual const UseDepAtom * as_use_dep_atom() const PALUDIS_ATTRIBUTE((pure));
};
}