├── iamtheecs.jpg ├── lua_dll_build_test ├── DataContainerGenerator.exe ├── objs.txt ├── lua_dll_build_test.vcxproj.filters ├── lua_objs.hpp └── lua_dll_build_test.vcxproj ├── Catch_color_tutorial_tests ├── color_tutorial.hpp ├── old_color_container.txt ├── color_container.txt ├── Catch_color_tutorial_tests.vcxproj.filters ├── color_container.cpp └── Catch_color_tutorial_tests.cpp ├── CommonIncludes ├── common_types.cpp ├── CommonIncludes.vcxproj.filters └── CommonIncludes.vcxproj ├── Catch_core_datacontainer_tests ├── car_owner_basic3.txt ├── car_owner_basic2.txt ├── expandable_test.txt ├── car_owner_basic.txt └── Catch_core_datacontainer_tests.vcxproj.filters ├── changes.md ├── Catch_ecs_tutorial_tests ├── ecs.txt ├── Catch_ecs_tutorial_tests.vcxproj.filters ├── Catch_ecs_tutorial_tests.cpp └── Catch_ecs_tutorial_tests.vcxproj ├── Catch_ve_tests ├── Catch_ve_tests.vcxproj.filters ├── .clang-tidy └── Catch_ve_tests.vcxproj ├── Catch_parsing_tests ├── Catch_parsing_tests.vcxproj.filters ├── .clang-tidy └── Catch_parsing_tests.vcxproj ├── Catch_stable_storage_tests ├── Catch_stable_storage_tests.vcxproj.filters ├── Catch_stable_storage_tests.vcxproj └── Catch_stable_storage_tests.cpp ├── Catch_query_tests ├── Catch_query_tests.vcxproj.filters ├── query_objs.txt └── Catch_query_tests.vcxproj ├── Catch_objects_tests ├── Catch_objects_tests.vcxproj.filters ├── objects_def.txt ├── Catch_objects_tests.cpp └── Catch_objects_tests.vcxproj ├── Catch_relationships_tests ├── Catch_relationships_tests.vcxproj.filters ├── relation.txt └── Catch_relationships_tests.vcxproj ├── Catch_serialization_tests ├── Catch_serialization_tests.vcxproj.filters ├── new_ser.txt ├── old_ser.txt └── Catch_serialization_tests.vcxproj ├── LuaDLLGenerator ├── LuaDLLGenerator.vcxproj.filters ├── source_builder.hpp └── LuaDLLGenerator.vcxproj ├── basic.runsettings ├── DataContainerGenerator ├── .clang-tidy ├── DataContainerGenerator.vcxproj.filters ├── source_builder.hpp ├── code_fragments.hpp └── DataContainerGenerator.vcxproj ├── .gitattributes ├── getting_started.md ├── README.md ├── multithreading.md ├── .gitignore └── tutorial_color.md /iamtheecs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schombert/DataContainer/HEAD/iamtheecs.jpg -------------------------------------------------------------------------------- /lua_dll_build_test/DataContainerGenerator.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schombert/DataContainer/HEAD/lua_dll_build_test/DataContainerGenerator.exe -------------------------------------------------------------------------------- /Catch_color_tutorial_tests/color_tutorial.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | struct rgb_color { 5 | float red = 0.0f; 6 | float green = 0.0f; 7 | float blue = 0.0f; 8 | }; 9 | -------------------------------------------------------------------------------- /CommonIncludes/common_types.cpp: -------------------------------------------------------------------------------- 1 | #include "common_types.hpp" 2 | 3 | #ifndef DCON_STABLE_STORAGE_IMPLEMENTATION 4 | #define DCON_STABLE_STORAGE_IMPLEMENTATION 5 | namespace dcon { 6 | stable_variable_vector3_backing shared_backing_storage; 7 | } 8 | #endif 9 | -------------------------------------------------------------------------------- /Catch_color_tutorial_tests/old_color_container.txt: -------------------------------------------------------------------------------- 1 | namespace{old} 2 | 3 | object{ 4 | name{colored_thing} 5 | size{3000} 6 | storage_type{contiguous} 7 | 8 | property { 9 | name{red} 10 | type{float} 11 | } 12 | property { 13 | name{green} 14 | type{float} 15 | } 16 | property { 17 | name{blue} 18 | type{float} 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /Catch_color_tutorial_tests/color_container.txt: -------------------------------------------------------------------------------- 1 | include{"color_tutorial.hpp"} 2 | 3 | object{ 4 | name{colored_thing} 5 | size{3000} 6 | storage_type{contiguous} 7 | 8 | property { 9 | name{color} 10 | type{rgb_color} 11 | } 12 | 13 | function{void @set_red(float @value)} 14 | function{void @set_green(float @value)} 15 | function{void @set_blue(float @value)} 16 | const_function{float @get_red()} 17 | const_function{float @get_green()} 18 | const_function{float @get_blue()} 19 | } 20 | 21 | global{void deserialize_rgb(std::byte const* start, std::byte const* end, load_record& record_in_out);} -------------------------------------------------------------------------------- /Catch_core_datacontainer_tests/car_owner_basic3.txt: -------------------------------------------------------------------------------- 1 | namespace{cob3} 2 | 3 | object{ 4 | name{car} 5 | storage_type{erasable} 6 | size{ 1200 } 7 | 8 | property{ 9 | name{wheels} 10 | type{int32_t} 11 | } 12 | property{ 13 | name{resale_value} 14 | type{float} 15 | } 16 | } 17 | 18 | object{ 19 | name{person} 20 | storage_type{erasable} 21 | size{100} 22 | 23 | property{ 24 | name{age} 25 | type{int32_t} 26 | } 27 | } 28 | 29 | relationship{ 30 | name{car_ownership} 31 | 32 | link{ 33 | object{person} 34 | name{owner} 35 | type{many} 36 | index_storage{std_vector} 37 | } 38 | link{ 39 | object{car} 40 | name{owned_car} 41 | type{unique} 42 | } 43 | 44 | property{ 45 | name{ownership_date} 46 | type{int32_t} 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Catch_core_datacontainer_tests/car_owner_basic2.txt: -------------------------------------------------------------------------------- 1 | namespace{cob2} 2 | 3 | object{ 4 | name{car} 5 | storage_type{compactable} 6 | size{ 1200 } 7 | 8 | property{ 9 | name{wheels} 10 | type{int32_t} 11 | } 12 | property{ 13 | name{resale_value} 14 | type{float} 15 | } 16 | } 17 | 18 | object{ 19 | name{person} 20 | storage_type{compactable} 21 | size{100} 22 | 23 | property{ 24 | name{age} 25 | type{int32_t} 26 | } 27 | } 28 | 29 | relationship{ 30 | name{car_ownership} 31 | 32 | link{ 33 | object{person} 34 | name{owner} 35 | type{many} 36 | index_storage{std_vector} 37 | } 38 | link{ 39 | object{car} 40 | name{owned_car} 41 | type{unique} 42 | } 43 | 44 | property{ 45 | name{ownership_date} 46 | type{int32_t} 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Catch_core_datacontainer_tests/expandable_test.txt: -------------------------------------------------------------------------------- 1 | namespace{ex1} 2 | 3 | object{ 4 | name{top} 5 | storage_type{compactable} 6 | size{ expandable } 7 | 8 | property{ 9 | name{wheels} 10 | type{int32_t} 11 | } 12 | } 13 | 14 | object{ 15 | name{bottom} 16 | storage_type{contiguous} 17 | size{ expandable } 18 | 19 | property{ 20 | name{legs} 21 | type{int32_t} 22 | } 23 | } 24 | 25 | relationship{ 26 | name{lr_relation} 27 | size{ expandable } 28 | storage_type{erasable} 29 | 30 | link{ 31 | object{top} 32 | name{left} 33 | type{many} 34 | index_storage{std_vector} 35 | } 36 | link{ 37 | object{bottom} 38 | name{right} 39 | type{many} 40 | index_storage{std_vector} 41 | } 42 | 43 | property{ 44 | name{thingies} 45 | type{int32_t} 46 | } 47 | } -------------------------------------------------------------------------------- /changes.md: -------------------------------------------------------------------------------- 1 | ### version 0.2.1 2 | 3 | - updated unordered_dense header 4 | - Fixed a few bugs, thanks to Clang 5 | 6 | ### version 0.2.1 7 | 8 | - updated unordered_dense header 9 | - added an iterator interface (supporting `for(auto i : ...)` loops) for iterating over all of the object instances in the data container and all of the relationships linked via a `many` link to an object instance. 10 | 11 | ### version 0.2.0 12 | 13 | - added [query](queries.md) interface 14 | - changed the `vector_pool` property interface to work through a proxy object 15 | - improved gcc compatibility of the ve library 16 | - migrated to a more conventional way of reporting errors 17 | 18 | ### version 0.1.1 19 | 20 | - added `optional` links 21 | - added `multiple` links 22 | - added [color tutorial](tutorial_color.md) 23 | - various bug fixes 24 | 25 | ### version 0.1 26 | 27 | - First released version -------------------------------------------------------------------------------- /Catch_ecs_tutorial_tests/ecs.txt: -------------------------------------------------------------------------------- 1 | relationship{ 2 | name{entity} 3 | size{3000} 4 | storage_type{erasable} 5 | 6 | hook{delete} 7 | 8 | link{ 9 | object{position} 10 | name{position_component} 11 | type{unique}{optional} 12 | } 13 | link{ 14 | object{sprite} 15 | name{sprite_component} 16 | type{unique}{optional} 17 | } 18 | } 19 | 20 | object{ 21 | name{position} 22 | size{3000} 23 | storage_type{erasable} 24 | 25 | property{ 26 | name{x} 27 | type{float} 28 | } 29 | property{ 30 | name{y} 31 | type{float} 32 | } 33 | property{ 34 | name{rotation} 35 | type{float} 36 | } 37 | } 38 | 39 | object{ 40 | name{sprite} 41 | size{3000} 42 | storage_type{erasable} 43 | 44 | property{ 45 | name{sprite_id} 46 | type{uint16_t} 47 | } 48 | } 49 | 50 | query{ 51 | name{sprites_with_position} 52 | select{sprite.id as sprite, position.id as position 53 | from sprite, join entity, join position} 54 | } 55 | -------------------------------------------------------------------------------- /Catch_ve_tests/Catch_ve_tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Catch_parsing_tests/Catch_parsing_tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Catch_core_datacontainer_tests/car_owner_basic.txt: -------------------------------------------------------------------------------- 1 | namespace{car_owner_basic} 2 | 3 | object{ 4 | name{car} 5 | storage_type{contiguous} 6 | size{ 1200 } 7 | 8 | property{ 9 | name{wheels} 10 | type{int32_t} 11 | } 12 | property{ 13 | name{resale_value} 14 | type{float} 15 | } 16 | } 17 | 18 | object{ 19 | name{person} 20 | storage_type{contiguous} 21 | size{100} 22 | 23 | property{ 24 | name{age} 25 | type{int32_t} 26 | } 27 | } 28 | 29 | relationship{ 30 | name{car_ownership} 31 | 32 | link{ 33 | object{person} 34 | name{owner} 35 | type{many} 36 | index_storage{std_vector} 37 | } 38 | link{ 39 | object{car} 40 | name{owned_car} 41 | type{unique} 42 | } 43 | 44 | property{ 45 | name{ownership_date} 46 | type{int32_t} 47 | } 48 | } 49 | 50 | relationship{ 51 | name{uniq_car_ownership} 52 | 53 | link{ 54 | object{person} 55 | name{owner} 56 | type{unique} 57 | } 58 | link{ 59 | object{car} 60 | name{owned_car} 61 | type{unique} 62 | } 63 | 64 | property{ 65 | name{ownership_date} 66 | type{int32_t} 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Catch_stable_storage_tests/Catch_stable_storage_tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Catch_query_tests/Catch_query_tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /lua_dll_build_test/objs.txt: -------------------------------------------------------------------------------- 1 | object{ 2 | name{thingy} 3 | storage_type{compactable} 4 | size{2500} 5 | tag{simple} 6 | 7 | property{ 8 | name{some_value} 9 | type{int32_t} 10 | tag{simple} 11 | } 12 | 13 | property{ 14 | name{bf_value} 15 | type{bitfield} 16 | tag{simple} 17 | } 18 | 19 | property{ 20 | name{lua_value} 21 | type{lua_reference_type} 22 | } 23 | 24 | 25 | property{ 26 | name{pooled_v} 27 | type{vector_pool{1000}{int16_t}} 28 | } 29 | 30 | property{ 31 | name{big_array} 32 | type{array{thingy_id}{float}} 33 | } 34 | 35 | property{ 36 | name{big_array_bf} 37 | type{array{int32_t}{bitfield}} 38 | } 39 | } 40 | 41 | object { 42 | name { pop } 43 | storage_type { erasable } 44 | size { 300000 } 45 | tag {scenario} 46 | } 47 | 48 | relationship { 49 | name { negotiation } 50 | storage_type { erasable } 51 | size { 2500 } 52 | 53 | link { 54 | object { pop } 55 | name { initiator } 56 | type { many } 57 | index_storage{array} 58 | } 59 | link { 60 | object { pop } 61 | name { target } 62 | type { many } 63 | index_storage{array} 64 | } 65 | } 66 | 67 | load_save{ 68 | name{store_simple} 69 | only_objects{simple} 70 | only_properties{simple} 71 | } 72 | -------------------------------------------------------------------------------- /Catch_objects_tests/Catch_objects_tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Catch_relationships_tests/Catch_relationships_tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Catch_ecs_tutorial_tests/Catch_ecs_tutorial_tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /Catch_serialization_tests/Catch_serialization_tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | Header Files 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Catch_serialization_tests/new_ser.txt: -------------------------------------------------------------------------------- 1 | namespace{ns} 2 | 3 | legacy_types { 4 | name{std::vector} 5 | } 6 | convert{ 7 | from{std::vector} 8 | to{c_struct_b} 9 | } 10 | 11 | object{ 12 | name{thingy} 13 | storage_type{compactable} 14 | size{1200} 15 | 16 | tag{left} 17 | 18 | property{ 19 | name{i_value} 20 | type{int16_t} 21 | 22 | tag{simple} 23 | } 24 | 25 | property{ 26 | name{f_value} 27 | type{float} 28 | 29 | tag{simple} 30 | } 31 | 32 | property{ 33 | name{d_value} 34 | type{derived{int32_t}} 35 | } 36 | 37 | property{ 38 | name{obj_value} 39 | type{c_struct_b} 40 | } 41 | 42 | property { 43 | name{custom_struct} 44 | type{c_struct} 45 | } 46 | } 47 | 48 | object{ 49 | name{thingy2} 50 | storage_type{compactable} 51 | size{300} 52 | 53 | property{ 54 | name{some_value} 55 | type{int32_t} 56 | } 57 | } 58 | 59 | relationship{ 60 | name{dummy_rel} 61 | 62 | link{ 63 | object{thingy} 64 | name{left} 65 | type{many} 66 | index_storage{std_vector} 67 | } 68 | link{ 69 | object{thingy2} 70 | name{right} 71 | type{unique} 72 | 73 | } 74 | 75 | composite_key{ 76 | name{joint} 77 | index{left} 78 | index{right} 79 | } 80 | } 81 | 82 | load_save{ 83 | name{store_simple} 84 | only_objects{left} 85 | only_properties{simple} 86 | } 87 | 88 | load_save{ 89 | name{store_left} 90 | only_objects{left} 91 | } 92 | 93 | load_save{ 94 | name{store_right} 95 | exclude_objects{left} 96 | } 97 | -------------------------------------------------------------------------------- /LuaDLLGenerator/LuaDLLGenerator.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /basic.runsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 60000 7 | on 8 | --verbosity high --list-tests --reporter xml * 9 | 500 10 | 11 | Welcome 12 | 13 | 14 | Combine 15 | Slow 16 | ^Catch_ 17 | true 18 | normal 19 | StatsOnly 20 | ShortInfo 21 | 60 22 | , 23 | 20000 24 | ..\TestData 25 | Executable 26 | 27 | 28 | -------------------------------------------------------------------------------- /lua_dll_build_test/lua_dll_build_test.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Catch_color_tutorial_tests/Catch_color_tutorial_tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Catch_core_datacontainer_tests/Catch_core_datacontainer_tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Catch_serialization_tests/old_ser.txt: -------------------------------------------------------------------------------- 1 | namespace{os} 2 | 3 | object{ 4 | name{thingy} 5 | storage_type{compactable} 6 | size{1200} 7 | 8 | tag{left} 9 | 10 | property{ 11 | name{i_value} 12 | type{int16_t} 13 | 14 | tag{simple} 15 | } 16 | 17 | property{ 18 | name{f_value} 19 | type{float} 20 | 21 | tag{simple} 22 | } 23 | 24 | property{ 25 | name{bf_value} 26 | type{bitfield} 27 | 28 | tag{simple} 29 | } 30 | 31 | property{ 32 | name{d_value} 33 | type{derived{int32_t}} 34 | } 35 | 36 | property{ 37 | name{obj_value} 38 | type{object{std::vector}} 39 | } 40 | 41 | property{ 42 | name{pooled_v} 43 | type{vector_pool{1000}{int16_t}} 44 | } 45 | 46 | property{ 47 | name{big_array} 48 | type{array{int32_t}{float}} 49 | } 50 | 51 | property{ 52 | name{big_array_bf} 53 | type{array{int32_t}{bitfield}} 54 | } 55 | 56 | property { 57 | name{custom_struct} 58 | type{c_struct} 59 | } 60 | } 61 | 62 | object{ 63 | name{thingy2} 64 | storage_type{compactable} 65 | size{300} 66 | 67 | property{ 68 | name{some_value} 69 | type{int32_t} 70 | } 71 | } 72 | 73 | relationship{ 74 | name{dummy_rel} 75 | 76 | link{ 77 | object{thingy} 78 | name{left} 79 | type{many} 80 | index_storage{std_vector} 81 | } 82 | link{ 83 | object{thingy2} 84 | name{right} 85 | type{unique} 86 | 87 | } 88 | 89 | composite_key{ 90 | name{joint} 91 | index{left} 92 | index{right} 93 | } 94 | } 95 | 96 | load_save{ 97 | name{store_simple} 98 | only_objects{left} 99 | only_properties{simple} 100 | } 101 | 102 | load_save{ 103 | name{store_left} 104 | only_objects{left} 105 | } 106 | 107 | load_save{ 108 | name{store_right} 109 | exclude_objects{left} 110 | } 111 | -------------------------------------------------------------------------------- /Catch_ve_tests/.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: 'google-readability-braces-around-statements,google-readability-casting,google-readability-function-size,google-readability-namespace-comments,google-readability-todo,modernize-avoid-bind,modernize-avoid-c-arrays,modernize-concat-nested-namespaces,modernize-deprecated-headers,modernize-deprecated-ios-base-aliases,modernize-loop-convert,modernize-make-shared,modernize-make-unique,modernize-pass-by-value,modernize-raw-string-literal,modernize-redundant-void-arg,modernize-replace-auto-ptr,modernize-replace-random-shuffle,modernize-return-braced-init-list,modernize-shrink-to-fit,modernize-unary-static-assert,modernize-use-auto,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-emplace,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-noexcept,modernize-use-nullptr,modernize-use-override,modernize-use-transparent-functors,modernize-use-uncaught-exceptions,modernize-use-using,readability-avoid-const-params-in-decls,readability-braces-around-statements,readability-const-return-type,readability-container-size-empty,readability-deleted-default,readability-delete-null-pointer,readability-else-after-return,readability-function-size,readability-identifier-naming,readability-implicit-bool-conversion,readability-inconsistent-declaration-parameter-name,readability-isolate-declaration,readability-magic-numbers,readability-misleading-indentation,readability-misplaced-array-index,readability-named-parameter,readability-non-const-parameter,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-redundant-member-init,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-boolean-expr,readability-simplify-subscript-expr,readability-static-accessed-through-instance,readability-static-definition-in-anonymous-namespace,readability-string-compare,readability-uniqueptr-delete-release,readability-uppercase-literal-suffix' -------------------------------------------------------------------------------- /Catch_parsing_tests/.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: 'google-readability-braces-around-statements,google-readability-casting,google-readability-function-size,google-readability-namespace-comments,google-readability-todo,modernize-avoid-bind,modernize-avoid-c-arrays,modernize-concat-nested-namespaces,modernize-deprecated-headers,modernize-deprecated-ios-base-aliases,modernize-loop-convert,modernize-make-shared,modernize-make-unique,modernize-pass-by-value,modernize-raw-string-literal,modernize-redundant-void-arg,modernize-replace-auto-ptr,modernize-replace-random-shuffle,modernize-return-braced-init-list,modernize-shrink-to-fit,modernize-unary-static-assert,modernize-use-auto,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-emplace,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-noexcept,modernize-use-nullptr,modernize-use-override,modernize-use-transparent-functors,modernize-use-uncaught-exceptions,modernize-use-using,readability-avoid-const-params-in-decls,readability-braces-around-statements,readability-const-return-type,readability-container-size-empty,readability-deleted-default,readability-delete-null-pointer,readability-else-after-return,readability-function-size,readability-identifier-naming,readability-implicit-bool-conversion,readability-inconsistent-declaration-parameter-name,readability-isolate-declaration,readability-magic-numbers,readability-misleading-indentation,readability-misplaced-array-index,readability-named-parameter,readability-non-const-parameter,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-redundant-member-init,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-boolean-expr,readability-simplify-subscript-expr,readability-static-accessed-through-instance,readability-static-definition-in-anonymous-namespace,readability-string-compare,readability-uniqueptr-delete-release,readability-uppercase-literal-suffix' -------------------------------------------------------------------------------- /DataContainerGenerator/.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: 'google-readability-braces-around-statements,google-readability-casting,google-readability-function-size,google-readability-namespace-comments,google-readability-todo,modernize-avoid-bind,modernize-avoid-c-arrays,modernize-concat-nested-namespaces,modernize-deprecated-headers,modernize-deprecated-ios-base-aliases,modernize-loop-convert,modernize-make-shared,modernize-make-unique,modernize-pass-by-value,modernize-raw-string-literal,modernize-redundant-void-arg,modernize-replace-auto-ptr,modernize-replace-random-shuffle,modernize-return-braced-init-list,modernize-shrink-to-fit,modernize-unary-static-assert,modernize-use-auto,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-emplace,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-noexcept,modernize-use-nullptr,modernize-use-override,modernize-use-transparent-functors,modernize-use-uncaught-exceptions,modernize-use-using,readability-avoid-const-params-in-decls,readability-braces-around-statements,readability-const-return-type,readability-container-size-empty,readability-deleted-default,readability-delete-null-pointer,readability-else-after-return,readability-function-size,readability-identifier-naming,readability-implicit-bool-conversion,readability-inconsistent-declaration-parameter-name,readability-isolate-declaration,readability-magic-numbers,readability-misleading-indentation,readability-misplaced-array-index,readability-named-parameter,readability-non-const-parameter,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-redundant-member-init,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-boolean-expr,readability-simplify-subscript-expr,readability-static-accessed-through-instance,readability-static-definition-in-anonymous-namespace,readability-string-compare,readability-uniqueptr-delete-release,readability-uppercase-literal-suffix' -------------------------------------------------------------------------------- /DataContainerGenerator/DataContainerGenerator.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | -------------------------------------------------------------------------------- /Catch_color_tutorial_tests/color_container.cpp: -------------------------------------------------------------------------------- 1 | #include "color_container.hpp" 2 | 3 | void dcon::colored_thing_fat_id::set_red(float value) { 4 | get_color().red = value; 5 | } 6 | void dcon::colored_thing_fat_id::set_green(float value) { 7 | get_color().green = value; 8 | } 9 | void dcon::colored_thing_fat_id::set_blue(float value) { 10 | get_color().blue = value; 11 | } 12 | float dcon::colored_thing_const_fat_id::get_red() { 13 | return get_color().red; 14 | } 15 | float dcon::colored_thing_const_fat_id::get_green() { 16 | return get_color().green; 17 | } 18 | float dcon::colored_thing_const_fat_id::get_blue() { 19 | return get_color().blue; 20 | } 21 | 22 | void dcon::data_container::deserialize_rgb(std::byte const* start, std::byte const* end, load_record& record_in_out) { 23 | if(!record_in_out.colored_thing_color) { 24 | float const* found_red = nullptr; 25 | float const* found_green = nullptr; 26 | float const* found_blue = nullptr; 27 | uint32_t smallest_count = colored_thing_size(); 28 | 29 | for_each_record(start, end, 30 | [&](dcon::record_header const& header, std::byte const* data_start, std::byte const* data_end) { 31 | if(header.is_object("colored_thing") && header.is_type("float")) { 32 | if(header.is_property("red")) { 33 | found_red = reinterpret_cast(data_start); 34 | smallest_count = std::min(smallest_count, uint32_t((data_end - data_start) / sizeof(float))); 35 | } else if(header.is_property("green")) { 36 | found_green = reinterpret_cast(data_start); 37 | smallest_count = std::min(smallest_count, uint32_t((data_end - data_start) / sizeof(float))); 38 | } else if(header.is_property("blue")) { 39 | found_blue = reinterpret_cast(data_start); 40 | smallest_count = std::min(smallest_count, uint32_t((data_end - data_start) / sizeof(float))); 41 | } 42 | } 43 | }); 44 | if(found_red && found_green && found_blue) { 45 | for_each_colored_thing([&](auto id) { 46 | if(id.index() < int32_t(smallest_count)) { 47 | colored_thing_set_color(id, 48 | rgb_color{ found_red[id.index()], found_green[id.index()], found_blue[id.index()] 49 | }); 50 | } 51 | }); 52 | record_in_out.colored_thing_color = true; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Catch_objects_tests/objects_def.txt: -------------------------------------------------------------------------------- 1 | object{ 2 | name{thingy} 3 | storage_type{compactable} 4 | size{1200} 5 | 6 | hook{create} 7 | hook{delete} 8 | hook{move} 9 | 10 | property{ 11 | name{some_value} 12 | type{int32_t} 13 | } 14 | 15 | property{ 16 | name{bf_value} 17 | type{bitfield} 18 | } 19 | 20 | property{ 21 | name{d_value} 22 | type{derived{int32_t}} 23 | hook{get} 24 | } 25 | 26 | property{ 27 | name{dbf_value} 28 | type{derived{bitfield}} 29 | hook{set} 30 | } 31 | 32 | property{ 33 | name{obj_value} 34 | type{object{std::vector}} 35 | } 36 | 37 | property{ 38 | name{pooled_v} 39 | type{vector_pool{1000}{int16_t}} 40 | } 41 | 42 | property{ 43 | name{big_array} 44 | type{array{int32_t}{float}} 45 | } 46 | 47 | property{ 48 | name{big_array_alt} 49 | type{array{int32_t}{float}} 50 | } 51 | 52 | swappable{big_array}{big_array_alt} 53 | 54 | property{ 55 | name{big_array_bf} 56 | type{array{int32_t}{bitfield}} 57 | } 58 | } 59 | 60 | object{ 61 | name{thingy2} 62 | storage_type{compactable} 63 | size{expandable} 64 | 65 | property{ 66 | name{some_value} 67 | type{int32_t} 68 | } 69 | 70 | property{ 71 | name{bf_value} 72 | type{bitfield} 73 | } 74 | 75 | property{ 76 | name{d_value} 77 | type{derived{int32_t}} 78 | } 79 | 80 | property{ 81 | name{dbf_value} 82 | type{derived{bitfield}} 83 | } 84 | 85 | property{ 86 | name{obj_value} 87 | type{object{std::vector}} 88 | } 89 | 90 | property{ 91 | name{pooled_v} 92 | type{vector_pool{1000}{int16_t}} 93 | } 94 | 95 | property{ 96 | name{big_array} 97 | type{array{int32_t}{float}} 98 | } 99 | 100 | property{ 101 | name{big_array_bf} 102 | type{array{int32_t}{bitfield}} 103 | } 104 | } 105 | 106 | relationship{ 107 | name{dummy_rel} 108 | 109 | link{ 110 | object{thingy} 111 | name{left} 112 | type{unique} 113 | } 114 | link{ 115 | object{thingy2} 116 | name{right} 117 | type{unique} 118 | } 119 | } 120 | 121 | object{ 122 | name{oop_thingy} 123 | storage_type{compactable} 124 | size{1200} 125 | 126 | property{ 127 | protected 128 | name{pstruct} 129 | type{my_struct} 130 | } 131 | 132 | property{ 133 | private 134 | name{pfloat} 135 | type{float} 136 | } 137 | 138 | function{void @reset_internal()} 139 | const_function{int @get_a_value(float @offset)} 140 | } 141 | 142 | relationship{ 143 | name{dummy_rel_B} 144 | 145 | link{ 146 | object{oop_thingy} 147 | name{left} 148 | type{unique} 149 | } 150 | link{ 151 | object{oop_thingy} 152 | name{right} 153 | type{unique} 154 | } 155 | } 156 | 157 | global{int32_t counter = 0;} -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /CommonIncludes/CommonIncludes.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {0a7af04a-d655-48f4-8ba9-725074e16ef3} 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | Header Files 47 | 48 | 49 | 50 | 51 | docs 52 | 53 | 54 | docs 55 | 56 | 57 | docs 58 | 59 | 60 | docs 61 | 62 | 63 | docs 64 | 65 | 66 | docs 67 | 68 | 69 | docs 70 | 71 | 72 | docs 73 | 74 | 75 | docs 76 | 77 | 78 | docs 79 | 80 | 81 | docs 82 | 83 | 84 | docs 85 | 86 | 87 | docs 88 | 89 | 90 | docs 91 | 92 | 93 | 94 | 95 | docs 96 | 97 | 98 | 99 | 100 | Header Files 101 | 102 | 103 | -------------------------------------------------------------------------------- /Catch_query_tests/query_objs.txt: -------------------------------------------------------------------------------- 1 | 2 | object{ 3 | name{car} 4 | storage_type{contiguous} 5 | size{ 1200 } 6 | 7 | property{ 8 | name{wheels} 9 | type{int32_t} 10 | } 11 | property{ 12 | name{resale_value} 13 | type{float} 14 | } 15 | } 16 | 17 | object{ 18 | name{person} 19 | storage_type{contiguous} 20 | size{100} 21 | 22 | property{ 23 | name{age} 24 | type{int32_t} 25 | } 26 | 27 | property{ 28 | name{wealth} 29 | type{float} 30 | } 31 | } 32 | 33 | relationship{ 34 | name{car_ownership} 35 | 36 | link{ 37 | object{person} 38 | name{owner} 39 | type{many} 40 | index_storage{std_vector} 41 | } 42 | link{ 43 | object{car} 44 | name{owned_car} 45 | type{unique} 46 | } 47 | 48 | property{ 49 | name{ownership_date} 50 | type{int32_t} 51 | } 52 | } 53 | 54 | relationship { 55 | name{parentage} 56 | link{ 57 | object{person} 58 | name{child} 59 | type{unique} 60 | } 61 | link{ 62 | object{person} 63 | name{bio_parent} 64 | type{many} 65 | index_storage{array} 66 | multiple{2}{distinct} 67 | } 68 | } 69 | 70 | query{ 71 | name{q_all_owner_ages} 72 | parameters{} 73 | select{person.age, person.id from car join car_ownership join person} 74 | } 75 | 76 | query{ 77 | name{rev_car_from_owner} 78 | parameters{} 79 | select{car.resale_value as rv, car.id from person join car_ownership join car} 80 | } 81 | 82 | query{ 83 | name{param_car_from_owner} 84 | parameters{ 85 | from_person{person_id} 86 | } 87 | select{car.resale_value as rv, car.id from @from_person join car_ownership join car} 88 | } 89 | 90 | query{ 91 | name{q_all_owner_ages_plus} 92 | parameters{} 93 | select{person.age, person.id from car join+ car_ownership join+ person} 94 | } 95 | 96 | query{ 97 | name{rev_car_from_owner_plus} 98 | parameters{} 99 | select{car.resale_value as rv, car.id from person join+ car_ownership join car} 100 | } 101 | 102 | query{ 103 | name{grandparents} 104 | parameters{ 105 | from_person{person_id} 106 | } 107 | select{gp.id as grandparent, par.id as parent from @from_person join on child parentage, join on bio_parent person as par, 108 | join on child parentage, join on bio_parent person as gp} 109 | } 110 | 111 | query{ 112 | name{grandchildren} 113 | parameters{ 114 | from_person{person_id} 115 | age_filter{int32_t} 116 | } 117 | select{gch.id as grandchild, ch.id as child from @from_person join on bio_parent parentage, join on child person as ch, 118 | join on bio_parent parentage, join on child person as gch 119 | where @gch.age < @age_filter } 120 | } 121 | 122 | query{ 123 | name{group_grandchildren} 124 | parameters{ 125 | age_filter{int32_t} 126 | } 127 | select{base.id as grandparent, count(gch.id as count_gc), max(gch.age as max_age), gch.wealth 128 | from person as base join on bio_parent parentage, join on child person as ch, 129 | join on bio_parent parentage, join on child person as gch 130 | where @gch.age < @age_filter group base} 131 | } 132 | 133 | query{ 134 | name{sum_car_value} 135 | parameters{ 136 | from_person{person_id} 137 | } 138 | select{sum(car.resale_value as rv_sum) from @from_person join car_ownership join car group from_person} 139 | } 140 | 141 | query{ 142 | name{pairs_of_cars} 143 | select{person.id, car_a.id, car_b.id 144 | from person join car_ownership join car as car_a 145 | person.join car_ownership join car as car_b} 146 | } 147 | 148 | query{ 149 | name{siblings} 150 | parameters{ 151 | person_param{person_id} 152 | } 153 | select{base.id, sibling_a.id, sibling_b.id 154 | from @person_param as base, 155 | join on bio_parent parentage, join on child person as sibling_a, 156 | base.join on bio_parent parentage, join on child person as sibling_b 157 | where @sibling_a.id .index() < @sibling_b.id .index() } 158 | } 159 | 160 | -------------------------------------------------------------------------------- /lua_dll_build_test/lua_objs.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // 4 | // This file was automatically generated from: objs.txt 5 | // EDIT AT YOUR OWN RISK; all changes will be lost upon regeneration 6 | // NOT SUITABLE FOR USE IN CRITICAL SOFTWARE WHERE LIVES OR LIVELIHOODS DEPEND ON THE CORRECT OPERATION 7 | // 8 | 9 | #include 10 | using lua_reference_type = int32_t; 11 | #include "objs.hpp" 12 | #ifdef DCON_LUADLL_EXPORTS 13 | #define DCON_LUADLL_API __declspec(dllexport) 14 | #else 15 | #define DCON_LUADLL_API __declspec(dllimport) 16 | #endif 17 | 18 | extern DCON_LUADLL_API dcon::data_container state; 19 | 20 | extern "C" { 21 | DCON_LUADLL_API void dcon_set_release_object_function(void (*fn)(int32_t)); 22 | DCON_LUADLL_API bool dcon_thingy_is_valid(int32_t i); 23 | DCON_LUADLL_API uint32_t dcon_thingy_size(); 24 | DCON_LUADLL_API void dcon_thingy_resize(uint32_t sz); 25 | DCON_LUADLL_API int32_t dcon_thingy_get_some_value(int32_t i); 26 | DCON_LUADLL_API void dcon_thingy_set_some_value(int32_t i,int32_t v); 27 | DCON_LUADLL_API bool dcon_thingy_get_bf_value(int32_t i); 28 | DCON_LUADLL_API void dcon_thingy_set_bf_value(int32_t i, bool v); 29 | DCON_LUADLL_API lua_reference_type dcon_thingy_get_lua_value(int32_t i); 30 | DCON_LUADLL_API void dcon_thingy_set_lua_value(int32_t i,lua_reference_type v); 31 | DCON_LUADLL_API int16_t dcon_thingy_get_pooled_v(int32_t i, int32_t idx); 32 | DCON_LUADLL_API int32_t dcon_thingy_size_pooled_v(int32_t i); 33 | DCON_LUADLL_API void dcon_thingy_set_pooled_v(int32_t i, int32_t idx,int16_t v); 34 | DCON_LUADLL_API void dcon_thingy_resize_pooled_v(int32_t i, int32_t sz); 35 | DCON_LUADLL_API float dcon_thingy_get_big_array(int32_t i, int32_t idx); 36 | DCON_LUADLL_API void dcon_thingy_set_big_array(int32_t i, int32_t idx,float v); 37 | DCON_LUADLL_API uint32_t dcon_thingy_get_big_array_size(); 38 | DCON_LUADLL_API void dcon_thingy_resize_big_array(uint32_t sz); 39 | DCON_LUADLL_API bool dcon_thingy_get_big_array_bf(int32_t i, int32_t idx); 40 | DCON_LUADLL_API void dcon_thingy_set_big_array_bf(int32_t i, int32_t idx, bool v); 41 | DCON_LUADLL_API uint32_t dcon_thingy_get_big_array_bf_size(); 42 | DCON_LUADLL_API void dcon_thingy_resize_big_array_bf(uint32_t sz); 43 | DCON_LUADLL_API bool dcon_pop_is_valid(int32_t i); 44 | DCON_LUADLL_API uint32_t dcon_pop_size(); 45 | DCON_LUADLL_API void dcon_pop_resize(uint32_t sz); 46 | DCON_LUADLL_API int32_t dcon_pop_get_range_negotiation_as_initiator(int32_t i); 47 | DCON_LUADLL_API int32_t dcon_pop_get_index_negotiation_as_initiator(int32_t i, int32_t subindex); 48 | DCON_LUADLL_API int32_t dcon_pop_get_range_negotiation_as_target(int32_t i); 49 | DCON_LUADLL_API int32_t dcon_pop_get_index_negotiation_as_target(int32_t i, int32_t subindex); 50 | DCON_LUADLL_API bool dcon_negotiation_is_valid(int32_t i); 51 | DCON_LUADLL_API uint32_t dcon_negotiation_size(); 52 | DCON_LUADLL_API void dcon_negotiation_resize(uint32_t sz); 53 | DCON_LUADLL_API int32_t dcon_negotiation_get_initiator(int32_t i); 54 | DCON_LUADLL_API void dcon_negotiation_set_initiator(int32_t i, int32_t v); 55 | DCON_LUADLL_API void dcon_negotiation_try_set_initiator(int32_t i, int32_t v); 56 | DCON_LUADLL_API int32_t dcon_negotiation_get_target(int32_t i); 57 | DCON_LUADLL_API void dcon_negotiation_set_target(int32_t i, int32_t v); 58 | DCON_LUADLL_API void dcon_negotiation_try_set_target(int32_t i, int32_t v); 59 | DCON_LUADLL_API void dcon_pop_back_thingy(); 60 | DCON_LUADLL_API int32_t dcon_create_thingy(); 61 | DCON_LUADLL_API void dcon_delete_thingy(int32_t j); 62 | DCON_LUADLL_API void dcon_delete_pop(int32_t j); 63 | DCON_LUADLL_API int32_t dcon_create_pop(); 64 | DCON_LUADLL_API void dcon_delete_negotiation(int32_t j); 65 | DCON_LUADLL_API int32_t dcon_try_create_negotiation(int32_t p1, int32_t p2); 66 | DCON_LUADLL_API int32_t dcon_force_create_negotiation(int32_t p1, int32_t p2); 67 | DCON_LUADLL_API int32_t dcon_reset(); 68 | DCON_LUADLL_API void dcon_store_simple_write_file(char const* name); 69 | DCON_LUADLL_API void dcon_store_simple_read_file(char const* name); 70 | } 71 | -------------------------------------------------------------------------------- /Catch_ecs_tutorial_tests/Catch_ecs_tutorial_tests.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | 3 | #include "catch.hpp" 4 | #include "common_types.hpp" 5 | #include "ecs.hpp" 6 | #include "common_types.cpp" 7 | 8 | void dcon::data_container::on_delete_entity(entity_id e) { 9 | if (auto c = entity_get_position_component(e); bool(c)) { 10 | delete_position(c); 11 | } 12 | if (auto c = entity_get_sprite_component(e); bool(c)) { 13 | delete_sprite(c); 14 | } 15 | } 16 | 17 | dcon::entity_id make_entity(dcon::data_container& dc) { 18 | return dc.try_create_entity(dcon::position_id(), dcon::sprite_id()); 19 | } 20 | 21 | 22 | TEST_CASE("destructor test", "[ecs_tutorial_tests]") { 23 | auto ptr = std::make_unique(); 24 | 25 | auto e1 = make_entity(*ptr); 26 | auto e2 = make_entity(*ptr); 27 | auto e3 = make_entity(*ptr); 28 | auto e4 = make_entity(*ptr); 29 | 30 | REQUIRE(bool(e1)); 31 | REQUIRE(bool(e2)); 32 | REQUIRE(bool(e3)); 33 | REQUIRE(bool(e4)); 34 | 35 | auto p1 = ptr->create_position(); 36 | auto p2 = ptr->create_position(); 37 | ptr->entity_set_position_component(e1, p1); 38 | ptr->entity_set_position_component(e3, p2); 39 | auto s1 = ptr->create_sprite(); 40 | auto s2 = ptr->create_sprite(); 41 | ptr->entity_set_sprite_component(e3, s1); 42 | ptr->entity_set_sprite_component(e4, s2); 43 | 44 | REQUIRE(ptr->position_is_valid(p1)); 45 | REQUIRE(ptr->position_is_valid(p2)); 46 | REQUIRE(ptr->sprite_is_valid(s1)); 47 | REQUIRE(ptr->sprite_is_valid(s2)); 48 | 49 | REQUIRE(ptr->position_size() == 2); 50 | REQUIRE(ptr->sprite_size() == 2); 51 | 52 | ptr->delete_entity(e1); 53 | 54 | REQUIRE(!ptr->position_is_valid(p1)); 55 | REQUIRE(ptr->position_is_valid(p2)); 56 | 57 | ptr->delete_entity(e3); 58 | 59 | REQUIRE(!ptr->position_is_valid(p1)); 60 | REQUIRE(!ptr->position_is_valid(p2)); 61 | REQUIRE(!ptr->sprite_is_valid(s1)); 62 | REQUIRE(ptr->sprite_is_valid(s2)); 63 | 64 | ptr->delete_entity(e4); 65 | 66 | REQUIRE(!ptr->sprite_is_valid(s1)); 67 | REQUIRE(!ptr->sprite_is_valid(s2)); 68 | 69 | REQUIRE(ptr->position_size() == 0); 70 | REQUIRE(ptr->sprite_size() == 0); 71 | 72 | ptr->delete_entity(e2); 73 | 74 | REQUIRE(ptr->entity_size() == 0); 75 | } 76 | 77 | 78 | TEST_CASE("iteration test", "[ecs_tutorial_tests]") { 79 | auto ptr = std::make_unique(); 80 | 81 | auto e1 = make_entity(*ptr); 82 | auto e2 = make_entity(*ptr); 83 | auto e3 = make_entity(*ptr); 84 | auto e4 = make_entity(*ptr); 85 | 86 | auto p1 = ptr->create_position(); 87 | auto p2 = ptr->create_position(); 88 | auto p3 = ptr->create_position(); 89 | auto p4 = ptr->create_position(); 90 | 91 | auto s1 = ptr->create_sprite(); 92 | auto s2 = ptr->create_sprite(); 93 | auto s4 = ptr->create_sprite(); 94 | 95 | ptr->entity_set_position_component(e1, p1); 96 | ptr->entity_set_position_component(e2, p2); 97 | ptr->entity_set_position_component(e3, p3); 98 | ptr->entity_set_position_component(e4, p4); 99 | 100 | ptr->entity_set_sprite_component(e1, s1); 101 | ptr->entity_set_sprite_component(e2, s2); 102 | ptr->entity_set_sprite_component(e4, s4); 103 | 104 | ptr->position_set_x(p1, 1.0f); 105 | ptr->position_set_x(p2, 2.0f); 106 | ptr->position_set_x(p3, 3.0f); 107 | ptr->position_set_x(p4, 4.0f); 108 | 109 | ptr->sprite_set_sprite_id(s1, 1); 110 | ptr->sprite_set_sprite_id(s2, 2); 111 | ptr->sprite_set_sprite_id(s4, 1); 112 | 113 | int32_t count = 0; 114 | for (auto& q : ptr->query_sprites_with_position()) { 115 | ++count; 116 | if (q.get_position().get_x() == 1.0f) 117 | REQUIRE(q.get_sprite().get_sprite_id() == uint16_t(1)); 118 | if (q.get_position().get_x() == 2.0f) 119 | REQUIRE(q.get_sprite().get_sprite_id() == uint16_t(2)); 120 | if (q.get_position().get_x() == 3.0f) 121 | REQUIRE(q.get_sprite().get_sprite_id() == uint16_t(4)); // impossible 122 | if (q.get_position().get_x() == 4.0f) 123 | REQUIRE(q.get_sprite().get_sprite_id() == uint16_t(1)); 124 | } 125 | REQUIRE(count == 3); 126 | 127 | } 128 | -------------------------------------------------------------------------------- /Catch_color_tutorial_tests/Catch_color_tutorial_tests.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | 3 | #include "catch.hpp" 4 | #include "common_types.hpp" 5 | #include "color_container.hpp" 6 | #include "color_tutorial.hpp" 7 | #include "old_color_container.hpp" 8 | #include "common_types.cpp" 9 | 10 | TEST_CASE("test basic access", "[tutorial_tests]") { 11 | auto ptr = std::make_unique< dcon::data_container >(); 12 | 13 | ptr->create_colored_thing(); 14 | ptr->create_colored_thing(); 15 | auto h = fatten(*ptr, ptr->create_colored_thing()); 16 | ptr->create_colored_thing(); 17 | 18 | h.set_blue(5.0f); 19 | REQUIRE(h.get_blue() == 5.0f); 20 | REQUIRE(h.get_color().blue == 5.0f); 21 | } 22 | 23 | TEST_CASE("test deserialize", "[tutorial_tests]") { 24 | 25 | std::byte* bptr; 26 | size_t sz = 0; 27 | 28 | auto ptr = std::make_unique< old::data_container >(); 29 | ptr->create_colored_thing(); 30 | auto id = fatten(*ptr, ptr->create_colored_thing()); 31 | id.set_blue(2.0f); 32 | id.set_green(3.0f); 33 | id.set_red(4.0f); 34 | 35 | sz = ptr->serialize_size(ptr->serialize_entire_container_record()); 36 | bptr = new std::byte[sz]; 37 | { 38 | auto iptr = bptr; 39 | ptr->serialize(iptr, ptr->serialize_entire_container_record()); 40 | REQUIRE(iptr == bptr + sz); 41 | } 42 | 43 | 44 | auto ptrb = std::make_unique< dcon::data_container >(); 45 | 46 | { 47 | dcon::load_record record; 48 | std::byte const* iptr = bptr; 49 | ptrb->deserialize(iptr, bptr + sz, record); 50 | ptrb->deserialize_rgb(bptr, bptr + sz, record); 51 | 52 | REQUIRE(record.colored_thing_color); 53 | 54 | REQUIRE(fatten(*ptrb, dcon::colored_thing_id(1)).get_blue() == 2.0f); 55 | REQUIRE(fatten(*ptrb, dcon::colored_thing_id(1)).get_green() == 3.0f); 56 | REQUIRE(fatten(*ptrb, dcon::colored_thing_id(1)).get_red() == 4.0f); 57 | } 58 | 59 | delete[] bptr; 60 | } 61 | 62 | TEST_CASE("test SIMD", "[tutorial_tests]") { 63 | { 64 | auto ptr = std::make_unique< dcon::data_container >(); 65 | 66 | { 67 | auto h = fatten(*ptr, ptr->create_colored_thing()); 68 | h.set_red(1.0f); 69 | h.set_green(3.0f); 70 | } 71 | { 72 | auto h = fatten(*ptr, ptr->create_colored_thing()); 73 | h.set_red(7.0f); 74 | h.set_green(1.0f); 75 | } 76 | { 77 | auto h = fatten(*ptr, ptr->create_colored_thing()); 78 | h.set_red(1.0f); 79 | h.set_green(2.0f); 80 | } 81 | 82 | ptr->create_colored_thing(); 83 | 84 | ptr->execute_serial_over_colored_thing([p = ptr.get()](auto position){ 85 | auto red_value = ve::apply( 86 | [p](dcon::colored_thing_id i) { return p->colored_thing_get_color(i).red; }, 87 | position); 88 | auto green_value = ve::apply( 89 | [p](dcon::colored_thing_id i) { return p->colored_thing_get_color(i).green; }, 90 | position); 91 | ve::apply( 92 | [p](dcon::colored_thing_id i, float v) { p->colored_thing_get_color(i).blue = v; }, 93 | position, (red_value + green_value) / 2.0f); 94 | }); 95 | 96 | REQUIRE(ptr->colored_thing_get_color(dcon::colored_thing_id(0)).blue == 2.0f); 97 | REQUIRE(ptr->colored_thing_get_color(dcon::colored_thing_id(1)).blue == 4.0f); 98 | REQUIRE(ptr->colored_thing_get_color(dcon::colored_thing_id(2)).blue == 1.5f); 99 | } 100 | { 101 | auto ptr = std::make_unique< old::data_container >(); 102 | 103 | { 104 | auto h = fatten(*ptr, ptr->create_colored_thing()); 105 | h.set_red(1.0f); 106 | h.set_green(3.0f); 107 | } 108 | { 109 | auto h = fatten(*ptr, ptr->create_colored_thing()); 110 | h.set_red(7.0f); 111 | h.set_green(1.0f); 112 | } 113 | { 114 | auto h = fatten(*ptr, ptr->create_colored_thing()); 115 | h.set_red(1.0f); 116 | h.set_green(2.0f); 117 | } 118 | 119 | ptr->create_colored_thing(); 120 | 121 | ptr->execute_serial_over_colored_thing([p = ptr.get()](auto position){ 122 | p->colored_thing_set_blue(position, 123 | (p->colored_thing_get_red(position) + p->colored_thing_get_green(position)) / 2.0f); 124 | }); 125 | 126 | REQUIRE(ptr->colored_thing_get_blue(old::colored_thing_id(0)) == 2.0f); 127 | REQUIRE(ptr->colored_thing_get_blue(old::colored_thing_id(1)) == 4.0f); 128 | REQUIRE(ptr->colored_thing_get_blue(old::colored_thing_id(2)) == 1.5f); 129 | } 130 | } -------------------------------------------------------------------------------- /Catch_relationships_tests/relation.txt: -------------------------------------------------------------------------------- 1 | object { 2 | name { pop } 3 | storage_type { erasable } 4 | size { 1 } 5 | tag {scenario} 6 | } 7 | 8 | relationship { 9 | name { employment } 10 | storage_type { erasable } 11 | size { 1 } 12 | tag {scenario} 13 | link { 14 | object { pop } 15 | name { worker } 16 | type { unique } 17 | } 18 | property{ 19 | name { job } 20 | type { job_id } 21 | tag { scenario } 22 | } 23 | } 24 | object { 25 | name { job } 26 | storage_type { contiguous } 27 | size { 1 } 28 | tag {scenario} 29 | } 30 | 31 | object{ 32 | name{thingyA} 33 | storage_type{compactable} 34 | size{1200} 35 | 36 | property{ 37 | name{some_value} 38 | type{int32_t} 39 | } 40 | } 41 | 42 | object{ 43 | name{thingyB} 44 | storage_type{erasable} 45 | size{1200} 46 | 47 | property{ 48 | name{some_value} 49 | type{int32_t} 50 | } 51 | } 52 | 53 | relationship{ 54 | name{relate_same} 55 | 56 | link{ 57 | object{thingyA} 58 | name{left} 59 | type{unique} 60 | } 61 | link{ 62 | object{thingyA} 63 | name{right} 64 | type{unindexed} 65 | } 66 | 67 | composite_key{ 68 | name{joint} 69 | index{left} 70 | index{right} 71 | } 72 | } 73 | 74 | relationship{ 75 | name{relate_in_array} 76 | 77 | link{ 78 | object{thingyA} 79 | name{left} 80 | type{unique} 81 | } 82 | link{ 83 | object{thingyB} 84 | name{right} 85 | type{many} 86 | index_storage{array} 87 | } 88 | } 89 | relationship{ 90 | name{relate_in_list} 91 | 92 | link{ 93 | object{thingyA} 94 | name{left} 95 | type{unique} 96 | } 97 | link{ 98 | object{thingyB} 99 | name{right} 100 | type{many} 101 | index_storage{list} 102 | } 103 | } 104 | 105 | relationship{ 106 | name{many_many} 107 | 108 | storage_type{erasable} 109 | size{200} 110 | 111 | link{ 112 | object{thingyA} 113 | name{A} 114 | type{unindexed} 115 | } 116 | link{ 117 | object{thingyA} 118 | name{B} 119 | type{unindexed} 120 | } 121 | link{ 122 | object{thingyA} 123 | name{C} 124 | type{unindexed} 125 | } 126 | link{ 127 | object{thingyA} 128 | name{D} 129 | type{unindexed} 130 | } 131 | link{ 132 | object{thingyA} 133 | name{E} 134 | type{unindexed} 135 | } 136 | link{ 137 | object{thingyA} 138 | name{F} 139 | type{unindexed} 140 | } 141 | link{ 142 | object{thingyA} 143 | name{ignore} 144 | type{unindexed} 145 | } 146 | 147 | 148 | composite_key{ 149 | name{joint} 150 | index{A} 151 | index{B} 152 | index{C} 153 | index{D} 154 | index{E} 155 | index{F} 156 | } 157 | } 158 | 159 | 160 | relationship{ 161 | name{relate_as_optional} 162 | storage_type{erasable} 163 | size{400} 164 | 165 | link{ 166 | object{thingyA} 167 | name{left} 168 | type{many} 169 | index_storage{array} 170 | } 171 | link{ 172 | object{thingyB} 173 | name{right} 174 | type{many}{optional} 175 | index_storage{array} 176 | } 177 | } 178 | 179 | relationship{ 180 | name{relate_as_non_optional} 181 | storage_type{erasable} 182 | size{400} 183 | 184 | link{ 185 | object{thingyA} 186 | name{left} 187 | type{many} 188 | index_storage{array} 189 | } 190 | link{ 191 | object{thingyB} 192 | name{right} 193 | type{many} 194 | index_storage{array} 195 | } 196 | } 197 | 198 | relationship{ 199 | name{relate_as_multipleA} 200 | storage_type{erasable} 201 | size{400} 202 | 203 | link{ 204 | object{thingyA} 205 | name{left} 206 | type{many} 207 | index_storage{array} 208 | multiple{2} 209 | } 210 | 211 | composite_key{ 212 | name{joint} 213 | index{left} 214 | } 215 | } 216 | 217 | relationship{ 218 | name{relate_as_multipleB} 219 | storage_type{erasable} 220 | size{400} 221 | 222 | link{ 223 | object{thingyA} 224 | name{left} 225 | type{unique} 226 | multiple{2}{distinct} 227 | } 228 | } 229 | 230 | relationship{ 231 | name{relate_as_multipleC} 232 | storage_type{erasable} 233 | size{400} 234 | 235 | link{ 236 | object{thingyA} 237 | name{left} 238 | type{many} 239 | index_storage{array} 240 | multiple{2}{distinct} 241 | } 242 | } 243 | 244 | relationship{ 245 | name{relate_as_multipleD} 246 | storage_type{erasable} 247 | size{400} 248 | 249 | link{ 250 | object{thingyA} 251 | name{left} 252 | type{unindexed} 253 | multiple{2} 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /getting_started.md: -------------------------------------------------------------------------------- 1 | # Getting started 2 | 3 | ## Building the generator 4 | 5 | To use the DataContainer project, the first thing you have to do is build the generator which turns the text file that determines what the data container will hold into the C++ header file that implements it. In Visual Studio you can do this by building the DataContainerGenerator sub-project (either in release or debug). If you aren't using Visual Studio, building the project is still easy: throw the `.cpp` and `.hpp` files from the DataContainerGenerator directory together and build them in whatever way you prefer; there are no dependencies except the standard library and no requirements except C++17 support. 6 | 7 | ## Running the generator 8 | 9 | Once you have compiled the generator and written a specification file describing your data container, it is time to figure out how to turn that file into a C++ header. In Visual Studio you can do this with a custom build tool. First, right click on the project within your solution that you want to generate the data container for and select `Add > Existing Item` to add the text file that you have written. Then, right click on the text file to view its properties. First find the `Item Type` property and change its value from `Text` to `Custom Build Tool`. After hitting apply, you should see new properties appear (under `Custom Build Tool > General` on the left). Change the `Command Line` setting to `𝘸𝘩𝘦𝘳𝘦 𝘺𝘰𝘶 𝘣𝘶𝘪𝘭𝘵 𝘵𝘩𝘦 𝘨𝘦𝘯𝘦𝘳𝘢𝘵𝘰𝘳\DataContainerGenerator 𝘺𝘰𝘶𝘳 𝘧𝘪𝘭𝘦 𝘯𝘢𝘮𝘦.txt`. Change the `Outputs` property to `𝘺𝘰𝘶𝘳 𝘧𝘪𝘭𝘦 𝘯𝘢𝘮𝘦.hpp`, and change `Add Outputs to Item Type` to `C/C++ header`. Don't forget to set these properties for *both* the debug and release configurations. Finally, right click on the specification file again and select `Compile` to make sure that you have done everything correctly. If you have, you can use `Add > Existing Item` again to make the generated header file part of the project. 10 | 11 | If you are using CMake ... I don't use CMake myself, but my understanding is that you can use [add_custom_command](https://cmake.org/cmake/help/latest/command/add_custom_command.html) to run the generator. 12 | 13 | For Meson ... probably [custom_target](https://mesonbuild.com/Reference-manual_functions.html#custom_target) will do the trick. 14 | 15 | If you use either CMake or Meson, please feel free to contribute detailed instructions for them. 16 | 17 | ## What to include 18 | 19 | Once you have generated the header file for your data container, there are a few final things you need to do before you can successfully compile and use it. First, you will need to include the `common_types.hpp` file in your project (found in the CommonIncludes directory). Second, you will need `ve.hpp` and the other `ve_....hpp` header files, as described in [the documentation for using the ve library](ve_documentation.md). If you don't want to use the ve library, simply define `DCON_NO_VE` before including either the generated file or `common_types.hpp`. Finally, if you have declared one or more composite keys, (see [composite keys](relationships.md#composite-keys)) you will need to include the `unordered_dense.h` file from CommonIncludes in your project. This is a copy, provided for the sake of convenience, of the hash map header from [Martin Leitner-Ankerl's unordered_dense project](https://github.com/martinus/unordered_dense), and you may want to go directly to the source for a more up-to-date version. These files are all simple enough that I suggest just making copies of them and dropping them into your project directly, rather than trying to depend on DataContainer in some way (and I don't support that approach anyways). 20 | 21 | Also, don't forget to define `NDEBUG` for your release versions, which not only turns off the standard C asserts, but will also direct the compiler to force inline the trivial functions (the intent is to help the compiler see through them). 22 | 23 | ## Compiler support 24 | 25 | The generated data container files require at least C++17 support to use, and are intended to work for msvc, clang, and gcc (there are a few compiler extensions used). I test almost exclusively with msvc, so if you encounter issues elsewhere, please let me know. In particular, the alignment of the data_container class is defined to be larger than the standard types. `new` in C++17 and later, as well as `std::make_unique` and `std::make_shared`, should support this over-alignment, but you may want to double check to make sure that the requested alignment is being respected. 26 | -------------------------------------------------------------------------------- /LuaDLLGenerator/source_builder.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class raw_lines { 10 | public: 11 | std::vector lines; 12 | 13 | raw_lines& operator+(char const* l) { 14 | lines.push_back(l); 15 | return *this; 16 | } 17 | }; 18 | 19 | class substitute { 20 | public: 21 | std::string sub_key; 22 | std::string sub_text; 23 | 24 | substitute(char const* key, std::string text) : sub_key(key), sub_text(text) { 25 | 26 | } 27 | }; 28 | 29 | struct append { 30 | char const* value; 31 | }; 32 | 33 | struct trailing_semicolon {}; 34 | 35 | struct line_break {}; 36 | 37 | struct heading { 38 | char const* str; 39 | }; 40 | 41 | class basic_builder; 42 | 43 | struct trailing_semicolon_state { 44 | basic_builder& ref; 45 | 46 | template 47 | auto operator+(T&& func)->std::enable_if_t, basic_builder&>; 48 | }; 49 | 50 | class basic_builder { 51 | public: 52 | std::vector substitutes; 53 | std::vector lines; 54 | int32_t extra_tabs = 0; 55 | bool declaration_mode = false; 56 | 57 | basic_builder& operator+(substitute const& sub) & { 58 | for(auto& s : substitutes) { 59 | if(s.sub_key == sub.sub_key) { 60 | s.sub_text = sub.sub_text; 61 | return *this; 62 | } 63 | } 64 | substitutes.push_back(sub); 65 | return *this; 66 | } 67 | basic_builder& operator+(char const* line) & { 68 | add_line(line); 69 | return *this; 70 | } 71 | basic_builder& operator+(append const& a) & { 72 | if(lines.size() > 0) 73 | lines.back() += (std::string(" ") + a.value); 74 | else 75 | add_line(std::string(" ") + a.value); 76 | return *this; 77 | } 78 | basic_builder& operator+(std::string const& line) & { 79 | add_line(line); 80 | return *this; 81 | } 82 | trailing_semicolon_state operator+(trailing_semicolon const&) { 83 | return trailing_semicolon_state{ *this }; 84 | } 85 | basic_builder& operator+(line_break const&) { 86 | lines.push_back(std::string(extra_tabs, '\t')); 87 | return *this; 88 | } 89 | 90 | basic_builder& operator+(heading const& h) { 91 | lines.push_back(std::string(extra_tabs, '\t') + "//"); 92 | add_line(std::string(extra_tabs, '\t') + "// " + h.str); 93 | lines.push_back(std::string(extra_tabs, '\t') + "//"); 94 | return *this; 95 | } 96 | template 97 | auto operator+(T&& func) ->std::enable_if_t, basic_builder&> { 98 | if(!declaration_mode) { 99 | if(lines.size() > 0) 100 | lines.back() += " {"; 101 | else 102 | add_line("{"); 103 | 104 | ++extra_tabs; 105 | func(*this); 106 | --extra_tabs; 107 | 108 | add_line("}"); 109 | } else if(lines.size() > 0) { 110 | lines.back() += ';'; 111 | } 112 | return *this; 113 | } 114 | void add_line(std::string const& line) { 115 | std::string built_string; 116 | bool in_sub_name = false; 117 | for(size_t pos = 0; pos < line.length(); ) { 118 | size_t end_pos = line.find('@', pos); 119 | if(end_pos > line.length()) { 120 | end_pos = line.length(); 121 | } 122 | 123 | std::string segment = line.substr(pos, end_pos - pos); 124 | 125 | if(in_sub_name) { 126 | bool found = false; 127 | for(auto s : substitutes) { 128 | if(s.sub_key == segment) { 129 | built_string += s.sub_text; 130 | found = true; 131 | } 132 | } 133 | if(!found) { 134 | built_string += (std::string("$") + segment + "$"); 135 | } 136 | } else { 137 | built_string += segment; 138 | } 139 | in_sub_name = !in_sub_name; 140 | pos = end_pos + 1; 141 | } 142 | 143 | lines.push_back(std::string(extra_tabs, '\t') + built_string); 144 | } 145 | [[nodiscard]] std::string to_string(int tab_level) { 146 | std::string output; 147 | std::string tabs = std::string(tab_level, '\t'); 148 | 149 | for(auto& l : lines) { 150 | output += (tabs + l + "\n"); 151 | } 152 | 153 | extra_tabs = 0; 154 | lines.clear(); 155 | substitutes.clear(); 156 | declaration_mode = false; 157 | 158 | return output; 159 | } 160 | }; 161 | 162 | template 163 | auto trailing_semicolon_state::operator+(T&& func)->std::enable_if_t, basic_builder&> { 164 | ref + func; 165 | if(!ref.declaration_mode && ref.lines.size() > 0) { 166 | ref.lines.back() += ';'; 167 | } 168 | return ref; 169 | } 170 | 171 | #define block [&](basic_builder& o) 172 | #define class_block trailing_semicolon{} + [&](basic_builder& o) 173 | #define inline_block line_break{} + [&](basic_builder& o) 174 | 175 | 176 | -------------------------------------------------------------------------------- /DataContainerGenerator/source_builder.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class raw_lines { 10 | public: 11 | std::vector lines; 12 | 13 | raw_lines& operator+(char const* l) { 14 | lines.push_back(l); 15 | return *this; 16 | } 17 | }; 18 | 19 | class substitute { 20 | public: 21 | std::string sub_key; 22 | std::string sub_text; 23 | 24 | substitute(char const* key, std::string text) : sub_key(key), sub_text(text) { 25 | 26 | } 27 | }; 28 | 29 | struct append { 30 | char const* value; 31 | }; 32 | 33 | struct trailing_semicolon {}; 34 | 35 | struct line_break {}; 36 | 37 | struct heading { 38 | char const* str; 39 | }; 40 | 41 | class basic_builder; 42 | 43 | struct trailing_semicolon_state { 44 | basic_builder& ref; 45 | 46 | template 47 | auto operator+(T&& func)->std::enable_if_t, basic_builder&>; 48 | }; 49 | 50 | class basic_builder { 51 | public: 52 | std::vector substitutes; 53 | std::vector lines; 54 | int32_t extra_tabs = 0; 55 | bool declaration_mode = false; 56 | 57 | basic_builder& operator+(substitute const& sub) & { 58 | for(auto& s : substitutes) { 59 | if(s.sub_key == sub.sub_key) { 60 | s.sub_text = sub.sub_text; 61 | return *this; 62 | } 63 | } 64 | substitutes.push_back(sub); 65 | return *this; 66 | } 67 | basic_builder& operator+(char const* line) & { 68 | add_line(line); 69 | return *this; 70 | } 71 | basic_builder& operator+(append const& a) & { 72 | if(lines.size() > 0) 73 | lines.back() += (std::string(" ") + a.value); 74 | else 75 | add_line(std::string(" ") + a.value); 76 | return *this; 77 | } 78 | basic_builder& operator+(std::string const& line) & { 79 | add_line(line); 80 | return *this; 81 | } 82 | trailing_semicolon_state operator+(trailing_semicolon const&) { 83 | return trailing_semicolon_state{ *this }; 84 | } 85 | basic_builder& operator+(line_break const&) { 86 | lines.push_back(std::string(extra_tabs, '\t')); 87 | return *this; 88 | } 89 | 90 | basic_builder& operator+(heading const& h) { 91 | lines.push_back(std::string(extra_tabs, '\t') + "//"); 92 | add_line(std::string(extra_tabs, '\t') + "// " + h.str); 93 | lines.push_back(std::string(extra_tabs, '\t') + "//"); 94 | return *this; 95 | } 96 | template 97 | auto operator+(T&& func) ->std::enable_if_t, basic_builder&> { 98 | if(!declaration_mode) { 99 | if(lines.size() > 0) 100 | lines.back() += " {"; 101 | else 102 | add_line("{"); 103 | 104 | ++extra_tabs; 105 | func(*this); 106 | --extra_tabs; 107 | 108 | add_line("}"); 109 | } else if(lines.size() > 0) { 110 | lines.back() += ';'; 111 | } 112 | return *this; 113 | } 114 | void add_line(std::string const& line) { 115 | std::string built_string; 116 | bool in_sub_name = false; 117 | for(size_t pos = 0; pos < line.length(); ) { 118 | size_t end_pos = line.find('@', pos); 119 | if(end_pos > line.length()) { 120 | end_pos = line.length(); 121 | } 122 | 123 | std::string segment = line.substr(pos, end_pos - pos); 124 | 125 | if(in_sub_name) { 126 | bool found = false; 127 | for(auto s : substitutes) { 128 | if(s.sub_key == segment) { 129 | built_string += s.sub_text; 130 | found = true; 131 | } 132 | } 133 | if(!found) { 134 | built_string += (std::string("$") + segment + "$"); 135 | } 136 | } else { 137 | built_string += segment; 138 | } 139 | in_sub_name = !in_sub_name; 140 | pos = end_pos + 1; 141 | } 142 | 143 | lines.push_back(std::string(extra_tabs, '\t') + built_string); 144 | } 145 | [[nodiscard]] std::string to_string(int tab_level) { 146 | std::string output; 147 | std::string tabs = std::string(tab_level, '\t'); 148 | 149 | for(auto& l : lines) { 150 | output += (tabs + l + "\n"); 151 | } 152 | 153 | extra_tabs = 0; 154 | lines.clear(); 155 | substitutes.clear(); 156 | declaration_mode = false; 157 | 158 | return output; 159 | } 160 | }; 161 | 162 | template 163 | auto trailing_semicolon_state::operator+(T&& func)->std::enable_if_t, basic_builder&> { 164 | ref + func; 165 | if(!ref.declaration_mode && ref.lines.size() > 0) { 166 | ref.lines.back() += ';'; 167 | } 168 | return ref; 169 | } 170 | 171 | #define block [&](basic_builder& o) 172 | #define class_block trailing_semicolon{} + [&](basic_builder& o) 173 | #define inline_block line_break{} + [&](basic_builder& o) 174 | 175 | 176 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DataContainer 2 | 3 | "More than an ECS, less than a database" 4 | 5 | ## What is it? 6 | 7 | The DataContainer project contains a code generation tool (DataContainerGenerator) that turns text specifications describing objects and their relationships into a C++ header files defining a `data_container` class that manages the described objects and relationships. 8 | 9 | ## Why does this exist? 10 | 11 | Since that sounds a lot like what structs and classes in a C++ header file already are, why would anyone want to go through the extra trouble required to use a code generator? The generated data container is intended to solve the following problems: 12 | 13 | - Values stored in standard C++ objects end up scattered in memory in a way that is relatively unfriendly to SIMD operations. The standard C++ solution is, on paper, to use a "struct of arrays" rather than an "array of structs", but actually doing this can be quite cumbersome. The generated data container, however, automatically stores values for the same property in contiguous memory and exposes a user-friendly SIMD interface to them. 14 | - Managing relationships between objects involves both repetitive boilerplate and is a common source of bugs. The code required to manage the relationships is also often hard to make changes to without significant effort.[^1] The generated data container helps solve this problem by automatically generating the code required to keep relationships up to date as objects are created and deleted, and automatically maintains any indexes you require for quickly finding an object based on a given relationship, or vice versa. 15 | - Serializing and deserializing C++ objects is a pain in the neck. It is easy enough to dump their contents out to a file, but anything non trivial requires more than that. You may want the ability to selectively save some of an object's properties and not others when it is possible to recalculate that information without saving it directly. And you almost certainly want the ability to load serialized data created by old versions of your software, even after member variables have been added, removed, or changed type. Because the generator has a description of your objects and relationships that it can understand as a whole, it can provide you with robust serialization and deserialization routines without any additional effort on your part. 16 | - And yes, there are existing libraries for doing all of the above things (often quite good ones). However, the problems discussed above are all fundamentally about storing and managing the data that is structured into objects and relationships. Thus, using a library to solve one of these problems may very well make it harder to use a library to solve another of them.[^2] And so the approach of this project is to try to solve them all in one go, and thus to be able to hide the sometimes ugly details from the end user completely. 17 | - OK, but why a code generator? Some early iterations of these ideas were implemented with dark template magics, but doing so made compilation significantly slower. So while it is harder to initially integrate a code generator into your project, I think that ultimately it is the more user-friendly solution. 18 | 19 | ## Disclaimer 20 | 21 | Every effort will be made to find and eliminate bugs, and to keep them eliminated with tests. However, at this stage there are insufficient tests, and insufficient usage experience, to reasonably expect the generated files to be 100% bug free. DO NOT USE A GENERATED DATA CONTAINER IN SOFTWARE WHERE LIVES OR LIVELIHOODS MAY DEPEND ON THE CORRECT OPERATION. 22 | 23 | ## Documentation 24 | 25 | The following documentation explains all you need to know about how to generate and use data containers. 26 | 27 | - [Getting started](getting_started.md) 28 | - [Overview](overview.md) 29 | - [Objects and properties](objects_and_properties.md) 30 | - [Relationships](relationships.md) 31 | - [Queries](queries.md) 32 | - [Serialization and deserialization](serialization.md) 33 | - [Multithreading](multithreading.md) 34 | - [The ve SIMD library](ve_documentation.md) 35 | - [File format](file_format_documentation.md) 36 | 37 | ## Examples and Tutorials 38 | 39 | - [Tutorial: integrating a color struct](tutorial_color.md) 40 | - [Tutorial: making a data container act like an ECS](tutorial_ecs.md) 41 | 42 | ## Other 43 | 44 | - [Change log](changes.md) 45 | 46 | ## Feedback 47 | 48 | Feel free to leave comments and suggestions as you see fit. If you are actively using, or intend to use, a data container generated by this project, I will try to prioritize any fixes or features that you need. Otherwise, additions will be mostly driven by my own needs. 49 | 50 | [^1]: This is the primary reason that this version the idea exists (as an improvement to a previous version that generated containers for each logical object individually); managing the code required to keep the relationships working correctly, and to make sure that they serialized and deserialized correctly, was tedious and error prone in a way that made me unwilling to make changes at all. 51 | 52 | [^2]: For example, a robust serialization library is typically built using techniques that emulate compile-time reflection on C++ classes and structs. This tends to be hard to integrate with the techniques you might use to generate SIMD-friendly memory layouts. -------------------------------------------------------------------------------- /multithreading.md: -------------------------------------------------------------------------------- 1 | # Multithreading 2 | 3 | ## Perspective 4 | 5 | The general perspective towards multithreading that this section is written with is the following: Accessing data is "safe" if it won't crash the program and any value you read is either the value resulting from default construction or a value that was assigned to a value of the same logical type (i.e. to that same property) at some other point. For example, you will never get a `NaN` from a floating point value unless you have written a `NaN` into some floating point value of that type at some point in time. These values are not, however, guaranteed to be correct, so you should also perform validation if you read values in a context where another thread might be writing them. 6 | 7 | Safe in this context does *not* mean free of undefined behavior. Reading while writing may involve data races. Safe only means that I expect it to work on the target platform (x86_64). 8 | 9 | ## Safe operations 10 | 11 | If an object or relationship is *not* defined as having an `expandable` size, then any operation that reads data from the data container is designed to be safe, as described above. This includes operations that may require reading multiple values internally, such as iterating over all of the relationship instances linked to an object instance. You may not, however, assume that the results of such operations are correct or logically consistent. Concurrent modifications could easily result in not seeing some relationship instances during such an iteration (even if they are not removed by any concurrent modifications) or seeing a relationship instance more than once. This safety extends to reading the contents of a property of the `vector_pool` type. It does not, however, extend to properties with type `object` unless those objects make their own compatible safety guarantees. An exception to this rule is looking up relationship instances with a composite key; doing so is not safe if any relationship instances of that type may be concurrently added or removed. 12 | 13 | Assuming I haven't overlooked something, all of the functions that can be accessed through a `const` reference or pointer to a data container will be safe in this way (with the exception of accessing `object` type properties, for which getters are provided because access *might* be safe, but only the user can know for sure). 14 | 15 | ## Probably bad ideas 16 | 17 | Trying to write values to the same location from two different threads at the same time is probably a bad idea, for all of the normal reasons. Trying to change the object instances linked in two different relationship instances but in the same type of link is possible *if* they are not involved in a composite key and if neither any of the new object instances nor old object instances overlap. Since there are so many ways this can go wrong, you are strongly advised not to attempt it. Modifying two different `vector_pool` values that are fundamentally backed by the same memory pool *should* be safe (the memory pool uses lock-free techniques to make modification safe), but since it is so easy to make mistakes when implementing such things, I can only say that I *hope* it works properly. And, as already mentioned, looking up relationship instances with a composite key requires knowing that no other thread is adding or removing relationship instances of that type. 18 | 19 | ## Definitely bad ideas 20 | 21 | Adding or deleting object instances or relationship instances from two or more threads at the same time is definitely a bad idea, that will almost certainly leave the data container in an inconsistent state. Accessing any data for properties/links in a relationship or object instance with size `expandable` while an instance may be created in another thread is also forbidden. Finally, accessing data from a property with type `array` while that array is being resized from another thread is also an error. Since deserializing information into a data container can do any or all of the things mentioned above, it is probably best to prevent even concurrent reads while deserialization is occurring[^1]. 22 | 23 | ## Expected usage pattern 24 | 25 | The data container is designed for the following multithreading usage pattern: any definitely unsafe operations (such as resizing type `array` properties) is done in a special, single-threaded initialization phase. Subsequently there may be any number of threads reading data from it (ideally through `const` references/pointers), while the "probably bad ideas" and all creation/deletion of object/relationship instances will all be confined to a single thread. Modifying multiple values for the same logical property will only be done from multiple threads simultaneously when the threads can be given disjoint ranges of object/relationship instances to modify to ensure that they make no attempt to write to the same values at the same time. (This pattern, of course, means that no objects or relationships can have size `expandable`) 26 | 27 | [^1]: Doing that may be one of the few situations in which a shared pointer works well. Access to the data container can be gated though making a copy of the shared pointer (ideally once for a substantial usage of that pointer, not once per accessing every function). Then data can be deserialized into a new instance of the data container which can simply replace the old one in the shared pointer after deserialization is complete. -------------------------------------------------------------------------------- /DataContainerGenerator/code_fragments.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "source_builder.hpp" 6 | #include "parsing.hpp" 7 | 8 | basic_builder& make_load_record(basic_builder& o, file_def const & fd); 9 | basic_builder& make_id_definition(basic_builder& o, std::string const& type_name, std::string const& underlying_type); 10 | basic_builder& make_value_to_vector_type(basic_builder& o, std::string const& qualified_name); 11 | 12 | enum class struct_padding { none, fixed }; 13 | 14 | basic_builder& make_member_container(basic_builder& o, 15 | std::string const& member_name, std::string const& type_name, std::string const& size, struct_padding pad, bool is_expandable, 16 | std::optional const& special_fill = std::optional(), int32_t multiplicity = 1); 17 | basic_builder& make_array_member_container(basic_builder& o, 18 | std::string const& member_name, std::string const& type_name, size_t raw_size, 19 | bool is_expandable, bool is_bitfield); 20 | 21 | std::string expand_size_to_fill_cacheline_calculation(std::string const& member_type, size_t base_size); 22 | 23 | basic_builder& make_erasable_object_constructor(basic_builder& o, relationship_object_def const& obj, std::string const& name, size_t size); 24 | basic_builder& make_other_object_constructor(basic_builder& o, relationship_object_def const& obj, std::string const& name, size_t size); 25 | 26 | basic_builder& make_pop_back(basic_builder& o, relationship_object_def const& obj); 27 | basic_builder& make_object_resize(basic_builder& o, relationship_object_def const& obj); 28 | basic_builder& make_compactable_delete(basic_builder& o, relationship_object_def const& obj); 29 | basic_builder& make_non_erasable_create(basic_builder& o, relationship_object_def const& obj); 30 | basic_builder& make_erasable_delete(basic_builder& o, relationship_object_def const& obj); 31 | basic_builder& make_clearing_delete(basic_builder& o, relationship_object_def const& cob); 32 | basic_builder& make_erasable_create(basic_builder& o, relationship_object_def const& obj); 33 | basic_builder& make_internal_move_relationship(basic_builder& o, relationship_object_def const& obj); 34 | basic_builder& make_relation_try_create(basic_builder& o, relationship_object_def const& cob); 35 | basic_builder& make_relation_force_create(basic_builder& o, relationship_object_def const& cob); 36 | basic_builder& make_serialize_plan_generator(basic_builder& o, file_def const& parsed_file, load_save_def const& rt); 37 | basic_builder& make_serialize_size(basic_builder& o, file_def const& parsed_file); 38 | void make_serialize_singe_object(basic_builder & o, const relationship_object_def & ob); 39 | basic_builder& make_serialize(basic_builder& o, file_def const& parsed_file); 40 | void deserialize_size_fragment(basic_builder& o); 41 | basic_builder& make_deserialize_helper(basic_builder& o, file_def const& parsed_file); 42 | basic_builder& make_deserialize(basic_builder& o, file_def const& parsed_file, bool with_mask); 43 | basic_builder& make_serialize_all_generator(basic_builder& o, file_def const& parsed_file); 44 | basic_builder& make_iterate_over_objects(basic_builder& o, relationship_object_def const& obj); 45 | 46 | basic_builder& make_const_fat_id(basic_builder& o, relationship_object_def const& obj, file_def const& parsed_file); 47 | basic_builder& make_fat_id(basic_builder& o, relationship_object_def const& obj, file_def const& parsed_file); 48 | basic_builder& make_const_fat_id_impl(basic_builder& o, relationship_object_def const& obj, file_def const& parsed_file); 49 | basic_builder& make_fat_id_impl(basic_builder& o, relationship_object_def const& obj, file_def const& parsed_file); 50 | 51 | basic_builder& make_composite_key_declarations(basic_builder& o, std::string const& obj_name, composite_index_def const& cc); 52 | basic_builder& make_composite_key_getter(basic_builder& o, std::string const& obj_name, composite_index_def const& cc, relationship_object_def const& cob); 53 | 54 | basic_builder& make_object_member_declarations(basic_builder& o, file_def const& parsed_file, relationship_object_def const& obj, 55 | bool add_prefix, bool declaration_mode, std::string const& namesp, bool const_mode); 56 | 57 | std::optional to_fat_index_type(file_def const& parsed_file, std::string const& original_name, bool is_const); 58 | 59 | basic_builder& make_query_instance_types(basic_builder& o, prepared_query_definition const& pdef); 60 | basic_builder& make_query_instance_definitions(basic_builder& o, prepared_query_definition const& pdef); 61 | basic_builder& make_query_iterator_declarations(basic_builder& o, prepared_query_definition const& pdef); 62 | basic_builder& make_query_iterator_body(basic_builder& o, prepared_query_definition const& pdef, std::string const& ns, bool is_const); 63 | 64 | basic_builder& object_iterator_declaration(basic_builder& o, relationship_object_def const& obj); 65 | basic_builder& object_iterator_implementation(basic_builder& o, relationship_object_def const& obj); 66 | 67 | basic_builder& relation_iterator_foreach_as_generator(basic_builder& o, relationship_object_def const& obj, relationship_object_def const& rel, related_object const& l); 68 | basic_builder& relation_iterator_foreach_as_declaration(basic_builder& o, relationship_object_def const& obj, relationship_object_def const& rel, related_object const& l); 69 | basic_builder& relation_iterator_foreach_as_implementation(basic_builder& o, relationship_object_def const& obj, relationship_object_def const& rel, related_object const& l); 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /Catch_parsing_tests/Catch_parsing_tests.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {83475179-C149-4935-9050-478BA07BD1AE} 24 | Catchparsingtests 25 | 10.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v143 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | v143 38 | true 39 | MultiByte 40 | 41 | 42 | Application 43 | true 44 | v143 45 | MultiByte 46 | 47 | 48 | Application 49 | false 50 | v143 51 | true 52 | MultiByte 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | Disabled 77 | true 78 | true 79 | stdcpp17 80 | 81 | 82 | Console 83 | 84 | 85 | 86 | 87 | Level3 88 | Disabled 89 | true 90 | true 91 | 92 | 93 | Console 94 | 95 | 96 | 97 | 98 | Level3 99 | MaxSpeed 100 | true 101 | true 102 | true 103 | true 104 | 105 | 106 | Console 107 | true 108 | true 109 | 110 | 111 | 112 | 113 | Level3 114 | MaxSpeed 115 | true 116 | true 117 | true 118 | true 119 | stdcpp17 120 | 121 | 122 | Console 123 | true 124 | true 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /Catch_stable_storage_tests/Catch_stable_storage_tests.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {3A595440-2AE5-4DB3-9BE1-B231A6D53EA7} 24 | Catchstablestoragetests 25 | 10.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v143 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | v143 38 | true 39 | MultiByte 40 | 41 | 42 | Application 43 | true 44 | v143 45 | MultiByte 46 | 47 | 48 | Application 49 | false 50 | v143 51 | true 52 | MultiByte 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | Disabled 77 | true 78 | true 79 | stdcpp17 80 | AdvancedVectorExtensions 81 | 82 | 83 | Console 84 | 85 | 86 | 87 | 88 | Level3 89 | Disabled 90 | true 91 | true 92 | 93 | 94 | Console 95 | 96 | 97 | 98 | 99 | Level3 100 | MaxSpeed 101 | true 102 | true 103 | true 104 | true 105 | 106 | 107 | Console 108 | true 109 | true 110 | 111 | 112 | 113 | 114 | Level3 115 | MaxSpeed 116 | true 117 | true 118 | true 119 | true 120 | stdcpp17 121 | 122 | 123 | Console 124 | true 125 | true 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /Catch_ve_tests/Catch_ve_tests.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {140C4108-B659-4A35-BCE6-A9E42D0D4379} 24 | Catchvetests 25 | 10.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v143 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | v143 38 | true 39 | MultiByte 40 | 41 | 42 | Application 43 | true 44 | v143 45 | MultiByte 46 | 47 | 48 | Application 49 | false 50 | v143 51 | true 52 | MultiByte 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level4 76 | Disabled 77 | true 78 | true 79 | stdcpp17 80 | AdvancedVectorExtensions512 81 | Fast 82 | false 83 | 84 | 85 | Console 86 | 87 | 88 | 89 | 90 | Level3 91 | Disabled 92 | true 93 | true 94 | 95 | 96 | Console 97 | 98 | 99 | 100 | 101 | Level3 102 | MaxSpeed 103 | true 104 | true 105 | true 106 | true 107 | 108 | 109 | Console 110 | true 111 | true 112 | 113 | 114 | 115 | 116 | Level3 117 | MaxSpeed 118 | true 119 | true 120 | false 121 | true 122 | stdcpp17 123 | AdvancedVectorExtensions2 124 | true 125 | false 126 | false 127 | false 128 | false 129 | 130 | 131 | Console 132 | true 133 | true 134 | UseLinkTimeCodeGeneration 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /LuaDLLGenerator/LuaDLLGenerator.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 17.0 23 | Win32Proj 24 | {1d0ade10-7785-405c-8c43-e5fac4cd7b95} 25 | LuaDLLGenerator 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | ClangCL 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Console 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | true 89 | true 90 | true 91 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | stdcpp20 108 | 109 | 110 | Console 111 | true 112 | 113 | 114 | 115 | 116 | Level3 117 | true 118 | true 119 | true 120 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | true 122 | stdcpp20 123 | 124 | 125 | Console 126 | true 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /Catch_objects_tests/Catch_objects_tests.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #define DCON_USE_EXCEPTIONS 3 | #define DCON_TRAP_INVALID_STORE 4 | 5 | #include "catch.hpp" 6 | #include "common_types.hpp" 7 | #include "common_types.cpp" 8 | 9 | struct my_struct { 10 | float internal_val = 2.0f; 11 | }; 12 | 13 | #include "objects_def.hpp" 14 | 15 | void dcon::data_container::on_create_thingy(thingy_id) { 16 | ++counter; 17 | } 18 | void dcon::data_container::on_delete_thingy(thingy_id) { 19 | ++counter; 20 | } 21 | void dcon::data_container::on_move_thingy(thingy_id, thingy_id) { 22 | ++counter; 23 | } 24 | 25 | int32_t dcon::data_container::thingy_get_d_value(thingy_id) const { 26 | return 6; 27 | } 28 | 29 | void dcon::data_container::thingy_set_dbf_value(thingy_id, bool) { 30 | ++counter; 31 | } 32 | 33 | void dcon::oop_thingy_fat_id::reset_internal() { 34 | set_pstruct(my_struct{4.0f}); 35 | } 36 | int dcon::oop_thingy_const_fat_id::get_a_value(float offset) { 37 | return int(get_pstruct().internal_val + get_pfloat() + offset); 38 | } 39 | 40 | TEST_CASE("oop case", "[objects_and_properties_tests]") { 41 | auto ptr = std::make_unique< dcon::data_container >(); 42 | 43 | auto fid = fatten(*ptr, ptr->create_oop_thingy()); 44 | 45 | REQUIRE(fid.get_pstruct().internal_val == 2.0f); 46 | fid.reset_internal(); 47 | REQUIRE(fid.get_pstruct().internal_val == 4.0f); 48 | 49 | REQUIRE(fid.get_a_value(6.0f) == 10); 50 | } 51 | 52 | TEST_CASE("hooked_functions", "[objects_and_properties_tests]") { 53 | auto ptr = std::make_unique< dcon::data_container >(); 54 | 55 | ptr->thingy_set_some_value(ptr->create_thingy(), 1); 56 | ptr->thingy_set_some_value(ptr->create_thingy(), 2); 57 | ptr->thingy_set_some_value(ptr->create_thingy(), 3); 58 | ptr->thingy_set_some_value(ptr->create_thingy(), 4); 59 | 60 | REQUIRE(ptr->counter == 4); 61 | ptr->counter = 0; 62 | 63 | REQUIRE(ptr->thingy_get_some_value(dcon::thingy_id(2)) == 3); 64 | 65 | ptr->delete_thingy(dcon::thingy_id(2)); 66 | 67 | REQUIRE(ptr->counter == 2); 68 | ptr->counter = 0; 69 | 70 | REQUIRE(ptr->thingy_get_some_value(dcon::thingy_id(2)) == 4); 71 | 72 | ptr->delete_thingy(dcon::thingy_id(2)); 73 | REQUIRE(ptr->counter == 1); 74 | } 75 | 76 | TEST_CASE("property_types", "[objects_and_properties_tests]") { 77 | auto ptr = std::make_unique< dcon::data_container >(); 78 | 79 | ptr->create_thingy(); 80 | ptr->create_thingy(); 81 | ptr->create_thingy(); 82 | ptr->create_thingy(); 83 | ptr->create_thingy(); 84 | ptr->create_thingy(); 85 | auto target = fatten(*ptr, ptr->create_thingy()); 86 | ptr->create_thingy(); 87 | ptr->create_thingy(); 88 | 89 | REQUIRE(ptr->thingy_get_bf_value(target) == false); 90 | REQUIRE(ptr->thingy_get_obj_value(target).size() == 0); 91 | REQUIRE(ptr->thingy_get_pooled_v(target).size() == 0); 92 | REQUIRE(ptr->thingy_get_big_array_size() == 0); 93 | REQUIRE(ptr->thingy_get_big_array_bf_size() == 0); 94 | 95 | ptr->thingy_set_bf_value(target, true); 96 | ptr->thingy_get_obj_value(target).push_back(3.0f); 97 | ptr->thingy_get_obj_value(target).push_back(4.0f); 98 | ptr->thingy_get_pooled_v(target).add_unique(int16_t(-5)); 99 | ptr->thingy_resize_big_array(2); 100 | ptr->thingy_resize_big_array_bf(4); 101 | 102 | target.set_some_value(35); 103 | REQUIRE(target.get_pooled_v().size() == 1); 104 | target.get_pooled_v().push_back(3); 105 | target.get_pooled_v().push_back(5); 106 | 107 | REQUIRE(ptr->thingy_get_big_array_size() == 2); 108 | REQUIRE(ptr->thingy_get_big_array_bf_size() == 4); 109 | 110 | REQUIRE(ptr->thingy_get_big_array(target, 0) == 0.0f); 111 | REQUIRE(ptr->thingy_get_big_array(target, 1) == 0.0f); 112 | 113 | REQUIRE(ptr->thingy_get_big_array_bf(target, 3) == false); 114 | 115 | REQUIRE(target.get_some_value() == 35); 116 | REQUIRE(target.get_pooled_v().size() == 3); 117 | REQUIRE(target.get_pooled_v().at(1) == 3); 118 | REQUIRE(target.get_pooled_v().at(2) == 5); 119 | 120 | ptr->thingy_set_big_array(target, 0, 1.5f); 121 | ptr->thingy_set_big_array(target, 1, 3.5f); 122 | ptr->thingy_set_big_array_bf(target, 3, true); 123 | 124 | REQUIRE(ptr->thingy_get_bf_value(target) == true); 125 | REQUIRE(ptr->thingy_get_obj_value(target).size() == 2); 126 | REQUIRE(ptr->thingy_get_obj_value(target)[1] == 4.0f); 127 | REQUIRE(ptr->thingy_get_pooled_v(target).contains(int16_t(-5)) == true); 128 | REQUIRE(ptr->thingy_get_big_array(target, 0) == 1.5f); 129 | REQUIRE(ptr->thingy_get_big_array(target, 1) == 3.5f); 130 | REQUIRE(ptr->thingy_get_big_array_bf(target, 3) == true); 131 | 132 | ptr->delete_thingy(target); 133 | 134 | REQUIRE(ptr->thingy_get_bf_value(target) == false); 135 | REQUIRE(ptr->thingy_get_obj_value(target).size() == 0); 136 | REQUIRE(ptr->thingy_get_pooled_v(target).size() == 0); 137 | REQUIRE(ptr->thingy_get_big_array(target, 0) == 0.0f); 138 | REQUIRE(ptr->thingy_get_big_array(target, 1) == 0.0f); 139 | REQUIRE(ptr->thingy_get_big_array_bf(target, 3) == false); 140 | } 141 | 142 | TEST_CASE("expandable_property_types", "[objects_and_properties_tests]") { 143 | auto ptr = std::make_unique< dcon::data_container >(); 144 | 145 | ptr->create_thingy2(); 146 | ptr->create_thingy2(); 147 | ptr->create_thingy2(); 148 | ptr->create_thingy2(); 149 | ptr->create_thingy2(); 150 | ptr->create_thingy2(); 151 | auto target = ptr->create_thingy2(); 152 | ptr->create_thingy2(); 153 | ptr->create_thingy2(); 154 | 155 | REQUIRE(ptr->thingy2_get_bf_value(target) == false); 156 | REQUIRE(ptr->thingy2_get_obj_value(target).size() == 0); 157 | REQUIRE(ptr->thingy2_get_pooled_v(target).size() == 0); 158 | REQUIRE(ptr->thingy2_get_big_array_size() == 0); 159 | REQUIRE(ptr->thingy2_get_big_array_bf_size() == 0); 160 | 161 | ptr->thingy2_set_bf_value(target, true); 162 | ptr->thingy2_get_obj_value(target).push_back(3.0f); 163 | ptr->thingy2_get_obj_value(target).push_back(4.0f); 164 | ptr->thingy2_get_pooled_v(target).add_unique(int16_t(-5)); 165 | ptr->thingy2_resize_big_array(2); 166 | ptr->thingy2_resize_big_array_bf(4); 167 | 168 | REQUIRE(ptr->thingy2_get_big_array_size() == 2); 169 | REQUIRE(ptr->thingy2_get_big_array_bf_size() == 4); 170 | 171 | REQUIRE(ptr->thingy2_get_big_array(target, 0) == 0.0f); 172 | REQUIRE(ptr->thingy2_get_big_array(target, 1) == 0.0f); 173 | 174 | REQUIRE(ptr->thingy2_get_big_array_bf(target, 3) == false); 175 | 176 | ptr->thingy2_set_big_array(target, 0, 1.5f); 177 | ptr->thingy2_set_big_array(target, 1, 3.5f); 178 | ptr->thingy2_set_big_array_bf(target, 3, true); 179 | 180 | REQUIRE(ptr->thingy2_get_bf_value(target) == true); 181 | REQUIRE(ptr->thingy2_get_obj_value(target).size() == 2); 182 | REQUIRE(ptr->thingy2_get_obj_value(target)[1] == 4.0f); 183 | REQUIRE(ptr->thingy2_get_pooled_v(target).contains(int16_t(-5)) == true); 184 | REQUIRE(ptr->thingy2_get_pooled_v(target).size() == 1); 185 | REQUIRE(ptr->thingy2_get_big_array(target, 0) == 1.5f); 186 | REQUIRE(ptr->thingy2_get_big_array(target, 1) == 3.5f); 187 | REQUIRE(ptr->thingy2_get_big_array_bf(target, 3) == true); 188 | 189 | ptr->delete_thingy2(target); 190 | 191 | REQUIRE(ptr->thingy2_get_bf_value(target) == false); 192 | REQUIRE(ptr->thingy2_get_obj_value(target).size() == 0); 193 | REQUIRE(ptr->thingy2_get_pooled_v(target).size() == 0); 194 | REQUIRE(ptr->thingy2_get_big_array(target, 0) == 0.0f); 195 | REQUIRE(ptr->thingy2_get_big_array(target, 1) == 0.0f); 196 | REQUIRE(ptr->thingy2_get_big_array_bf(target, 3) == false); 197 | } 198 | 199 | TEST_CASE("hooked property getter, setter", "[objects_and_properties_tests]") { 200 | auto ptr = std::make_unique< dcon::data_container >(); 201 | auto thng = dcon::fatten(*ptr, ptr->create_thingy()); 202 | 203 | REQUIRE(thng.get_d_value() == 6); 204 | REQUIRE(ptr->counter == 1); 205 | 206 | thng.set_dbf_value(false); 207 | 208 | REQUIRE(ptr->counter == 2); 209 | } -------------------------------------------------------------------------------- /CommonIncludes/CommonIncludes.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {6AB3FA0B-E833-4828-A494-0CAE6F640242} 24 | CommonIncludes 25 | 10.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v143 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | v143 38 | true 39 | MultiByte 40 | 41 | 42 | Application 43 | true 44 | v143 45 | MultiByte 46 | 47 | 48 | StaticLibrary 49 | false 50 | v143 51 | true 52 | MultiByte 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | Disabled 77 | true 78 | true 79 | 80 | 81 | Console 82 | 83 | 84 | 85 | 86 | Level3 87 | Disabled 88 | true 89 | true 90 | stdcpp17 91 | 92 | 93 | Console 94 | 95 | 96 | 97 | 98 | Level3 99 | MaxSpeed 100 | true 101 | true 102 | true 103 | true 104 | 105 | 106 | Console 107 | true 108 | true 109 | 110 | 111 | 112 | 113 | Level3 114 | MaxSpeed 115 | true 116 | true 117 | true 118 | true 119 | 120 | 121 | Console 122 | true 123 | true 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /Catch_query_tests/Catch_query_tests.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {4B690C65-6814-4D32-A81A-3E4B090ED4B8} 24 | Catchquerytests 25 | 10.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v143 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | v143 38 | true 39 | MultiByte 40 | 41 | 42 | Application 43 | true 44 | v143 45 | MultiByte 46 | 47 | 48 | Application 49 | false 50 | v143 51 | true 52 | MultiByte 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level4 76 | Disabled 77 | true 78 | true 79 | stdcpp17 80 | false 81 | $(SolutionDir)\CommonIncludes\ 82 | false 83 | false 84 | 85 | 86 | Console 87 | 88 | 89 | 90 | 91 | Level3 92 | Disabled 93 | true 94 | true 95 | 96 | 97 | Console 98 | 99 | 100 | 101 | 102 | Level3 103 | MaxSpeed 104 | true 105 | true 106 | true 107 | true 108 | 109 | 110 | Console 111 | true 112 | true 113 | 114 | 115 | 116 | 117 | Level4 118 | MaxSpeed 119 | true 120 | true 121 | true 122 | true 123 | stdcpp17 124 | false 125 | $(SolutionDir)\CommonIncludes\ 126 | 127 | 128 | Console 129 | true 130 | true 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | $(SolutionDir)$(Platform)\$(Configuration)\DataContainerGenerator query_objs.txt 139 | query_objs.hpp 140 | ClInclude 141 | $(SolutionDir)$(Platform)\$(Configuration)\DataContainerGenerator query_objs.txt 142 | query_objs.hpp 143 | ClInclude 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /Catch_stable_storage_tests/Catch_stable_storage_tests.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | 3 | #include "..\CommonIncludes\catch.hpp" 4 | #include "..\CommonIncludes\common_types.hpp" 5 | #include "..\CommonIncludes\common_types.cpp" 6 | 7 | TEST_CASE("operations on invalid", "[storage_tests]") { 8 | //dcon::shared_backing_storage.~stable_variable_vector3_backing(); 9 | //new (&dcon::shared_backing_storage) dcon::stable_variable_vector3_backing(); 10 | 11 | auto ptr = std::make_unique>(); 12 | 13 | dcon::stable_mk_2_tag inv_tag = std::numeric_limits::max(); 14 | 15 | auto rng = dcon::get_range(*ptr, inv_tag); 16 | 17 | REQUIRE(rng.first == rng.second); 18 | REQUIRE(dcon::get_size(*ptr, inv_tag) == 0); 19 | REQUIRE(dcon::contains_item(*ptr, inv_tag, 17.5f) == false); 20 | } 21 | 22 | TEST_CASE("single item", "[storage_tests]") { 23 | //dcon::shared_backing_storage.~stable_variable_vector3_backing(); 24 | //new (&dcon::shared_backing_storage) dcon::stable_variable_vector3_backing(); 25 | 26 | auto ptr = std::make_unique>(); 27 | 28 | dcon::stable_mk_2_tag store = std::numeric_limits::max(); 29 | 30 | dcon::push_back(*ptr, store, 3.5f); 31 | 32 | auto rng = dcon::get_range(*ptr, store); 33 | REQUIRE(rng.first != rng.second); 34 | REQUIRE(*rng.first == 3.5f); 35 | REQUIRE(dcon::get_size(*ptr, store) == 1); 36 | REQUIRE(dcon::contains_item(*ptr, store, 17.5f) == false); 37 | REQUIRE(dcon::contains_item(*ptr, store, 3.5f) == true); 38 | REQUIRE(dcon::get(*ptr, store, 0) == 3.5f); 39 | REQUIRE(dcon::contains_item(*ptr, store, 3.5f) == true); 40 | 41 | 42 | dcon::pop_back(*ptr, store); 43 | 44 | rng = dcon::get_range(*ptr, store); 45 | REQUIRE(rng.first == rng.second); 46 | REQUIRE(dcon::get_size(*ptr, store) == 0); 47 | REQUIRE(dcon::contains_item(*ptr, store, 3.5f) == false); 48 | } 49 | 50 | TEST_CASE("loaded_range", "[storage_tests]") { 51 | //dcon::shared_backing_storage.~stable_variable_vector3_backing(); 52 | //new (&dcon::shared_backing_storage) dcon::stable_variable_vector3_backing(); 53 | 54 | std::vector fvec = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; 55 | 56 | auto ptr = std::make_unique>(); 57 | 58 | dcon::stable_mk_2_tag store = std::numeric_limits::max(); 59 | 60 | dcon::load_range(*ptr, store, fvec.data(), fvec.data() + 6); 61 | 62 | auto rng = dcon::get_range(*ptr, store); 63 | REQUIRE(rng.second - rng.first == 6); 64 | REQUIRE(*rng.first == 1.0f); 65 | REQUIRE(dcon::get_size(*ptr, store) == 6); 66 | REQUIRE(dcon::contains_item(*ptr, store, 17.5f) == false); 67 | REQUIRE(dcon::contains_item(*ptr, store, 4.0f) == true); 68 | REQUIRE(dcon::get(*ptr, store, 2) == 3.0f); 69 | REQUIRE(dcon::contains_item(*ptr, store, 1.0f) == true); 70 | REQUIRE(dcon::contains_item(*ptr, store, 6.0f) == true); 71 | 72 | dcon::pop_back(*ptr, store); 73 | rng = dcon::get_range(*ptr, store); 74 | REQUIRE(rng.second - rng.first == 5); 75 | REQUIRE(*rng.first == 1.0f); 76 | REQUIRE(dcon::get_size(*ptr, store) == 5); 77 | REQUIRE(dcon::contains_item(*ptr, store, 17.5f) == false); 78 | REQUIRE(dcon::contains_item(*ptr, store, 4.0f) == true); 79 | REQUIRE(dcon::get(*ptr, store, 2) == 3.0f); 80 | REQUIRE(dcon::contains_item(*ptr, store, 1.0f) == true); 81 | REQUIRE(dcon::contains_item(*ptr, store, 6.0f) == false); 82 | 83 | auto old_back = dcon::get(*ptr, store, 4); 84 | dcon::remove_at(*ptr, store, 2); 85 | 86 | REQUIRE(dcon::get_size(*ptr, store) == 4); 87 | REQUIRE(dcon::get(*ptr, store, 2) == old_back); 88 | 89 | dcon::resize(*ptr, store, 2); 90 | rng = dcon::get_range(*ptr, store); 91 | REQUIRE(rng.second - rng.first == 2); 92 | REQUIRE(*rng.first == 1.0f); 93 | REQUIRE(dcon::get_size(*ptr, store) == 2); 94 | REQUIRE(dcon::contains_item(*ptr, store, 17.5f) == false); 95 | REQUIRE(dcon::contains_item(*ptr, store, 4.0f) == false); 96 | REQUIRE(dcon::get(*ptr, store, 1) == 2.0f); 97 | REQUIRE(dcon::contains_item(*ptr, store, 1.0f) == true); 98 | REQUIRE(dcon::contains_item(*ptr, store, 6.0f) == false); 99 | 100 | ptr->release(store); 101 | REQUIRE(store == std::numeric_limits::max()); 102 | rng = dcon::get_range(*ptr, store); 103 | REQUIRE(rng.first == rng.second); 104 | REQUIRE(dcon::get_size(*ptr, store) == 0); 105 | REQUIRE(dcon::contains_item(*ptr, store, 1.0f) == false); 106 | } 107 | 108 | TEST_CASE("growing storage", "[storage_tests]") { 109 | //dcon::shared_backing_storage.~stable_variable_vector3_backing(); 110 | //new (&dcon::shared_backing_storage) dcon::stable_variable_vector3_backing(); 111 | 112 | auto ptr = std::make_unique>(); 113 | dcon::stable_mk_2_tag store = std::numeric_limits::max(); 114 | 115 | for(int i = 0; i < 300; ++i) { 116 | dcon::push_back(*ptr, store, float(i)); 117 | } 118 | 119 | auto rng = dcon::get_range(*ptr, store); 120 | REQUIRE(rng.second - rng.first == 300); 121 | REQUIRE(*rng.first == 0.0f); 122 | REQUIRE(dcon::get_size(*ptr, store) == 300); 123 | REQUIRE(dcon::contains_item(*ptr, store, 17.5f) == false); 124 | REQUIRE(dcon::contains_item(*ptr, store, 299.0f) == true); 125 | REQUIRE(dcon::get(*ptr, store, 134) == 134.0f); 126 | REQUIRE(dcon::contains_item(*ptr, store, 120.0f) == true); 127 | REQUIRE(dcon::contains_item(*ptr, store, 6.0f) == true); 128 | 129 | dcon::remove_unique_item(*ptr, store, 130.0f); 130 | REQUIRE(dcon::get_size(*ptr, store) == 299); 131 | REQUIRE(dcon::contains_item(*ptr, store, 130.0f) == false); 132 | REQUIRE(dcon::contains_item(*ptr, store, 140.0f) == true); 133 | 134 | dcon::replace_unique_item(*ptr, store, 120.0f, 2.5f); 135 | REQUIRE(dcon::get_size(*ptr, store) == 299); 136 | REQUIRE(dcon::contains_item(*ptr, store, 120.0f) == false); 137 | REQUIRE(dcon::contains_item(*ptr, store, 2.5f) == true); 138 | 139 | dcon::resize(*ptr, store, 2); 140 | rng = dcon::get_range(*ptr, store); 141 | REQUIRE(rng.second - rng.first == 2); 142 | REQUIRE(dcon::get_size(*ptr, store) == 2); 143 | REQUIRE(dcon::contains_item(*ptr, store, 17.5f) == false); 144 | REQUIRE(dcon::contains_item(*ptr, store, 4.0f) == false); 145 | REQUIRE(dcon::get(*ptr, store, 1) == 1.0f); 146 | REQUIRE(dcon::contains_item(*ptr, store, 0.0f) == true); 147 | REQUIRE(dcon::contains_item(*ptr, store, 6.0f) == false); 148 | } 149 | 150 | TEST_CASE("growing multiple", "[storage_tests]") { 151 | //dcon::shared_backing_storage.~stable_variable_vector3_backing(); 152 | //new (&dcon::shared_backing_storage) dcon::stable_variable_vector3_backing(); 153 | 154 | auto ptr = std::make_unique>(); 155 | dcon::stable_mk_2_tag storea = std::numeric_limits::max(); 156 | dcon::stable_mk_2_tag storeb = std::numeric_limits::max(); 157 | 158 | for(int i = 0; i < 300; ++i) { 159 | dcon::push_back(*ptr, storea, float(i)); 160 | dcon::push_back(*ptr, storeb, float(i * 2)); 161 | } 162 | 163 | REQUIRE(dcon::get_size(*ptr, storea) == 300); 164 | REQUIRE(dcon::get_size(*ptr, storeb) == 300); 165 | 166 | REQUIRE(dcon::contains_item(*ptr, storea, 400.0f) == false); 167 | REQUIRE(dcon::contains_item(*ptr, storeb, 400.0f) == true); 168 | } 169 | 170 | TEST_CASE("local vector", "[storage_tests]") { 171 | //dcon::shared_backing_storage.~stable_variable_vector3_backing(); 172 | //new (&dcon::shared_backing_storage) dcon::stable_variable_vector3_backing(); 173 | 174 | { 175 | dcon::local_vector lv; 176 | 177 | for(int i = 0; i < 300; ++i) { 178 | lv.push_back(i); 179 | } 180 | 181 | REQUIRE(lv.end() - lv.begin() == 300); 182 | for(int i = 0; i < 300; ++i) { 183 | REQUIRE(*(lv.begin() + i) == i); 184 | } 185 | } 186 | { 187 | dcon::local_vector lv; 188 | 189 | for(int i = 0; i < 55; ++i) { 190 | lv.push_back(i); 191 | } 192 | 193 | REQUIRE(lv.end() - lv.begin() == 55); 194 | for(int i = 0; i < 55; ++i) { 195 | REQUIRE(*(lv.begin() + i) == i); 196 | } 197 | } 198 | } -------------------------------------------------------------------------------- /Catch_relationships_tests/Catch_relationships_tests.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {C2427BEB-98B9-4419-AF98-66059CA626DD} 24 | Catchrelationshipstests 25 | 10.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v143 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | v143 38 | true 39 | MultiByte 40 | 41 | 42 | Application 43 | true 44 | v143 45 | MultiByte 46 | 47 | 48 | Application 49 | false 50 | v143 51 | true 52 | MultiByte 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level4 76 | Disabled 77 | true 78 | true 79 | stdcpp20 80 | true 81 | $(SolutionDir)\CommonIncludes\;%(AdditionalIncludeDirectories) 82 | /bigobj %(AdditionalOptions) 83 | 84 | 85 | Console 86 | 87 | 88 | 89 | 90 | Level3 91 | Disabled 92 | true 93 | true 94 | 95 | 96 | Console 97 | 98 | 99 | 100 | 101 | Level3 102 | MaxSpeed 103 | true 104 | true 105 | true 106 | true 107 | 108 | 109 | Console 110 | true 111 | true 112 | 113 | 114 | 115 | 116 | Level4 117 | MaxSpeed 118 | true 119 | true 120 | true 121 | true 122 | stdcpp20 123 | true 124 | $(SolutionDir)\CommonIncludes\;%(AdditionalIncludeDirectories) 125 | /bigobj %(AdditionalOptions) 126 | 127 | 128 | Console 129 | true 130 | true 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | $(SolutionDir)$(Platform)\$(Configuration)\DataContainerGenerator relation.txt 139 | relation.hpp 140 | ClInclude 141 | $(SolutionDir)$(Platform)\$(Configuration)\DataContainerGenerator relation.txt 142 | relation.hpp 143 | ClInclude 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /Catch_objects_tests/Catch_objects_tests.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {148EC329-FEBD-41FE-A833-3F493294CAC8} 24 | Catchobjectstests 25 | 10.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v143 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | v143 38 | true 39 | MultiByte 40 | 41 | 42 | Application 43 | true 44 | v143 45 | MultiByte 46 | 47 | 48 | Application 49 | false 50 | v143 51 | true 52 | MultiByte 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | $(SolutionDir)\CommonIncludes\;$(IncludePath) 74 | 75 | 76 | $(SolutionDir)\CommonIncludes\;$(IncludePath) 77 | 78 | 79 | 80 | Level4 81 | Disabled 82 | true 83 | true 84 | stdcpp20 85 | true 86 | /wd4100 %(AdditionalOptions) 87 | 88 | 89 | Console 90 | 91 | 92 | 93 | 94 | Level3 95 | Disabled 96 | true 97 | true 98 | 99 | 100 | Console 101 | 102 | 103 | 104 | 105 | Level3 106 | MaxSpeed 107 | true 108 | true 109 | true 110 | true 111 | 112 | 113 | Console 114 | true 115 | true 116 | 117 | 118 | 119 | 120 | Level4 121 | MaxSpeed 122 | true 123 | true 124 | true 125 | true 126 | stdcpp20 127 | /wd4100 %(AdditionalOptions) 128 | 129 | 130 | Console 131 | true 132 | true 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | $(SolutionDir)$(Platform)\$(Configuration)\DataContainerGenerator objects_def.txt 141 | objects_def.hpp 142 | ClInclude 143 | $(SolutionDir)$(Platform)\$(Configuration)\DataContainerGenerator objects_def.txt 144 | objects_def.hpp 145 | ClInclude 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /Catch_ecs_tutorial_tests/Catch_ecs_tutorial_tests.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {162aad47-8007-4302-85ad-f0ee9e959d09} 25 | Catchecstutorialtests 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Console 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | true 89 | true 90 | true 91 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level4 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | $(SolutionDir)\CommonIncludes\ 108 | stdcpp17 109 | 110 | 111 | Console 112 | true 113 | 114 | 115 | 116 | 117 | Level4 118 | true 119 | true 120 | true 121 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 122 | true 123 | $(SolutionDir)\CommonIncludes\ 124 | stdcpp17 125 | 126 | 127 | Console 128 | true 129 | true 130 | true 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | $(SolutionDir)$(Platform)\$(Configuration)\DataContainerGenerator ecs.txt 139 | ecs.hpp 140 | ClInclude 141 | $(SolutionDir)$(Platform)\$(Configuration)\DataContainerGenerator ecs.txt 142 | ecs.hpp 143 | ClInclude 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /tutorial_color.md: -------------------------------------------------------------------------------- 1 | # Tutorial: integrating a color struct 2 | 3 | ## Motivation 4 | 5 | It is common to store a color as three values for red, green, blue. Let us say that you are storing the three color components as three floating point values. There is a good argument to be made that most operations on a color will want all three of those values at once, and if you don't plan on applying SIMD operations to colors, you would probably want the three color components to exist in adjacent memory locations so that they will be pulled into the cache together. This tutorial will cover how to accomplish this, and how the transition from an earlier version where the values were stored separately can be made less painful. 6 | 7 | The code for this tutorial can be found in `Catch_color_tutorial_tests`. 8 | 9 | ## The basics 10 | 11 | First you must define a class or structure that will hold the three color values. In our example this will be defined in `color_tutorial.hpp` as: 12 | 13 | ``` 14 | struct rgb_color { 15 | float red = 0.0f; 16 | float green = 0.0f; 17 | float blue = 0.0f; 18 | }; 19 | ``` 20 | 21 | Then in our data container definition file `color_container.txt` we can write the following: 22 | 23 | ``` 24 | include{"color_tutorial.hpp"} 25 | 26 | object{ 27 | name{colored_thing} 28 | size{3000} 29 | storage_type{contiguous} 30 | 31 | property { 32 | name{color} 33 | type{rgb_color} 34 | } 35 | } 36 | ``` 37 | 38 | If `handle` is a fat handle (of type `colored_thing_fat_id`) we can access the members of the `rgb_color` struct with expressions such as `handle.get_color().red`. 39 | 40 | ## Upgrading 41 | 42 | Let us further suppose that `colored` thing used to have three `red`, `green`, and `blue` properties. To make the transition easier, we can create member functions that will expose getters and setters that look like the old ones for the `red`, `green`, and `blue` properties when accessed through a fat handle. 43 | 44 | We do this by first making the following additions to the object definition: 45 | 46 | ``` 47 | object{ 48 | name{colored_thing} 49 | size{3000} 50 | storage_type{contiguous} 51 | 52 | property { 53 | name{color} 54 | type{rgb_color} 55 | } 56 | 57 | function{void @set_red(float @value)} 58 | function{void @set_green(float @value)} 59 | function{void @set_blue(float @value)} 60 | const_function{float @get_red()} 61 | const_function{float @get_green()} 62 | const_function{float @get_blue()} 63 | } 64 | ``` 65 | 66 | Then we add definitions for these functions in a `color_container.cpp` that we create (and which the generator will not touch). 67 | 68 | ``` 69 | void dcon::colored_thing_fat_id::set_red(float value) { 70 | get_color().red = value; 71 | } 72 | void dcon::colored_thing_fat_id::set_green(float value) { 73 | get_color().green = value; 74 | } 75 | void dcon::colored_thing_fat_id::set_blue(float value) { 76 | get_color().blue = value; 77 | } 78 | float dcon::colored_thing_const_fat_id::get_red() { 79 | return get_color().red; 80 | } 81 | float dcon::colored_thing_const_fat_id::get_green() { 82 | return get_color().green; 83 | } 84 | float dcon::colored_thing_const_fat_id::get_blue() { 85 | return get_color().blue; 86 | } 87 | ``` 88 | 89 | And now statements such as `handle.set_red(0.0f);` written under the old definition will continue to work. 90 | 91 | We would also need to update how we deserialize data written by the old version. Unfortunately, since we aren't converting a single property to a single property, we can't lean on the built in type-conversion facilities. Let us assume that we call the deserialize function as follows: 92 | 93 | ``` 94 | load_record record_out; 95 | std::byte const* position = start; 96 | ptr->deserialize(position, end, record_out); 97 | ``` 98 | 99 | What we need to do is first add a check to see if the color information has failed to deserialize. If it hasn't, we can then scan the records present in the data looking for the red, green, and blue values that an old version might have written out. And if we find them, then we can populate the new `rgb_color` structs with them. To promote better code organization, we will also sequester the logic to do this inside a new member function of the data container. 100 | 101 | So first we add the line `global{void deserialize_rgb(std::byte const* start, std::byte const* end, load_record& record_in_out);}` to the data container definition file, which declares our new member function. 102 | 103 | Then we add the following to the `color_container.cpp` file: 104 | 105 | ``` 106 | void dcon::data_container::deserialize_rgb(std::byte const* start, std::byte const* end, load_record& record_in_out) { 107 | if(!record_in_out.colored_thing_color) { 108 | float const* found_red = nullptr; 109 | float const* found_green = nullptr; 110 | float const* found_blue = nullptr; 111 | uint32_t smallest_count = colored_thing_size(); 112 | 113 | for_each_record(start, end, 114 | [&](dcon::record_header const& header, std::byte const* data_start, std::byte const* data_end){ 115 | if(header.is_object("colored_thing") && header.is_type("float")) { 116 | if(header.is_property("red")) { 117 | found_red = reinterpret_cast(data_start); 118 | smallest_count = std::min(smallest_count, uint32_t((data_end - data_start) / sizeof(float))); 119 | } else if(header.is_property("green")) { 120 | found_green = reinterpret_cast(data_start); 121 | smallest_count = std::min(smallest_count, uint32_t((data_end - data_start) / sizeof(float))); 122 | } else if(header.is_property("blue")) { 123 | found_blue = reinterpret_cast(data_start); 124 | smallest_count = std::min(smallest_count, uint32_t((data_end - data_start) / sizeof(float))); 125 | } 126 | } 127 | }); 128 | if(found_red && found_green && found_blue) { 129 | for_each_colored_thing([&](auto id){ 130 | if(id.index() < int32_t(smallest_count)) { 131 | colored_thing_set_color(id, 132 | rgb_color{ found_red[id.index()], found_green[id.index()], found_blue[id.index()] 133 | }); 134 | } 135 | }); 136 | record_in_out.colored_thing_color = true; 137 | } 138 | } 139 | } 140 | ``` 141 | 142 | Finally, we call this new function in addition to the old deserialization routine: 143 | 144 | ``` 145 | load_record record_out; 146 | std::byte const* position = start; 147 | ptr->deserialize(position, end, record_out); 148 | ptr->deserialize_rgb(start, end, record_out); 149 | 150 | ``` 151 | 152 | Note that there is some extra complexity here to check for the possibility of an incomplete data source (i.e. where one or more of the colors has had less information serialized than is necessary to fill all of the color values) and to make sure that we don't read outside the memory contained in each record. If you know for sure that you will never encounter incomplete records, then a lot of the complexity in the above example can be removed. 153 | 154 | ## SIMD integration 155 | 156 | Putting the red, green, and blue values into their own struct does not prevent them from being used in a SIMD operation altogether, it merely makes accessing and storing those values less efficient. *If* there is enough work being done, writing a SIMD operation for those values may still be the best approach. (This is probably not the case for the example below). 157 | 158 | Let us suppose that we had a SIMD operation that set all the blue values to the average of the red and green values as follows: 159 | 160 | ``` 161 | ptr->execute_serial_over_colored_thing([p = ptr.get()](auto position){ 162 | p->colored_thing_set_blue(position, 163 | (p->colored_thing_get_red(position) + p->colored_thing_get_green(position)) / 2.0f); 164 | }); 165 | ``` 166 | 167 | (Note, that we can't use the nice syntax inside a SIMD operation, unfortunately) 168 | 169 | We can translate this operation to work on the new design by using `ve::apply` to gather the desired values from the new struct and to store the result as follows: 170 | 171 | ``` 172 | ptr->execute_serial_over_colored_thing([p = ptr.get()](auto position){ 173 | auto red_value = ve::apply( 174 | [p](dcon::colored_thing_id i){ return p->colored_thing_get_color(i).red; }, 175 | position); 176 | auto green_value = ve::apply( 177 | [p](dcon::colored_thing_id i){ return p->colored_thing_get_color(i).green; }, 178 | position); 179 | ve::apply( 180 | [p](dcon::colored_thing_id i, float v){ p->colored_thing_get_color(i).blue = v; }, 181 | position, (red_value + green_value) / 2.0f); 182 | }); 183 | ``` 184 | 185 | Yes, this is significantly more verbose, but in cases where making this translation is reasonable, i.e. in cases where the operation is doing much more work than just loading and storing the values, the increase will be a much smaller proportion of the total length of the function. -------------------------------------------------------------------------------- /Catch_serialization_tests/Catch_serialization_tests.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {0DB34D32-F959-42F1-8B0D-47BB41022BF2} 24 | Catchserializationtests 25 | 10.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v143 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | v143 38 | true 39 | MultiByte 40 | 41 | 42 | Application 43 | true 44 | v143 45 | MultiByte 46 | 47 | 48 | Application 49 | false 50 | v143 51 | true 52 | MultiByte 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level4 76 | Disabled 77 | true 78 | true 79 | $(SolutionDir)\CommonIncludes\;%(AdditionalIncludeDirectories) 80 | stdcpp20 81 | true 82 | 83 | 84 | Console 85 | 86 | 87 | 88 | 89 | Level3 90 | Disabled 91 | true 92 | true 93 | 94 | 95 | Console 96 | 97 | 98 | 99 | 100 | Level3 101 | MaxSpeed 102 | true 103 | true 104 | true 105 | true 106 | 107 | 108 | Console 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | MaxSpeed 117 | true 118 | true 119 | true 120 | true 121 | $(SolutionDir)\CommonIncludes\;%(AdditionalIncludeDirectories) 122 | stdcpp20 123 | 124 | 125 | Console 126 | true 127 | true 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | $(SolutionDir)$(Platform)\$(Configuration)\DataContainerGenerator old_ser.txt 136 | old_ser.hpp 137 | ClInclude 138 | $(SolutionDir)$(Platform)\$(Configuration)\DataContainerGenerator old_ser.txt 139 | old_ser.hpp 140 | ClInclude 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | $(SolutionDir)$(Platform)\$(Configuration)\DataContainerGenerator new_ser.txt 150 | new_ser.hpp 151 | ClInclude 152 | $(SolutionDir)$(Platform)\$(Configuration)\DataContainerGenerator new_ser.txt 153 | new_ser.hpp 154 | ClInclude 155 | 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /DataContainerGenerator/DataContainerGenerator.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {EA045C4D-FCAB-40DC-AFB8-2A64F2B56354} 24 | Win32Proj 25 | DataContainerGenerator 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | true 78 | 79 | 80 | false 81 | 82 | 83 | false 84 | 85 | 86 | 87 | 88 | 89 | Level3 90 | Disabled 91 | true 92 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 93 | true 94 | 95 | 96 | Console 97 | true 98 | 99 | 100 | 101 | 102 | 103 | 104 | Level4 105 | Disabled 106 | true 107 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 108 | true 109 | stdcpp20 110 | /wd4100 %(AdditionalOptions) 111 | 112 | 113 | Console 114 | true 115 | 116 | 117 | 118 | 119 | 120 | 121 | Level3 122 | MaxSpeed 123 | true 124 | true 125 | true 126 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 127 | true 128 | 129 | 130 | Console 131 | true 132 | true 133 | true 134 | 135 | 136 | 137 | 138 | 139 | 140 | Level4 141 | MaxSpeed 142 | true 143 | true 144 | true 145 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 146 | true 147 | stdcpp20 148 | /wd4100 %(AdditionalOptions) 149 | 150 | 151 | Console 152 | true 153 | true 154 | true 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /lua_dll_build_test/lua_dll_build_test.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 17.0 23 | Win32Proj 24 | {0c308ffd-5901-4e9b-9cb3-a93af83a6bf3} 25 | luadllbuildtest 26 | 10.0 27 | 28 | 29 | 30 | DynamicLibrary 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | DynamicLibrary 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | DynamicLibrary 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | DynamicLibrary 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;LUADLLBUILDTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 78 | true 79 | Use 80 | pch.h 81 | 82 | 83 | Windows 84 | true 85 | false 86 | 87 | 88 | 89 | 90 | Level3 91 | true 92 | true 93 | true 94 | WIN32;NDEBUG;LUADLLBUILDTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 95 | true 96 | Use 97 | pch.h 98 | 99 | 100 | Windows 101 | true 102 | true 103 | true 104 | false 105 | 106 | 107 | 108 | 109 | Level3 110 | true 111 | _DEBUG;_CRT_SECURE_NO_WARNINGS;LUADLLBUILDTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 112 | true 113 | NotUsing 114 | pch.h 115 | stdcpp20 116 | C:\VSProjects\DataContainer\CommonIncludes;%(AdditionalIncludeDirectories) 117 | 118 | 119 | Windows 120 | true 121 | false 122 | 123 | 124 | 125 | 126 | Level3 127 | true 128 | true 129 | true 130 | _CRT_SECURE_NO_WARNINGS;NDEBUG;LUADLLBUILDTEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 131 | true 132 | NotUsing 133 | pch.h 134 | stdcpp20 135 | C:\VSProjects\DataContainer\CommonIncludes;%(AdditionalIncludeDirectories) 136 | 137 | 138 | Windows 139 | true 140 | true 141 | true 142 | false 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | $(SolutionDir)$(Platform)\$(Configuration)\LuaDLLGenerator objs.txt 156 | $(SolutionDir)$(Platform)\$(Configuration)\LuaDLLGenerator objs.txt 157 | lua_objs.hpp 158 | ClInclude 159 | lua_objs.hpp 160 | ClInclude 161 | 162 | 163 | 164 | 165 | 166 | --------------------------------------------------------------------------------