00001 00002 /* 00003 Copyright (C) 2005 Tom Drummond 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc. 00018 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 #ifndef __MEMBASE_H 00021 #define __MEMBASE_H 00022 00023 00024 // the class *is* the data (so a local variable places it on the stack) 00025 template<int Size> 00026 class Stack { 00027 protected: 00028 double my_values[Size]; 00029 } __attribute__ ((aligned(16))); 00030 00031 // the class allocates and deallocates the data on the heap 00032 template<int Size> 00033 class Heap { 00034 public: 00035 inline Heap(){my_values = new double[Size];} 00036 inline Heap(const Heap& copyof){ 00037 my_values = new double[Size]; 00038 memcpy(my_values,copyof.my_values,Size*sizeof(double)); 00039 } 00040 00041 inline Heap& operator=(const Heap& copyof){ 00042 memcpy(my_values,copyof.my_values,Size*sizeof(double)); 00043 } 00044 00045 inline ~Heap(){delete [] my_values;} 00046 protected: 00047 double* my_values; 00048 }; 00049 00050 00051 00052 00053 00054 00055 00056 #endif