Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F71163594
memory.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jul 10, 01:11
Size
2 KB
Mime Type
text/x-c++
Expires
Fri, Jul 12, 01:11 (2 d)
Engine
blob
Format
Raw Data
Handle
18915775
Attached To
rAKA akantu
memory.hh
View Options
/**
* @file memory.hh
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @date Tue Jun 15 09:30:23 2010
*
* @brief wrapper for the static_memory, all object which wants
* to access the ststic_memory as to inherit from the class memory
*
* @section LICENSE
*
* <insert lisence here>
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __MYFEM_MEMORY_HH__
#define __MYFEM_MEMORY_HH__
/* -------------------------------------------------------------------------- */
#include "common.hh"
#include "static_memory.hh"
#include "vector.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_MYFEM__
class
Memory
{
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public
:
Memory
(
MemoryID
memory_id
=
0
);
virtual
~
Memory
()
{};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public
:
/// malloc
template
<
class
T
>
inline
Vector
<
T
>
&
malloc
(
const
VectorID
&
name
,
unsigned
int
size
,
unsigned
int
nb_component
);
/* ------------------------------------------------------------------------ */
/// free an array
inline
void
free
(
const
VectorID
&
name
);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public
:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private
:
/// the static memory instance
StaticMemory
*
static_memory
;
/// the id registred in the static memory
MemoryID
memory_id
;
};
/* -------------------------------------------------------------------------- */
/* Inline functions */
/* -------------------------------------------------------------------------- */
template
<
class
T
>
inline
Vector
<
T
>
&
Memory
::
malloc
(
const
VectorID
&
name
,
unsigned
int
size
,
unsigned
int
nb_component
)
{
return
static_memory
->
smalloc
<
T
>
(
memory_id
,
name
,
size
,
nb_component
);
}
/* -------------------------------------------------------------------------- */
inline
void
Memory
::
free
(
const
VectorID
&
name
)
{
static_memory
->
sfree
(
memory_id
,
name
);
}
/* -------------------------------------------------------------------------- */
__END_MYFEM__
#endif
/* __MYFEM_MEMORY_HH__ */
Event Timeline
Log In to Comment