ARB
Main Page
Namespaces
Classes
Files
File List
File Members
ARBDB
gb_storage.h
Go to the documentation of this file.
1
// =============================================================== //
2
// //
3
// File : gb_storage.h //
4
// Purpose : //
5
// //
6
// Institute of Microbiology (Technical University Munich) //
7
// http://www.arb-home.de/ //
8
// //
9
// =============================================================== //
10
11
#ifndef GB_STORAGE_H
12
#define GB_STORAGE_H
13
14
#ifndef GB_DATA_H
15
#include "
gb_data.h
"
16
#endif
17
18
CONSTEXPR_INLINE
bool
store_inside_entry
(
int
size,
int
memsize) {
19
// returns true if data can be stored inside GBENTRY
20
return
size<256 && memsize<
SIZOFINTERN
;
21
}
22
23
inline
char
*
GBENTRY::alloc_data
(
long
Size,
long
Memsize) {
24
char
*mem;
25
gb_assert
(!
flags2
.
is_indexed
);
26
gb_assert
(
implicated
(
stored_external
(), !
data
()));
// would leak memory
27
28
if
(
store_inside_entry
(Size, Memsize)) {
29
mark_as_intern
();
30
31
info
.
istr
.
size
= (
unsigned
char
)Size;
32
info
.
istr
.
memsize
= (
unsigned
char
)Memsize;
33
34
mem =
data
();
35
}
36
else
{
37
mark_as_extern
();
38
39
info
.
ex
.
size
= Size;
40
info
.
ex
.
memsize
= Memsize;
41
42
mem = (
char
*)
gbm_get_mem
((
size_t
)Memsize,
GB_GBM_INDEX
(
this
));
43
info
.
ex
.
set_data
(mem);
44
}
45
return
mem;
46
}
47
48
class
GBENTRY_memory
:
virtual
Noncopyable
{
49
GBENTRY
*gbe;
50
char
*mem;
51
public
:
52
GBENTRY_memory
(
GBENTRY
*gb_entry,
long
size,
long
memsize)
53
: gbe(gb_entry),
54
mem(gbe->alloc_data(size, memsize))
55
{}
56
~GBENTRY_memory
() { gbe->
index_re_check_in
(); }
57
operator
char
*() {
return
mem; }
58
};
59
60
inline
void
GBENTRY::insert_data
(
const
char
*
Data
,
long
Size,
long
Memsize) {
61
gb_assert
(Data);
62
memcpy(
GBENTRY_memory
(
this
, Size, Memsize), Data, Memsize);
63
}
64
65
#else
66
#error gb_storage.h included twice
67
#endif // GB_STORAGE_H
store_inside_entry
CONSTEXPR_INLINE bool store_inside_entry(int size, int memsize)
Definition:
gb_storage.h:18
gb_extern_data::memsize
long memsize
Definition:
gb_data.h:29
GBENTRY_memory::~GBENTRY_memory
~GBENTRY_memory()
Definition:
gb_storage.h:56
GB_GBM_INDEX
#define GB_GBM_INDEX(gbd)
Definition:
gb_data.h:127
GB_INTern_strings::size
unsigned char size
Definition:
gb_data.h:39
implicated
#define implicated(hypothesis, conclusion)
Definition:
arb_assert.h:289
GB_INTern_strings::memsize
unsigned char memsize
Definition:
gb_data.h:38
GBDATA::flags2
gb_flag_types2 flags2
Definition:
gb_data.h:135
GBENTRY::info
gb_data_base_type_union info
Definition:
gb_data.h:204
GBENTRY::insert_data
void insert_data(const char *Data, long Size, long Memsize)
Definition:
gb_storage.h:60
gb_data_base_type_union::istr
GB_INTern_strings istr
Definition:
gb_data.h:49
GBENTRY
Definition:
gb_data.h:199
CONSTEXPR_INLINE
#define CONSTEXPR_INLINE
Definition:
cxxforward.h:111
SIZOFINTERN
#define SIZOFINTERN
Definition:
gb_data.h:25
GBENTRY::index_re_check_in
void index_re_check_in()
Definition:
gb_data.h:235
GBENTRY::alloc_data
char * alloc_data(long Size, long Memsize)
Definition:
gb_storage.h:23
gb_extern_data::size
long size
Definition:
gb_data.h:30
gbm_get_mem
void * gbm_get_mem(size_t size, long index)
Definition:
gb_memory.h:130
gb_flag_types2::is_indexed
unsigned int is_indexed
Definition:
gb_data.h:88
gb_data_base_type_union::ex
gb_extern_data ex
Definition:
gb_data.h:51
GBENTRY::data
char * data()
Definition:
gb_data.h:219
GBENTRY::mark_as_intern
void mark_as_intern()
Definition:
gb_data.h:208
gb_assert
#define gb_assert(cond)
Definition:
arbdbt.h:11
GBENTRY::stored_external
bool stored_external() const
Definition:
gb_data.h:211
GBENTRY_memory::GBENTRY_memory
GBENTRY_memory(GBENTRY *gb_entry, long size, long memsize)
Definition:
gb_storage.h:52
gb_data.h
Data
Definition:
aisc_interpreter.h:363
GBENTRY::mark_as_extern
void mark_as_extern()
Definition:
gb_data.h:209
char
GBENTRY_memory
Definition:
gb_storage.h:48
gb_extern_data::set_data
void set_data(char *data)
Definition:
gb_data.h:33
Noncopyable
Definition:
arbtools.h:39
Generated by
1.8.8