Orbiter 2022
Combinatorial Objects
mem_object_registry_entry.cpp
Go to the documentation of this file.
1// mem_object_registry_entry.cpp
2//
3// Anton Betten
4//
5// started: June 25, 2009
6
7
8
9
10#include "foundations.h"
11
12using namespace std;
13
14
15
16
17namespace orbiter {
18namespace layer1_foundations {
19namespace orbiter_kernel_system {
20
21
22
23
24
25
27{
28 null();
29}
30
32{
33
34}
35
37{
38 time_stamp = 0;
39 pointer = NULL;
41 object_n = 0;
43 extra_type_info = NULL;
44 source_file = NULL;
45 source_line = 0;
46}
47
49{
50 if (strcmp(str, "int") == 0) {
52 }
53 else if (strcmp(str, "pint") == 0) {
55 }
56 else if (strcmp(str, "lint") == 0) {
58 }
59 else if (strcmp(str, "plint") == 0) {
61 }
62 else if (strcmp(str, "ppint") == 0) {
64 }
65 else if (strcmp(str, "char") == 0) {
67 }
68 else if (strcmp(str, "uchar") == 0) {
70 }
71 else if (strcmp(str, "pchar") == 0) {
73 }
74 else if (strcmp(str, "puchar") == 0) {
76 }
77 else if (strcmp(str, "pvoid") == 0) {
79 }
80 else if (strcmp(str, "OBJECT") == 0) {
82 }
83 else if (strcmp(str, "OBJECTS") == 0) {
85 }
86 else {
88 }
89}
90
92{
94 ost << "invalid entry";
95 }
96 else if (object_type == POINTER_TYPE_int) {
97 ost << "int";
98 }
99 else if (object_type == POINTER_TYPE_pint) {
100 ost << "pint";
101 }
102 else if (object_type == POINTER_TYPE_lint) {
103 ost << "lint";
104 }
105 else if (object_type == POINTER_TYPE_plint) {
106 ost << "plint";
107 }
108 else if (object_type == POINTER_TYPE_ppint) {
109 ost << "ppint";
110 }
111 else if (object_type == POINTER_TYPE_char) {
112 ost << "char";
113 }
114 else if (object_type == POINTER_TYPE_uchar) {
115 ost << "uchar";
116 }
117 else if (object_type == POINTER_TYPE_pchar) {
118 ost << "pchar";
119 }
120 else if (object_type == POINTER_TYPE_puchar) {
121 ost << "puchar";
122 }
123 else if (object_type == POINTER_TYPE_PVOID) {
124 ost << "pvoid";
125 }
126 else if (object_type == POINTER_TYPE_OBJECT) {
127 ost << "OBJECT";
128 }
129 else if (object_type == POINTER_TYPE_OBJECTS) {
130 ost << "OBJECTS";
131 }
132 else {
133 ost << "unknown" << endl;
134 }
135}
136
137
139{
141 cout << "mem_object_registry_entry::size_of invalid entry" << endl;
142 exit(1);
143 }
144 else if (object_type == POINTER_TYPE_int) {
145 return sizeof(int) * object_n;
146 }
147 else if (object_type == POINTER_TYPE_pint) {
148 return sizeof(int *) * object_n;
149 }
150 else if (object_type == POINTER_TYPE_lint) {
151 return sizeof(long int) * object_n;
152 }
153 else if (object_type == POINTER_TYPE_plint) {
154 return sizeof(long int *) * object_n;
155 }
156 else if (object_type == POINTER_TYPE_ppint) {
157 return sizeof(int **) * object_n;
158 }
159 else if (object_type == POINTER_TYPE_char) {
160 return sizeof(char) * object_n;
161 }
162 else if (object_type == POINTER_TYPE_uchar) {
163 return sizeof(uchar) * object_n;
164 }
165 else if (object_type == POINTER_TYPE_pchar) {
166 return sizeof(char *) * object_n;
167 }
168 else if (object_type == POINTER_TYPE_puchar) {
169 return sizeof(uchar *) * object_n;
170 }
171 else if (object_type == POINTER_TYPE_PVOID) {
172 return sizeof(pvoid) * object_n;
173 }
174 else if (object_type == POINTER_TYPE_OBJECT) {
175 return object_size_of;
176 }
177 else if (object_type == POINTER_TYPE_OBJECTS) {
178 return object_n * object_size_of;
179 }
180 else {
181 cout << "mem_object_registry_entry::size_of "
182 "unknown object type " << object_type << endl;
183 exit(1);
184 }
185}
186
188{
190
191 cout << line << " : ";
192 Algo.print_pointer_hex(cout, pointer);
193 cout << " : " << time_stamp << " : ";
194
195 print_type(cout);
196
197 cout << " : "
198 << object_n << " : "
199 << object_size_of << " : "
200 << extra_type_info << " : "
201 << source_file << " : "
202 << source_line << endl;
203
204}
205
206
207void mem_object_registry_entry::print_csv(ostream &ost, int line)
208{
210
211 ost << line << ",";
212 Algo.print_pointer_hex(ost, pointer);
213 ost << "," << time_stamp << ",";
214
215 print_type(ost);
216
217 ost << ","
218 << object_n << ","
219 << object_size_of << ","
220 << extra_type_info << ","
221 << source_file << ","
222 << source_line << endl;
223
224}
225
226
227
228
229}}}
230
void print_pointer_hex(std::ostream &ost, void *p)
Definition: algorithms.cpp:116
void set_type_from_string(char *str)
const char * source_file
void print(int line)
int object_size_of
void * pointer
mem_object_registry_entry()
int size_of()
int time_stamp
void null()
int object_type
~mem_object_registry_entry()
long int object_n
void print_csv(std::ostream &ost, int line)
int source_line
const char * extra_type_info
void print_type(std::ostream &ost)
unsigned char uchar
Definition: foundations.h:204
void * pvoid
Definition: foundations.h:206
the orbiter library for the classification of combinatorial objects
#define POINTER_TYPE_puchar
#define POINTER_TYPE_uchar
#define POINTER_TYPE_pint
#define POINTER_TYPE_lint
#define POINTER_TYPE_ppint
#define POINTER_TYPE_int
#define POINTER_TYPE_INVALID
#define POINTER_TYPE_OBJECTS
#define POINTER_TYPE_pchar
#define POINTER_TYPE_PVOID
#define POINTER_TYPE_OBJECT
#define POINTER_TYPE_char
#define POINTER_TYPE_plint