-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgh_core.cpp
More file actions
143 lines (121 loc) · 3.24 KB
/
gh_core.cpp
File metadata and controls
143 lines (121 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include "gh_core.h"
gh_core::gh_core(const char * _hed_name, bool _is_opt, bool _is_logs)
{
integrity = conn_db(_hed_name, _is_opt);
switch(integrity)
{
// case 2 :
// {
// for(unsigned int i = 0; i < gh::dim_qua; i++) hie->dim_size[i] = hed->size[i];
// if(_is_logs) hie_log(_hed_name);
// }
case 1 :
{
//DEBUG("Start log\n");
if(_is_logs) hed->log(_hed_name);
//DEBUG("Stop log\n");
break;
}
default:
{
ERROR
printf("gh_core: Cannot connect to data source %s\n", _hed_name);
}
}
}
gh_core::~gh_core()
{
// switch(integrity)
// {
// case 2 : delete hie;
// case 1 :
// {
// delete inf;
// delete idx;
delete hed;
// }
// }
}
unsigned int gh_core::conn_db(const char * _file_name, bool _is_opt)
{
char name[256];
strcpy(name, _file_name);
char * a = strstr(name, ".hed");
if(!a) return 0;
* a = '\0';
char hed_name[256];
strcpy(hed_name, name);
strcat(hed_name, ".hed");
FILE * fp_hed = fopen(hed_name, "rb");
if(!fp_hed) return 0;
//DEBUG("hed done\n");
// char idx_name[256];
// strcpy(idx_name, name);
// strcat(idx_name, ".idx");
// FILE * fp_idx = fopen(idx_name, "rb");
// if(!fp_idx) return 0;
//DEBUG("idx done\n");
// char inf_name[256];
// strcpy(inf_name, name);
// strcat(inf_name, ".inf");
// FILE * fp_inf = fopen(inf_name, "rb");
// if(!fp_inf) return 0;
//DEBUG("inf done\n");
hed = new gh_hed(fp_hed);
fclose(fp_hed);
return 1;
//DEBUG("idx switch 1\n");
// idx = _is_opt ? new gh_idx(fp_idx, hed->size) : new gh_idx(fp_idx);
// inf = new gh_inf(fp_inf);
//DEBUG("idx switch 2\n");
// char chr_name[256];
// strcpy(chr_name, name);
// strcat(chr_name, ".chr");
// FILE * fp_chr = fopen(chr_name, "rb");
// if(!fp_chr) return 1;
// char tad_name[256];
// strcpy(tad_name, name);
// strcat(tad_name, ".tad");
// FILE * fp_tad = fopen(tad_name, "rb");
// if(!fp_tad) return 1;
// hie = new gh_hie(fp_chr, fp_tad);
//DEBUG("Hi there!\n");
// return 2;
}
//const char * gh_core::get_attr_by_num(unsigned int _dim_num, unsigned int _att_num, unsigned int _item_num)
//{
// if(_dim_num >= gh::dim_qua) return 0;
// if(_att_num > 2) return 0;
// if((_item_num < 0) || (_item_num >= hed->size[_dim_num])) return 0;
// return hed->att[_dim_num][_item_num][_att_num];
//}
///////////////////////////////////////////////////////////////////////////////
//void gh_core::hie_log(const char * _hed_name)
//{
// char log_name[350];
// strcpy(log_name, _hed_name);
// char * a = 0;
// while((a = strchr(log_name, '/'))) * a = '_';
// if((a = strrchr(log_name, '.'))) * a = '\0';
// strcat(log_name, ".hie.log");
// FILE * fp = fopen(log_name, "w");
// if(!fp)
// {
// ERROR;
// printf("gh_core:Cannot open \"hie.log\" file\n");
// return;
// }
// for(unsigned int i(0); i < gh::dim_qua; i++)
// {
// fprintf(fp, "********************** Dimension:%d **********************\n", i);
// for(unsigned int j(0); j < hie->seg_qua[i]; j++)
// {
// fprintf(fp, "Segment: %3d %s\n", j, hie->seg[i][j]);
// for(unsigned int k(0); k < hie->off_qua[i][j]; k++)
// {
// fprintf(fp, "\tOffset: %5d :%-82s\n", k, hie->off[i][j][k]);
// }
// }
// }
// fclose(fp);
//}