[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN/internal membase.hh
From: |
Tom Drummond |
Subject: |
[Toon-members] TooN/internal membase.hh |
Date: |
Tue, 27 Jan 2009 12:01:51 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Tom Drummond <twd20> 09/01/27 12:01:51
Added files:
internal : membase.hh
Log message:
adding my memory management structure
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/membase.hh?cvsroot=toon&rev=1.1
Patches:
Index: membase.hh
===================================================================
RCS file: membase.hh
diff -N membase.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ membase.hh 27 Jan 2009 12:01:51 -0000 1.1
@@ -0,0 +1,59 @@
+
+#ifndef TOON_MAX_STACK_SIZE
+static const int TOON_MAX_STACK_SIZE=10;
+#endif
+
+template <int Rows, int Cols>
+struct MMemSize{
+ static const int size=Rows*Cols;
+};
+
+template<>
+struct MMemSize<-1,-1> {
+ static const int size=-1;
+};
+
+
+template<int Size, typename Precision, int
Place=(Size>TOON_MAX_STACK_SIZE?1:0)>
+struct MemBase;
+
+// stack memory
+template<int Size, typename Precision>
+struct MemBase<Size, Precision, 0> {
+
+
+
+ Precision my_data[Size];
+};
+
+// heap memory
+template<int Size, typename Precision>
+struct MemBase<Size, Precision, 1>{
+ MemBase() : my_data(new Precision[Size]){
+ }
+ ~MemBase(){
+ delete[] my_data;
+ }
+
+
+
+ Precision* const my_data;
+};
+
+
+
+// dynamic memory
+template<typename Precision>
+struct MemBase<-1,Precision,0> {
+ MemBase(const int Size) : my_data(new Precision[Size]), my_size(size){
+ }
+ ~MemBase(){
+ delete[] my_data;
+ }
+
+
+
+ Precision* const my_data;
+ int my_size;
+};
+
- [Toon-members] TooN/internal membase.hh,
Tom Drummond <=