/* vim: set sw=4 sts=4 et foldmethod=syntax : *//* * Copyright (c) 2008, 2009, 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_SPEC_TREE_HH#define PALUDIS_GUARD_PALUDIS_SPEC_TREE_HH 1#include<paludis/spec_tree-fwd.hh>#include<paludis/util/wrapped_forward_iterator.hh>#include<paludis/util/simple_visitor.hh>#include<paludis/util/sequence.hh>#include<type_traits>namespacepaludis{namespacespec_tree_internals{template<typenameTree_>classPALUDIS_VISIBLEBasicNode:publicvirtualDeclareAbstractAcceptMethods<BasicNode<Tree_>,typenameTree_::VisitableTypeList>{};template<typenameTree_,typenameItem_>classPALUDIS_VISIBLELeafNode:publicBasicNode<Tree_>,publicImplementAcceptMethods<BasicNode<Tree_>,LeafNode<Tree_,Item_>>{private:conststd::shared_ptr<constItem_>_spec;public:explicitLeafNode(conststd::shared_ptr<constItem_>&i);template<typenameOtherTree_>operatorLeafNode<OtherTree_,Item_>()const;conststd::shared_ptr<constItem_>spec()const;};template<typenameTree_,typenameItem_>structInnerNode;template<typenameTree_>classPALUDIS_VISIBLEBasicInnerNode:publicBasicNode<Tree_>{private:typedefSequence<std::shared_ptr<constBasicNode<Tree_>>>ChildList;std::shared_ptr<ChildList>_child_list;public:BasicInnerNode();typedefBasicInnerNodeConstIteratorTag<Tree_>ConstIteratorTag;typedefWrappedForwardIterator<ConstIteratorTag,conststd::shared_ptr<constBasicNode<Tree_>>>ConstIterator;ConstIteratorbegin()const;ConstIteratorend()const;voidappend_node(conststd::shared_ptr<constBasicNode<Tree_>>&t);template<typenameT_>conststd::shared_ptr<typenameTree_::templateNodeType<T_>::Type>append(conststd::shared_ptr<constT_>&t);template<typenameT_>conststd::shared_ptr<typenameTree_::templateNodeType<T_>::Type>append(conststd::shared_ptr<T_>&t);};template<typenameTree_,typenameItem_>classPALUDIS_VISIBLEInnerNode:publicBasicInnerNode<Tree_>,publicImplementAcceptMethods<BasicNode<Tree_>,InnerNode<Tree_,Item_>>{private:conststd::shared_ptr<constItem_>_spec;public:explicitInnerNode(conststd::shared_ptr<constItem_>&i);template<typenameOtherTree_>operatorInnerNode<OtherTree_,Item_>()const;conststd::shared_ptr<constItem_>spec()const;};template<typenameTree_>structMakeVisitableTypeListEntry<Tree_,TypeListTail>{typedefTypeListTailType;};template<typenameTree_,typenameItem_,typenameTail_>structMakeVisitableTypeListEntry<Tree_,TypeListEntry<SpecTreeInnerNodeType<Item_>,Tail_>>{typedefTypeListEntry<InnerNode<Tree_,Item_>,typenameMakeVisitableTypeListEntry<Tree_,Tail_>::Type>Type;};template<typenameTree_,typenameItem_,typenameTail_>structMakeVisitableTypeListEntry<Tree_,TypeListEntry<SpecTreeLeafNodeType<Item_>,Tail_>>{typedefTypeListEntry<LeafNode<Tree_,Item_>,typenameMakeVisitableTypeListEntry<Tree_,Tail_>::Type>Type;};template<typenameTree_,typenameNodeList_>structMakeVisitableTypeList{typedeftypenameMakeVisitableTypeListEntry<Tree_,NodeList_>::TypeType;};}template<typenameNodeList_,typenameRootNode_>classPALUDIS_VISIBLESpecTree{public:typedeftypenamespec_tree_internals::MakeVisitableTypeList<SpecTree,NodeList_>::TypeVisitableTypeList;typedefspec_tree_internals::BasicNode<SpecTree>BasicNode;typedefspec_tree_internals::BasicInnerNode<SpecTree>BasicInnerNode;template<typenameNode_>structLeafNodeType{typedefspec_tree_internals::LeafNode<SpecTree,Node_>Type;};template<typenameNode_>structInnerNodeType{typedefspec_tree_internals::InnerNode<SpecTree,Node_>Type;};template<typenameNode_>structNodeType{typedeftypenamestd::conditional<TypeListContains<VisitableTypeList,typenameLeafNodeType<Node_>::Type>::value,typenameSpecTree::templateLeafNodeType<Node_>::Type,typenamestd::conditional<TypeListContains<VisitableTypeList,typenameInnerNodeType<Node_>::Type>::value,typenameInnerNodeType<Node_>::Type,spec_tree_internals::TreeCannotContainNodeType<SpecTree,Node_>>::type>::typeType;};explicitSpecTree(conststd::shared_ptr<RootNode_>&spec);explicitSpecTree(conststd::shared_ptr<constRootNode_>&spec);conststd::shared_ptr<typenameInnerNodeType<RootNode_>::Type>top();conststd::shared_ptr<consttypenameInnerNodeType<RootNode_>::Type>top()const;private:conststd::shared_ptr<typenameInnerNodeType<RootNode_>::Type>_top;};externtemplateclassWrappedForwardIterator<spec_tree_internals::BasicInnerNode<GenericSpecTree>::ConstIteratorTag,conststd::shared_ptr<constspec_tree_internals::BasicNode<GenericSpecTree>>>;externtemplateclassWrappedForwardIterator<spec_tree_internals::BasicInnerNode<DependencySpecTree>::ConstIteratorTag,conststd::shared_ptr<constspec_tree_internals::BasicNode<DependencySpecTree>>>;externtemplateclassWrappedForwardIterator<spec_tree_internals::BasicInnerNode<SetSpecTree>::ConstIteratorTag,conststd::shared_ptr<constspec_tree_internals::BasicNode<SetSpecTree>>>;externtemplateclassWrappedForwardIterator<spec_tree_internals::BasicInnerNode<PlainTextSpecTree>::ConstIteratorTag,conststd::shared_ptr<constspec_tree_internals::BasicNode<PlainTextSpecTree>>>;externtemplateclassWrappedForwardIterator<spec_tree_internals::BasicInnerNode<RequiredUseSpecTree>::ConstIteratorTag,conststd::shared_ptr<constspec_tree_internals::BasicNode<RequiredUseSpecTree>>>;externtemplateclassWrappedForwardIterator<spec_tree_internals::BasicInnerNode<ProvideSpecTree>::ConstIteratorTag,conststd::shared_ptr<constspec_tree_internals::BasicNode<ProvideSpecTree>>>;externtemplateclassWrappedForwardIterator<spec_tree_internals::BasicInnerNode<SimpleURISpecTree>::ConstIteratorTag,conststd::shared_ptr<constspec_tree_internals::BasicNode<SimpleURISpecTree>>>;externtemplateclassWrappedForwardIterator<spec_tree_internals::BasicInnerNode<FetchableURISpecTree>::ConstIteratorTag,conststd::shared_ptr<constspec_tree_internals::BasicNode<FetchableURISpecTree>>>;externtemplateclassWrappedForwardIterator<spec_tree_internals::BasicInnerNode<LicenseSpecTree>::ConstIteratorTag,conststd::shared_ptr<constspec_tree_internals::BasicNode<LicenseSpecTree>>>;}#endif