00001 #ifndef __FIBER_CREATIVEITERATOR_HPP
00002 #define __FIBER_CREATIVEITERATOR_HPP
00003
00004 #include "MultiIndex.hpp"
00005 #include "Iterator.hpp"
00006 #include "Expression.hpp"
00007 #include <meta/IF.hpp>
00008 #include <eagle/Vector.hpp>
00009
00010 #include <vector>
00011
00012 namespace Fiber
00013 {
00014 using Eagle::MetaInfo;
00015
00016
00017 template <class T>
00018 struct DataCreator;
00019
00023 template <class T>
00024 class CreativeIterator : public Iterator<T>
00025 {
00026 protected:
00027 DataCreator<T> *myCreator;
00028 public:
00029 using Iterator<T>::ptr;
00030
00031 CreativeIterator(const Iterator<T>&D, DataCreator<T>*C=0)
00032 : Iterator<T>(D)
00033 , myCreator(C)
00034 {}
00035
00036 CreativeIterator(index_t length, T*data, DataCreator<T>*C=0)
00037 : Iterator<T>(length, data)
00038 , myCreator(C)
00039 {}
00040
00041 CreativeIterator(const CreativeIterator&CI)
00042 : Iterator<T>(CI)
00043 , myCreator(CI.myCreator)
00044 {}
00045
00046 typedef typename MetaInfo<T>::element_t component_t;
00047
00048 typedef FixedArray< component_t,
00049 MetaInfo<T>::MULTIPLICITY> FixedArray_t;
00050
00051 typedef typename META::IF< MetaInfo<T>::MULTIPLICITY == 1,
00052 component_t, FixedArray_t>::result ValueBase_t;
00053
00054
00059 typedef typename META::IF< MetaInfo<T>::MULTIPLICITY == 1,
00060 void, FixedArray_t>::result FixedArrayBase_t;
00061
00062 typedef Eagle::Vector< component_t,
00063 MetaInfo<T>::MULTIPLICITY> VectorArray_t;
00064
00069 typedef typename META::IF< MetaInfo<T>::RANK == 0,
00070 void, VectorArray_t>::result VectorArrayBase_t;
00071 };
00072
00073 template <class T>
00074 struct DataCreator
00075 {
00076 typedef typename Iterator<T>::reference_t reference_t;
00077
00078 virtual ~DataCreator() = 0;
00079
00080 virtual CreativeIterator<T> slice(int Dimension, index_t i) = 0;
00081
00082 virtual reference_t getElement(index_t i) = 0;
00083 };
00084
00085
00086 }
00087
00088 #endif
00089