]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/index/test/rtree/rtree_test_generator.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / index / test / rtree / rtree_test_generator.cpp
1 // Boost.Geometry Index
2 // Rtree tests generator
3
4 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
5
6 // This file was modified by Oracle on 2021.
7 // Modifications copyright (c) 2021, Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
13
14 #include <fstream>
15 #include <vector>
16 #include <string>
17 #include <boost/assert.hpp>
18 #include <boost/tuple/tuple.hpp>
19
20 int main()
21 {
22 typedef boost::tuple<std::string, std::string> CT;
23 std::vector<CT> coordinate_types;
24 coordinate_types.push_back(boost::make_tuple("double", "d"));
25 //coordinate_types.push_back(boost::make_tuple("int", "i"));
26 //coordinate_types.push_back(boost::make_tuple("float", "f"));
27
28 std::vector<std::string> dimensions;
29 dimensions.push_back("2");
30 dimensions.push_back("3");
31
32 typedef boost::tuple<std::string, std::string> P;
33 std::vector<P> parameters;
34 parameters.push_back(boost::make_tuple("bgi::linear<5, 2>()", "lin"));
35 parameters.push_back(boost::make_tuple("bgi::dynamic_linear(5, 2)", "dlin"));
36 parameters.push_back(boost::make_tuple("bgi::quadratic<5, 2>()", "qua"));
37 parameters.push_back(boost::make_tuple("bgi::dynamic_quadratic(5, 2)", "dqua"));
38 parameters.push_back(boost::make_tuple("bgi::rstar<5, 2>()", "rst"));
39 parameters.push_back(boost::make_tuple("bgi::dynamic_rstar(5, 2)","drst"));
40
41 std::vector<std::string> indexables;
42 indexables.push_back("p");
43 indexables.push_back("b");
44 indexables.push_back("s");
45
46 typedef std::pair<std::string, std::string> TS;
47 std::vector<TS> testsets;
48 testsets.push_back(std::make_pair("testset::modifiers", "mod"));
49 testsets.push_back(std::make_pair("testset::queries", "que"));
50 testsets.push_back(std::make_pair("testset::additional", "add"));
51
52 for (P const& p : parameters)
53 {
54 for (TS const& ts : testsets)
55 {
56 for (std::string const& i : indexables)
57 {
58 for (std::string const& d : dimensions)
59 {
60 // If the I is Segment, generate only for 2d
61 if ( i == "s" && d != "2" )
62 {
63 continue;
64 }
65
66 for (CT const& c : coordinate_types)
67 {
68 std::string filename = std::string() +
69 "rtree_" + boost::get<1>(p) + '_' + ts.second + '_' + i + d + boost::get<1>(c) + ".cpp";
70
71 std::ofstream f(filename.c_str(), std::ios::trunc);
72
73 f <<
74 "// Boost.Geometry Index\n" <<
75 "// Unit Test\n" <<
76 "\n" <<
77 "// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.\n" <<
78 "\n" <<
79 "// Use, modification and distribution is subject to the Boost Software License,\n" <<
80 "// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at\n" <<
81 "// http://www.boost.org/LICENSE_1_0.txt)\n" <<
82 "\n";
83
84 f <<
85 "#include <rtree/test_rtree.hpp>\n" <<
86 "\n";
87
88 std::string indexable_type;
89 std::string point_type = std::string("bg::model::point<") + boost::get<0>(c) + ", " + d + ", bg::cs::cartesian>";
90 if ( i == "p" )
91 indexable_type = point_type;
92 else if ( i == "b" )
93 indexable_type = std::string("bg::model::box< ") + point_type + " >";
94 else if ( i == "s" )
95 indexable_type = std::string("bg::model::segment< ") + point_type + " >";
96 else
97 BOOST_ASSERT(false);
98
99 f <<
100 "int test_main(int, char* [])\n" <<
101 "{\n" <<
102 " typedef " << indexable_type << " Indexable;\n" <<
103 " " << ts.first << "<Indexable>(" << boost::get<0>(p) << ", std::allocator<int>());\n" <<
104 " return 0;\n" <<
105 "}\n";
106 }
107 }
108 }
109
110 }
111 }
112
113 return 0;
114 }