aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-16 18:42:47 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-16 18:42:47 +0000
commitf715cb80090cb3e21b3cd3fac697575863a15b2c (patch)
treed6bccdf84599a5f467559963d1c8bc757f672a60
parent9e40f93e3479dbc0407157ad9e00a2190a23cb83 (diff)
downloadpaludis-f715cb80090cb3e21b3cd3fac697575863a15b2c.tar.gz
paludis-f715cb80090cb3e21b3cd3fac697575863a15b2c.tar.xz
DepLabel work
-rw-r--r--paludis/dep_label-fwd.hh54
-rw-r--r--paludis/dep_label.cc185
-rw-r--r--paludis/dep_label.hh46
3 files changed, 285 insertions, 0 deletions
diff --git a/paludis/dep_label-fwd.hh b/paludis/dep_label-fwd.hh
index 2b85b07..a258f11 100644
--- a/paludis/dep_label-fwd.hh
+++ b/paludis/dep_label-fwd.hh
@@ -21,6 +21,8 @@
#define PALUDIS_GUARD_PALUDIS_DEP_LABEL_FWD_HH 1
#include <paludis/util/attributes.hh>
+#include <paludis/util/sequence-fwd.hh>
+#include <paludis/util/tr1_memory.hh>
#include <iosfwd>
/** \file
@@ -69,6 +71,46 @@ namespace paludis
struct DependencySuggestLabel;
struct DependencyABIsLabel;
+ /**
+ * A collection of DependencyLabel instances.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.26
+ */
+ typedef Sequence<tr1::shared_ptr<const DependencyLabel> > DependencyLabelSequence;
+
+ /**
+ * A collection of DependencySystemLabel instances.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.26
+ */
+ typedef Sequence<tr1::shared_ptr<const DependencySystemLabel> > DependencySystemLabelSequence;
+
+ /**
+ * A collection of DependencyTypeLabel instances.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.26
+ */
+ typedef Sequence<tr1::shared_ptr<const DependencyTypeLabel> > DependencyTypeLabelSequence;
+
+ /**
+ * A collection of DependencySuggestLabel instances.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.26
+ */
+ typedef Sequence<tr1::shared_ptr<const DependencySuggestLabel> > DependencySuggestLabelSequence;
+
+ /**
+ * A collection of DependencyABIsLabel instances.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.26
+ */
+ typedef Sequence<tr1::shared_ptr<const DependencyABIsLabel> > DependencyABIsLabelSequence;
+
template <typename T_, typename Category_> struct ConcreteDependencyLabel;
struct DependencyHostLabelTag;
@@ -111,6 +153,16 @@ namespace paludis
*/
typedef ConcreteDependencyLabel<DependencyRunLabelTag, DependencyTypeLabel> DependencyRunLabel;
+ struct DependencyPostLabelTag;
+
+ /**
+ * A DependencyPostLabel specifies build-time requirements for building a package.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.26
+ */
+ typedef ConcreteDependencyLabel<DependencyPostLabelTag, DependencyTypeLabel> DependencyPostLabel;
+
struct DependencyInstallLabelTag;
/**
@@ -212,6 +264,8 @@ namespace paludis
* \since 0.26
*/
std::ostream & operator<< (std::ostream &, const DependencyLabel &) PALUDIS_VISIBLE;
+
+ struct ActiveDependencyLabels;
}
#endif
diff --git a/paludis/dep_label.cc b/paludis/dep_label.cc
index 072cabb..9b90568 100644
--- a/paludis/dep_label.cc
+++ b/paludis/dep_label.cc
@@ -18,11 +18,22 @@
*/
#include <paludis/dep_label.hh>
+#include <paludis/dep_spec.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/sequence-impl.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/stringify.hh>
#include <ostream>
+#include <algorithm>
using namespace paludis;
+template class Sequence<tr1::shared_ptr<const DependencyLabel> >;
+template class Sequence<tr1::shared_ptr<const DependencySystemLabel> >;
+template class Sequence<tr1::shared_ptr<const DependencyTypeLabel> >;
+template class Sequence<tr1::shared_ptr<const DependencySuggestLabel> >;
+template class Sequence<tr1::shared_ptr<const DependencyABIsLabel> >;
+
std::ostream &
paludis::operator<< (std::ostream & s, const URILabel & l)
{
@@ -128,10 +139,184 @@ ConcreteDependencyLabel<T_, C_>::text() const
return _imp->text;
}
+namespace paludis
+{
+ template <>
+ struct Implementation<ActiveDependencyLabels>
+ {
+ tr1::shared_ptr<DependencySystemLabelSequence> system_labels;
+ tr1::shared_ptr<DependencyTypeLabelSequence> type_labels;
+ tr1::shared_ptr<DependencyABIsLabelSequence> abi_labels;
+ tr1::shared_ptr<DependencySuggestLabelSequence> suggest_labels;
+ };
+}
+
+namespace
+{
+ struct LabelsPopulator :
+ ConstVisitor<DependencyLabelVisitorTypes>
+ {
+ Implementation<ActiveDependencyLabels> & _imp;
+ const tr1::shared_ptr<const DependencyLabel> _l;
+
+ LabelsPopulator(Implementation<ActiveDependencyLabels> & i,
+ const tr1::shared_ptr<const DependencyLabel> & l) :
+ _imp(i),
+ _l(l)
+ {
+ }
+
+ void visit(const DependencySuggestLabel &)
+ {
+ if (! _imp.suggest_labels)
+ _imp.suggest_labels.reset(new DependencySuggestLabelSequence);
+ _imp.suggest_labels->push_back(tr1::static_pointer_cast<const DependencySuggestLabel>(_l));
+ }
+
+ void visit(const DependencySystemLabel &)
+ {
+ if (! _imp.system_labels)
+ _imp.system_labels.reset(new DependencySystemLabelSequence);
+ _imp.system_labels->push_back(tr1::static_pointer_cast<const DependencySystemLabel>(_l));
+ }
+
+ void visit(const DependencyABIsLabel &)
+ {
+ if (! _imp.abi_labels)
+ _imp.abi_labels.reset(new DependencyABIsLabelSequence);
+ _imp.abi_labels->push_back(tr1::static_pointer_cast<const DependencyABIsLabel>(_l));
+ }
+
+ void visit(const DependencyTypeLabel &)
+ {
+ if (! _imp.type_labels)
+ _imp.type_labels.reset(new DependencyTypeLabelSequence);
+ _imp.type_labels->push_back(tr1::static_pointer_cast<const DependencyTypeLabel>(_l));
+ }
+ };
+}
+
+ActiveDependencyLabels::ActiveDependencyLabels(const DependencyLabelsDepSpec & spec) :
+ PrivateImplementationPattern<ActiveDependencyLabels>(new Implementation<ActiveDependencyLabels>)
+{
+ for (DependencyLabelsDepSpec::ConstIterator i(spec.begin()), i_end(spec.end()) ;
+ i != i_end ; ++i)
+ {
+ LabelsPopulator p(*_imp.get(), *i);
+ (*i)->accept(p);
+ }
+
+ if (! _imp->system_labels)
+ _imp->system_labels.reset(new DependencySystemLabelSequence);
+ if (! _imp->type_labels)
+ _imp->type_labels.reset(new DependencyTypeLabelSequence);
+ if (! _imp->suggest_labels)
+ _imp->suggest_labels.reset(new DependencySuggestLabelSequence);
+ if (! _imp->abi_labels)
+ _imp->abi_labels.reset(new DependencyABIsLabelSequence);
+}
+
+ActiveDependencyLabels::ActiveDependencyLabels(const ActiveDependencyLabels & other) :
+ PrivateImplementationPattern<ActiveDependencyLabels>(new Implementation<ActiveDependencyLabels>)
+{
+ _imp->system_labels.reset(new DependencySystemLabelSequence);
+ std::copy(other._imp->system_labels->begin(), other._imp->system_labels->end(), _imp->system_labels->back_inserter());
+
+ _imp->type_labels.reset(new DependencyTypeLabelSequence);
+ std::copy(other._imp->type_labels->begin(), other._imp->type_labels->end(), _imp->type_labels->back_inserter());
+
+ _imp->suggest_labels.reset(new DependencySuggestLabelSequence);
+ std::copy(other._imp->suggest_labels->begin(), other._imp->suggest_labels->end(), _imp->suggest_labels->back_inserter());
+
+ _imp->abi_labels.reset(new DependencyABIsLabelSequence);
+ std::copy(other._imp->abi_labels->begin(), other._imp->abi_labels->end(), _imp->abi_labels->back_inserter());
+}
+
+ActiveDependencyLabels::ActiveDependencyLabels(const ActiveDependencyLabels & other, const DependencyLabelsDepSpec & spec) :
+ PrivateImplementationPattern<ActiveDependencyLabels>(new Implementation<ActiveDependencyLabels>)
+{
+ for (DependencyLabelsDepSpec::ConstIterator i(spec.begin()), i_end(spec.end()) ;
+ i != i_end ; ++i)
+ {
+ LabelsPopulator p(*_imp.get(), *i);
+ (*i)->accept(p);
+ }
+
+ if (! _imp->system_labels)
+ {
+ _imp->system_labels.reset(new DependencySystemLabelSequence);
+ std::copy(other._imp->system_labels->begin(), other._imp->system_labels->end(), _imp->system_labels->back_inserter());
+ }
+ if (! _imp->type_labels)
+ {
+ _imp->type_labels.reset(new DependencyTypeLabelSequence);
+ std::copy(other._imp->type_labels->begin(), other._imp->type_labels->end(), _imp->type_labels->back_inserter());
+ }
+ if (! _imp->suggest_labels)
+ {
+ _imp->suggest_labels.reset(new DependencySuggestLabelSequence);
+ std::copy(other._imp->suggest_labels->begin(), other._imp->suggest_labels->end(), _imp->suggest_labels->back_inserter());
+ }
+ if (! _imp->abi_labels)
+ {
+ _imp->abi_labels.reset(new DependencyABIsLabelSequence);
+ std::copy(other._imp->abi_labels->begin(), other._imp->abi_labels->end(), _imp->abi_labels->back_inserter());
+ }
+}
+
+ActiveDependencyLabels::ActiveDependencyLabels(const DependencyLabelSequence & spec) :
+ PrivateImplementationPattern<ActiveDependencyLabels>(new Implementation<ActiveDependencyLabels>)
+{
+ for (DependencyLabelSequence::ConstIterator i(spec.begin()), i_end(spec.end()) ;
+ i != i_end ; ++i)
+ {
+ LabelsPopulator p(*_imp.get(), *i);
+ (*i)->accept(p);
+ }
+
+ if (! _imp->system_labels)
+ _imp->system_labels.reset(new DependencySystemLabelSequence);
+ if (! _imp->type_labels)
+ _imp->type_labels.reset(new DependencyTypeLabelSequence);
+ if (! _imp->suggest_labels)
+ _imp->suggest_labels.reset(new DependencySuggestLabelSequence);
+ if (! _imp->abi_labels)
+ _imp->abi_labels.reset(new DependencyABIsLabelSequence);
+}
+
+ActiveDependencyLabels::~ActiveDependencyLabels()
+{
+}
+
+const tr1::shared_ptr<const DependencySystemLabelSequence>
+ActiveDependencyLabels::system_labels() const
+{
+ return _imp->system_labels;
+}
+
+const tr1::shared_ptr<const DependencyTypeLabelSequence>
+ActiveDependencyLabels::type_labels() const
+{
+ return _imp->type_labels;
+}
+
+const tr1::shared_ptr<const DependencyABIsLabelSequence>
+ActiveDependencyLabels::abi_labels() const
+{
+ return _imp->abi_labels;
+}
+
+const tr1::shared_ptr<const DependencySuggestLabelSequence>
+ActiveDependencyLabels::suggest_labels() const
+{
+ return _imp->suggest_labels;
+}
+
template class ConcreteDependencyLabel<DependencyHostLabel::Tag, DependencySystemLabel>;
template class ConcreteDependencyLabel<DependencyTargetLabel::Tag, DependencySystemLabel>;
template class ConcreteDependencyLabel<DependencyBuildLabel::Tag, DependencyTypeLabel>;
template class ConcreteDependencyLabel<DependencyRunLabel::Tag, DependencyTypeLabel>;
+template class ConcreteDependencyLabel<DependencyPostLabel::Tag, DependencyTypeLabel>;
template class ConcreteDependencyLabel<DependencyInstallLabel::Tag, DependencyTypeLabel>;
template class ConcreteDependencyLabel<DependencyCompileLabel::Tag, DependencyTypeLabel>;
template class ConcreteDependencyLabel<DependencySuggestedLabel::Tag, DependencySuggestLabel>;
diff --git a/paludis/dep_label.hh b/paludis/dep_label.hh
index b9caffb..478df9c 100644
--- a/paludis/dep_label.hh
+++ b/paludis/dep_label.hh
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_DEP_LABEL_HH 1
#include <paludis/dep_label-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
#include <paludis/util/visitor.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
@@ -111,6 +112,7 @@ namespace paludis
DependencyTypeLabel,
DependencyBuildLabel,
DependencyRunLabel,
+ DependencyPostLabel,
DependencyInstallLabel,
DependencyCompileLabel
>
@@ -245,6 +247,9 @@ namespace paludis
{
/// Convenience alias for our visitor types.
typedef DependencySystemLabelVisitorTypes VisitorTypes;
+
+ typedef ConstAcceptInterface<DependencySystemLabelVisitorTypes>::Heirarchy Heirarchy;
+ using ConstAcceptInterface<DependencySystemLabelVisitorTypes>::accept;
};
/**
@@ -261,6 +266,9 @@ namespace paludis
{
/// Convenience alias for our visitor types.
typedef DependencyTypeLabelVisitorTypes VisitorTypes;
+
+ typedef ConstAcceptInterface<DependencyTypeLabelVisitorTypes>::Heirarchy Heirarchy;
+ using ConstAcceptInterface<DependencyTypeLabelVisitorTypes>::accept;
};
/**
@@ -277,6 +285,9 @@ namespace paludis
{
/// Convenience alias for our visitor types.
typedef DependencySuggestLabelVisitorTypes VisitorTypes;
+
+ typedef ConstAcceptInterface<DependencySuggestLabelVisitorTypes>::Heirarchy Heirarchy;
+ using ConstAcceptInterface<DependencySuggestLabelVisitorTypes>::accept;
};
/**
@@ -293,6 +304,9 @@ namespace paludis
{
/// Convenience alias for our visitor types.
typedef DependencyABIsLabelVisitorTypes VisitorTypes;
+
+ typedef ConstAcceptInterface<DependencyABIsLabelVisitorTypes>::Heirarchy Heirarchy;
+ using ConstAcceptInterface<DependencyABIsLabelVisitorTypes>::accept;
};
/**
@@ -325,6 +339,38 @@ namespace paludis
/// Convenience typedef alias to obtain our tag.
typedef T_ Tag;
};
+
+ /**
+ * A collection of each dependency label type.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ class PALUDIS_VISIBLE ActiveDependencyLabels :
+ private PrivateImplementationPattern<ActiveDependencyLabels>
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ ActiveDependencyLabels(const DependencyLabelsDepSpec &);
+ ActiveDependencyLabels(const DependencyLabelSequence &);
+ ActiveDependencyLabels(const ActiveDependencyLabels &);
+ ActiveDependencyLabels(const ActiveDependencyLabels &, const DependencyLabelsDepSpec &);
+ ~ActiveDependencyLabels();
+
+ ///\}
+
+ ///\name Current label selections
+ ///\{
+
+ const tr1::shared_ptr<const DependencySystemLabelSequence> system_labels() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const tr1::shared_ptr<const DependencyTypeLabelSequence> type_labels() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const tr1::shared_ptr<const DependencyABIsLabelSequence> abi_labels() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const tr1::shared_ptr<const DependencySuggestLabelSequence> suggest_labels() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ ///\}
+ };
}
#endif