// Ryzom - MMORPG Framework
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
#ifndef RYAI_STATIC_VECTOR_H
#define RYAI_STATIC_VECTOR_H
/*
This class implements an array of entities of any derived class of a given base class
The entities are allocated in a single memory block.
*/
// not the way to use templates .. ( bad generalisation implementation ).
/*
template
class StaticVector
{
public:
// ctor & dtor --------------------------------------------------
StaticVector(): _data(0), _count(0), _size(0) {}
~StaticVector() { if (_data) delete[] _data; }
// allocate memory and initialise objects -----------------------
template
void init(uint count,DerivedClass *&dc)
{
nlassert(_data==NULL);
_count=count;
_data=(BaseClass*)malloc(count*sizeof(DerivedClass));
_size=sizeof(DerivedClass);
nlassert(_data!=NULL);
for (uint i=0;i