1#ifndef joedb_Table_declared
2#define joedb_Table_declared
21 std::map<Field_Id, Field> fields;
22 std::map<Field_Id, std::string> field_names;
30 const std::map<Field_Id, Field> &
get_fields()
const {
return fields;}
41 #define TYPE_MACRO(type, return_type, type_id, R, W)\
42 return_type get_##type_id(Record_Id rid, Field_Id fid) const\
44 return fields.find(fid)->second.get_##type_id(rid);\
46 void update_##type_id(Record_Id record_id,\
50 const auto it = fields.find(field_id);\
51 if (it == fields.end())\
52 throw Exception("update: invalid field_id");\
53 if (!freedom.is_used(to_underlying(record_id) + 1))\
54 throw Exception("update: invalid record_id");\
55 it->second.set_##type_id(record_id, value);\
57 void update_vector_##type_id(Record_Id record_id,\
62 const auto it = fields.find(field_id);\
63 if (it == fields.end())\
64 throw Exception("update_vector: invalid field_id");\
65 if (!freedom.is_used(to_underlying(record_id) + 1) ||\
66 !freedom.is_used(to_underlying(record_id) + size))\
67 throw Exception("update_vector: invalid record_id range");\
68 it->second.set_vector_##type_id(record_id, size, value);\
70 type *get_own_##type_id##_storage(Record_Id record_id, Field_Id field_id)\
72 const auto it = fields.find(field_id);\
73 if (it == fields.end())\
74 throw Exception("get_own_storage: invalid field_id");\
75 if (!freedom.is_used(to_underlying(record_id) + 1))\
76 throw Exception("get_own_storage: invalid record_id");\
77 return it->second.get_own_##type_id##_storage(record_id);\
79 const type *get_own_##type_id##_storage(Record_Id record_id, Field_Id field_id) const\
81 const auto it = fields.find(field_id);\
82 if (it == fields.end())\
83 throw Exception("get_own_storage: invalid field_id");\
84 if (!freedom.is_used(to_underlying(record_id) + 1))\
85 throw Exception("get_own_storage: invalid record_id");\
86 return it->second.get_own_##type_id##_storage(record_id);\
void delete_record(Record_Id record_id)
const std::map< Field_Id, Field > & get_fields() const
void drop_field(Field_Id field_id)
Field_Id find_field(const std::string &name) const
void insert_vector(Record_Id record_id, size_t size)
void add_field(const std::string &name, const Type &type)
void insert_record(Record_Id record_id)
const Compact_Freedom_Keeper & get_freedom() const
size_t get_storage_capacity() const