| [063fab] | 1 | /*
 | 
|---|
 | 2 |  * IndexSetContainer.hpp
 | 
|---|
 | 3 |  *
 | 
|---|
 | 4 |  *  Created on: Jul 3, 2012
 | 
|---|
 | 5 |  *      Author: heber
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | #ifndef INDEXSETCONTAINER_HPP_
 | 
|---|
 | 9 | #define INDEXSETCONTAINER_HPP_
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 | 
 | 
|---|
 | 12 | // include config.h
 | 
|---|
 | 13 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 14 | #include <config.h>
 | 
|---|
 | 15 | #endif
 | 
|---|
 | 16 | 
 | 
|---|
 | 17 | #include <boost/shared_ptr.hpp>
 | 
|---|
 | 18 | #include <vector>
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 | #include "IndexSet.hpp"
 | 
|---|
 | 21 | #include "SortedVector.hpp"
 | 
|---|
 | 22 | 
 | 
|---|
 | 23 | class IndexSetContainerTest;
 | 
|---|
 | 24 | 
 | 
|---|
 | 25 | /**
 | 
|---|
 | 26 |   * As the IndexSet is supposed to appear in many maps and Containers as it may
 | 
|---|
 | 27 |   * be contained in other IndexSet's, we store it always as a shared_ptr. This
 | 
|---|
 | 28 |   * Container is then responsible that the ordering within the container still
 | 
|---|
 | 29 |   * allows for fast access due to sorted appearance not by order in memory but
 | 
|---|
 | 30 |   * order defined by IndexSet comparison operators.
 | 
|---|
 | 31 |   *
 | 
|---|
 | 32 |   */
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | //!> typedef for IndexSet instances stored in SortedVector
 | 
|---|
 | 35 | class IndexSetContainer : public SortedVector<IndexSet> {
 | 
|---|
 | 36 |   //!> grant unit test access to protected members of SortedVector
 | 
|---|
 | 37 |   friend class IndexSetContainerTest;
 | 
|---|
 | 38 | public:
 | 
|---|
 | 39 |   //!> typedef for IndexSetContainer wrapped in shared_ptr
 | 
|---|
 | 40 |   typedef boost::shared_ptr<IndexSetContainer> ptr;
 | 
|---|
 | 41 | 
 | 
|---|
 | 42 |   /** Constructor from an unsorted vector of instances.
 | 
|---|
 | 43 |    *
 | 
|---|
 | 44 |    * @param _container unsorted vector of instances
 | 
|---|
 | 45 |    */
 | 
|---|
 | 46 |   IndexSetContainer(const SortedVector<IndexSet>::Container_t &_container) :
 | 
|---|
 | 47 |     SortedVector<IndexSet>(_container)
 | 
|---|
 | 48 |   {}
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 |   /** Constructor from an unsorted vector of instances.
 | 
|---|
 | 51 |    *
 | 
|---|
 | 52 |    * @param _container unsorted vector of instances
 | 
|---|
 | 53 |    */
 | 
|---|
 | 54 |   IndexSetContainer(const std::vector<IndexSet> &_container) :
 | 
|---|
 | 55 |     SortedVector<IndexSet>(_container)
 | 
|---|
 | 56 |   {}
 | 
|---|
 | 57 | 
 | 
|---|
 | 58 |   /** Constructor from a single instance.
 | 
|---|
 | 59 |    *
 | 
|---|
 | 60 |    * @param _instance single instance
 | 
|---|
 | 61 |    */
 | 
|---|
 | 62 |   IndexSetContainer(IndexSet::ptr &_instance) :
 | 
|---|
 | 63 |     SortedVector<IndexSet>(_instance)
 | 
|---|
 | 64 |   {}
 | 
|---|
 | 65 | };
 | 
|---|
 | 66 | //!> typedef for IndexSet instance stored as shared_ptr in SortedVector
 | 
|---|
 | 67 | typedef IndexSetContainer::T_ptr IndexSet_ptr;
 | 
|---|
 | 68 | 
 | 
|---|
 | 69 | 
 | 
|---|
 | 70 | #endif /* INDEXSETCONTAINER_HPP_ */
 | 
|---|