aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-09 15:23:50 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-09 15:23:50 +0000
commitf80cf5da45e4243fc8eeb45cf2ddbbba76acfa10 (patch)
tree09162ef0671dd325aef14225d7f26454ff6752b1
parent68941d5d546c407afa6bfaaf4fcc5ec198dcd023 (diff)
downloadpaludis-f80cf5da45e4243fc8eeb45cf2ddbbba76acfa10.tar.gz
paludis-f80cf5da45e4243fc8eeb45cf2ddbbba76acfa10.tar.xz
Remove Composite class, it is no longer required. More doxygen cleanups.
-rw-r--r--doc/doc_main.doxygen5
-rw-r--r--paludis/dep_atom.hh5
-rw-r--r--paludis/util/collection.hh116
-rw-r--r--paludis/util/composite_pattern.hh66
-rw-r--r--paludis/util/files.m41
5 files changed, 63 insertions, 130 deletions
diff --git a/doc/doc_main.doxygen b/doc/doc_main.doxygen
index 48c86bb..fdb947b 100644
--- a/doc/doc_main.doxygen
+++ b/doc/doc_main.doxygen
@@ -273,11 +273,6 @@
// ----- grppatterns Subgroups -----
-/** \defgroup grpcomposite Composite pattern
- *
- * \ingroup grppatterns
- */
-
/** \defgroup grpinstance Instance patterns
*
* \ingroup grppatterns
diff --git a/paludis/dep_atom.hh b/paludis/dep_atom.hh
index 1fa29c2..09ca9fc 100644
--- a/paludis/dep_atom.hh
+++ b/paludis/dep_atom.hh
@@ -24,7 +24,6 @@
#include <paludis/dep_tag.hh>
#include <paludis/name.hh>
#include <paludis/util/attributes.hh>
-#include <paludis/util/composite_pattern.hh>
#include <paludis/util/counted_ptr.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/visitor.hh>
@@ -64,7 +63,6 @@ namespace paludis
*/
class DepAtom :
public virtual VisitableInterface<DepAtomVisitorTypes>,
- public virtual Composite<DepAtom, CompositeDepAtom>,
private InstantiationPolicy<DepAtom, instantiation_method::NonCopyableTag>,
public InternalCounted<DepAtom>
{
@@ -91,8 +89,7 @@ namespace paludis
* \ingroup grpdepatoms
*/
class CompositeDepAtom :
- public DepAtom,
- public virtual Composite<DepAtom, CompositeDepAtom>
+ public DepAtom
{
private:
std::list<DepAtom::ConstPointer> _children;
diff --git a/paludis/util/collection.hh b/paludis/util/collection.hh
index 764d3f6..45ab70e 100644
--- a/paludis/util/collection.hh
+++ b/paludis/util/collection.hh
@@ -59,6 +59,9 @@ namespace paludis
*/
typedef const T_ & const_reference;
+ ///\name Basic operations
+ ///\{
+
/**
* Constructor.
*/
@@ -73,35 +76,33 @@ namespace paludis
{
}
- /**
- * Our iterator type.
- */
+ ///\}
+
+ ///\name Iterate over our items
+ ///\{
+
typedef typename std::list<T_>::const_iterator Iterator;
- /**
- * Iterator to the start of our items.
- */
Iterator begin() const
{
return _items.begin();
}
- /**
- * Iterator to one past our last item.
- */
Iterator end() const
{
return _items.end();
}
- /**
- * Iterator to our last item.
- */
Iterator last() const
{
return _items.begin() == _items.end() ? _items.end() : --(_items.end());
}
+ ///\}
+
+ ///\name Finding items
+ ///\{
+
/**
* Return an Iterator to an item, or end() if there's no match.
*/
@@ -110,6 +111,11 @@ namespace paludis
return std::find(_items.begin(), _items.end(), v);
}
+ ///\}
+
+ ///\name Adding and modifying items
+ ///\{
+
/**
* Append an item, return whether we succeeded.
*/
@@ -131,6 +137,11 @@ namespace paludis
_items.push_back(v);
}
+ ///\}
+
+ ///\name Queries
+ ///\{
+
/**
* Are we empty?
*/
@@ -138,6 +149,8 @@ namespace paludis
{
return _items.empty();
}
+
+ ///\}
};
/**
@@ -157,65 +170,46 @@ namespace paludis
std::set<T_> _items;
public:
- /**
- * Constructor.
- */
+ ///\name Basic operations
+ ///\{
+
SortedCollection()
{
}
- /**
- * Destructor.
- */
virtual ~SortedCollection()
{
}
- /**
- * Our iterator type.
- */
+ ///\}
+
+ ///\name Iterate over our items
+ ///\{
+
typedef typename std::set<T_>::const_iterator Iterator;
- /**
- * Iterator to the start of our items.
- */
Iterator begin() const
{
return _items.begin();
}
- /**
- * Iterator to one past our last item.
- */
Iterator end() const
{
return _items.end();
}
- /**
- * Our reverse iterator type.
- */
typedef typename std::set<T_>::const_reverse_iterator ReverseIterator;
- /**
- * Reverse iterator to the start of our items.
- */
ReverseIterator rbegin() const
{
return _items.rbegin();
}
- /**
- * Reverse iterator to one past our last item.
- */
ReverseIterator rend() const
{
return _items.rend();
}
- /**
- * Iterator to our last item.
- */
Iterator last() const
{
Iterator result(_items.end());
@@ -224,14 +218,21 @@ namespace paludis
return result;
}
- /**
- * Return an Iterator to an item, or end() if there's no match.
- */
+ ///\}
+
+ ///\name Finding items
+ ///\{
+
Iterator find(const T_ & v) const
{
return _items.find(v);
}
+ ///\}
+
+ ///\name Adding, removing and modifying items
+ ///\{
+
/**
* Insert an item, return whether we succeeded.
*/
@@ -261,6 +262,24 @@ namespace paludis
}
/**
+ * Our insert iterator type.
+ */
+ typedef typename std::insert_iterator<std::set<T_> > Inserter;
+
+ /**
+ * Fetch an inserter.
+ */
+ Inserter inserter()
+ {
+ return std::inserter(_items, _items.begin());
+ }
+
+ ///\}
+
+ ///\name Queries
+ ///\{
+
+ /**
* Are we empty?
*/
bool empty() const
@@ -276,18 +295,7 @@ namespace paludis
return _items.size();
}
- /**
- * Our insert iterator type.
- */
- typedef typename std::insert_iterator<std::set<T_> > Inserter;
-
- /**
- * Fetch an inserter.
- */
- Inserter inserter()
- {
- return std::inserter(_items, _items.begin());
- }
+ ///\}
};
}
diff --git a/paludis/util/composite_pattern.hh b/paludis/util/composite_pattern.hh
deleted file mode 100644
index 215bfb3..0000000
--- a/paludis/util/composite_pattern.hh
+++ /dev/null
@@ -1,66 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
- *
- * 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_COMPOSITE_PATTERN_HH
-#define PALUDIS_GUARD_PALUDIS_COMPOSITE_PATTERN_HH 1
-
-/** \file
- * Declarations for the Composite template class.
- *
- * \ingroup grpcomposite
- */
-
-namespace paludis
-{
- /**
- * A Composite class represents both a class and a collection of
- * child instances of the same class.
- *
- * \ingroup grpcomposite
- */
- template <typename ChildClass_, typename CompositeClass_ = ChildClass_>
- class Composite
- {
- private:
- mutable CompositeClass_ * _composite;
-
- protected:
- /**
- * Constructor.
- */
- Composite() :
- _composite(0)
- {
- }
-
- public:
- /**
- * Fetch a CompositeClass_ representation of ourself, or 0 if we
- * are not composite.
- */
- CompositeClass_ * get_composite() const
- {
- if (0 == _composite)
- _composite = & dynamic_cast<CompositeClass_>(*this);
- return _composite;
- }
- };
-}
-
-#endif
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 612734d..cfa6e46 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -12,7 +12,6 @@ add(`attributes', `hh')
add(`collection', `hh')
add(`compare', `hh')
add(`comparison_policy', `hh', `test')
-add(`composite_pattern', `hh')
add(`container_entry', `hh', `test')
add(`counted_ptr', `hh', `cc', `test')
add(`deleter', `hh', `cc', `test')