[aba92d] | 1 | /*
|
---|
| 2 | * ActOnAlltest.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: 04.10.2009
|
---|
| 5 | * Author: FrederikHeber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef ACTONALLTEST_HPP_
|
---|
| 9 | #define ACTONALLTEST_HPP_
|
---|
| 10 |
|
---|
| 11 | using namespace std;
|
---|
| 12 |
|
---|
| 13 | #include <list>
|
---|
[46ea3b] | 14 | #include "../vector.hpp"
|
---|
[aba92d] | 15 |
|
---|
| 16 | #define ListOfVectors list<Vector *>
|
---|
| 17 |
|
---|
| 18 | class VectorList
|
---|
| 19 | {
|
---|
| 20 | public:
|
---|
| 21 | VectorList();
|
---|
[33f9f7] | 22 | VectorList(VectorList &ref);
|
---|
[aba92d] | 23 | ~VectorList();
|
---|
| 24 |
|
---|
| 25 | void AddVector(Vector *v);
|
---|
| 26 | void EmptyList();
|
---|
| 27 |
|
---|
[eaee7f] | 28 | template <typename klasse, typename res, typename T> void ActOnAll( res (klasse::*f)(T), T t );
|
---|
[273382] | 29 | template <typename klasse, typename res, typename T> void ActOnAll( res (klasse::*f)(T&), T &t );
|
---|
[eaee7f] | 30 | template <typename klasse, typename res, typename T, typename U> void ActOnAll( res (klasse::*f)(T, U), T t, U u );
|
---|
| 31 | template <typename klasse, typename res, typename T, typename U, typename V> void ActOnAll( res (klasse::*f)(T, U, V), T t, U u, V v);
|
---|
[aba92d] | 32 |
|
---|
[33f9f7] | 33 | bool operator == (VectorList &rhs);
|
---|
| 34 | VectorList& operator = (VectorList &ref);
|
---|
| 35 |
|
---|
| 36 | //private:
|
---|
[aba92d] | 37 | ListOfVectors Vectors;
|
---|
| 38 | };
|
---|
| 39 |
|
---|
[33f9f7] | 40 |
|
---|
| 41 | VectorList::VectorList() { };
|
---|
| 42 | VectorList::VectorList(VectorList &ref)
|
---|
| 43 | {
|
---|
| 44 | ref.EmptyList();
|
---|
| 45 | for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) {
|
---|
| 46 | ref.Vectors.push_back(new Vector (**Runner));
|
---|
| 47 | }
|
---|
| 48 | };
|
---|
| 49 |
|
---|
| 50 | VectorList & VectorList::operator = (VectorList &ref)
|
---|
| 51 | {
|
---|
| 52 | EmptyList();
|
---|
| 53 | for (ListOfVectors::iterator Runner = ref.Vectors.begin(); Runner != ref.Vectors.end(); Runner++) {
|
---|
| 54 | Vectors.push_back(new Vector (**Runner));
|
---|
| 55 | }
|
---|
| 56 | return *this;
|
---|
| 57 | };
|
---|
| 58 |
|
---|
| 59 | bool VectorList::operator == (VectorList &rhs)
|
---|
| 60 | {
|
---|
| 61 | bool status = true;
|
---|
| 62 | ListOfVectors::iterator lRunner = Vectors.begin();
|
---|
| 63 | ListOfVectors::iterator rRunner = rhs.Vectors.begin();
|
---|
| 64 | for (;(lRunner != Vectors.end()) && (rRunner != rhs.Vectors.end()); lRunner++, rRunner++) {
|
---|
[e138de] | 65 | //Log() << Verbose(0) << **lRunner << " == " << **rRunner << endl;
|
---|
[33f9f7] | 66 | status = status && (**lRunner == **rRunner);
|
---|
| 67 | }
|
---|
| 68 | return status;
|
---|
| 69 | };
|
---|
| 70 |
|
---|
| 71 | VectorList::~VectorList() { };
|
---|
| 72 |
|
---|
[eaee7f] | 73 | template <typename klasse, typename res, typename T> void VectorList::ActOnAll( res (klasse::*f)(T), T t )
|
---|
[33f9f7] | 74 | {
|
---|
[eaee7f] | 75 | for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++)
|
---|
| 76 | ((*Runner)->*f)(t);
|
---|
[33f9f7] | 77 | };
|
---|
| 78 |
|
---|
[273382] | 79 | template <typename klasse, typename res, typename T> void VectorList::ActOnAll( res (klasse::*f)(T&), T &t )
|
---|
| 80 | {
|
---|
| 81 | for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++)
|
---|
| 82 | ((*Runner)->*f)(t);
|
---|
| 83 | };
|
---|
| 84 |
|
---|
[eaee7f] | 85 | template <typename klasse, typename res, typename T, typename U> void VectorList::ActOnAll( res (klasse::*f)(T, U), T t, U u )
|
---|
[aba92d] | 86 | {
|
---|
[eaee7f] | 87 | for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++)
|
---|
| 88 | ((*Runner)->*f)(t, u);
|
---|
[33f9f7] | 89 | };
|
---|
| 90 |
|
---|
[eaee7f] | 91 | template <typename klasse, typename res, typename T, typename U, typename V> void VectorList::ActOnAll( res (klasse::*f)(T, U, V), T t, U u, V v)
|
---|
[33f9f7] | 92 | {
|
---|
[eaee7f] | 93 | for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++)
|
---|
| 94 | ((*Runner)->*f)(t, u, v);
|
---|
[aba92d] | 95 | };
|
---|
| 96 |
|
---|
| 97 | void VectorList::AddVector(Vector *v)
|
---|
| 98 | {
|
---|
| 99 | Vectors.push_back(v);
|
---|
| 100 | };
|
---|
| 101 |
|
---|
| 102 | void VectorList::EmptyList()
|
---|
| 103 | {
|
---|
| 104 | for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++) {
|
---|
| 105 | delete(*Runner);
|
---|
| 106 | }
|
---|
| 107 | Vectors.clear();
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | #endif /* ACTONALLTEST_HPP_ */
|
---|