Line | |
---|
1 | /**
|
---|
2 | * @file memory.h
|
---|
3 | * @author myusgun@gmail.com
|
---|
4 | * @brief memory
|
---|
5 | */
|
---|
6 | #ifndef __cf_memory_h__
|
---|
7 | #define __cf_memory_h__
|
---|
8 |
|
---|
9 | #include "cf/types.h"
|
---|
10 | #include "cf/exception.h"
|
---|
11 |
|
---|
12 | namespace cf
|
---|
13 | {
|
---|
14 | /**
|
---|
15 | * memory
|
---|
16 | */
|
---|
17 | class memory
|
---|
18 | {
|
---|
19 | private:
|
---|
20 | cf::void_t * mMemory;
|
---|
21 |
|
---|
22 | public:
|
---|
23 | /**
|
---|
24 | * constructor. allocate memory
|
---|
25 | * @param size memory size
|
---|
26 | * @throw cf::exception
|
---|
27 | */
|
---|
28 | memory(const cf::size_t size = 0)
|
---|
29 | throw (cf::exception);
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * destructor. free memory
|
---|
33 | */
|
---|
34 | virtual ~memory();
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * get buffer memory address
|
---|
38 | */
|
---|
39 | cf::void_t * buffer();
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * static member function to get an address of allocated memory
|
---|
43 | * @param size memory size
|
---|
44 | * @throw cf::exception
|
---|
45 | */
|
---|
46 | static cf::void_t * alloc(const cf::size_t size)
|
---|
47 | throw (cf::exception);
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * static member function to free a memory allocated from cf::memory::alloc()
|
---|
51 | * @param mem memory address
|
---|
52 | * @throw cf::exception
|
---|
53 | */
|
---|
54 | static cf::void_t free(cf::void_t * mem)
|
---|
55 | throw (cf::exception);
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * static member function to check the memory is valid
|
---|
59 | * @return true; false
|
---|
60 | * @param mem memory address
|
---|
61 | */
|
---|
62 | static cf::bool_t valid(const cf::void_t * mem);
|
---|
63 | };
|
---|
64 | }
|
---|
65 |
|
---|
66 | #endif // #ifndef __cf_memory_h__
|
---|
Note:
See
TracBrowser
for help on using the repository browser.