Revision 17 (by moose, 2008/12/14 10:46:25) update svn
#include <cstdio>
#include <vector>

#define log(a, b...) do{\
	char __tmp__[2048]; \
	snprintf(__tmp__, 2048, a,##b); \
	fprintf(stderr, "%i:%s:%s: %s\n", __LINE__, __FUNCTION__, __FILE__, __tmp__); \
} while(0)

/*
Engine has DataStore
Engine has DataInterface

Ok, thinking about template meta programming here, somehow allow you to create N types,
maybe using an enum or something, possibly based on this:
http://www.cs.ualberta.ca/~graphics/software/boost/libs/mpl/doc/paper/html/intro.html#intro.cxx.seq
ie:

typedef uint32_t I3[3];
typedef uint32_t I4[4];

typedef double D3[3];
typedef double D4[4];

template< typename First, typename Rest >
struct cons
{
    typedef First first;
    typedef Rest rest;
};

struct nil {};

typedef
      cons<I3
    , cons<I4
    , cons<D3
    , cons<D4
    , nil
    > > > > my_types;

DataStore<double, 3> VectorData;
DataStore<double, 3> ColorData;


// Or something like:

typedef uint32_t I3[3];
typedef uint32_t I4[4];

typedef double D3[3];
typedef double D4[4];

struct types {
	union {
		I3 i3;
		I4 i4;
		D3 d3;
		D4 d4;
	};
};
*/

// growable data type
template < typename T, int N >
class DataStore {
	public:

		struct Type {
			Type() { for(int i=0; i<N; ++i) t[i] = (T)0; }
			Type( T *d ) { for(int i=0; i<N; ++i) t[i] = d[i]; }
			Type( T &d ) : t(d) { }
			void operator=( T d[N] ) { t = d; }
			T operator[]( int n ) { return t[n]; }
			T t[N];
		};

		DataStore( Type &t );
		Type operator[]( int n ) { return Type( data + ( n * N ) ); }

	private:
		T *data;
};

// OR

template < typename T >
class DataStore {
	public:
		enum { ItemCount = sizeof( T ) / sizeof ( typename( T ) ) };
		typedef typename T ItemType;

		struct Type {
			Type() { for(int i=0; i<ItemCount; ++i) t[i] = (T)0; }
			Type( ItemType *d ) { for(int i=0; i<ItemCount; ++i) t[i] = d[i]; }
			Type( ItemType &d ) : t(d) { }
			void operator=( ItemType d[N] ) { t = d; }
			ItemType operator[]( int n ) { return t[n]; }
			ItemType t[N];
		};

		DataStore( T &t );
		Type operator[]( int n ) { return Type( data + ( n * N ) ); }

	private:
		ItemType *data;
};

template < typename T, int M >
class DataInterface {
	public:

		template < typename S, int N >
		int addStore( ) { int new_id; b[new_id] = new DataBuffer<S,N>; return new_id; }
		// int my_store = foo->addStore< double, 3 >();
		// OR
		// int my_store = foo->addStore< double[3] >();

	private:
		DataBuffer< T, M > *b;
		// OR
		DataBuffer< T[M] > *b;
};

DataStore< double

!!!!!!!!! NONE OF THIS IS WHAT I'M LOOKING FOR !!!!!!!!!  >:E

class DataInterface { .. }

class DataStore { ... }

int main(int argc, char **argv)
{


	return 0;
}