1 // Boost.Geometry Index
2 // Unit Test
3
4 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
5
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9
10 #include <rtree/test_rtree.hpp>
11
12 #include <boost/geometry/geometries/point.hpp>
13 #include <boost/geometry/geometries/box.hpp>
14
15 #include <boost/interprocess/managed_shared_memory.hpp>
16 #include <boost/interprocess/allocators/allocator.hpp>
17
18 template <typename Point, typename Parameters>
test_rtree_interprocess(Parameters const & parameters=Parameters ())19 void test_rtree_interprocess(Parameters const& parameters = Parameters())
20 {
21 namespace bi = boost::interprocess;
22 struct shm_remove
23 {
24 shm_remove() { bi::shared_memory_object::remove("shmem"); }
25 ~shm_remove(){ bi::shared_memory_object::remove("shmem"); }
26 } remover;
27
28 bi::managed_shared_memory segment(bi::create_only, "shmem", 65535);
29 typedef bi::allocator<Point, bi::managed_shared_memory::segment_manager> shmem_alloc;
30
31 test_rtree_for_box<Point>(parameters, shmem_alloc(segment.get_segment_manager()));
32 }
33
34 namespace testset { namespace interprocess {
35
36 template <typename Indexable, typename Parameters>
modifiers(Parameters const & parameters=Parameters ())37 void modifiers(Parameters const& parameters = Parameters())
38 {
39 namespace bi = boost::interprocess;
40 struct shm_remove
41 {
42 shm_remove() { bi::shared_memory_object::remove("shmem"); }
43 ~shm_remove(){ bi::shared_memory_object::remove("shmem"); }
44 } remover;
45
46 bi::managed_shared_memory segment(bi::create_only, "shmem", 65535);
47 typedef bi::allocator<Indexable, bi::managed_shared_memory::segment_manager> shmem_alloc;
48
49 testset::modifiers<Indexable>(parameters, shmem_alloc(segment.get_segment_manager()));
50 }
51
52 template <typename Indexable, typename Parameters>
queries(Parameters const & parameters=Parameters ())53 void queries(Parameters const& parameters = Parameters())
54 {
55 namespace bi = boost::interprocess;
56 struct shm_remove
57 {
58 shm_remove() { bi::shared_memory_object::remove("shmem"); }
59 ~shm_remove(){ bi::shared_memory_object::remove("shmem"); }
60 } remover;
61
62 bi::managed_shared_memory segment(bi::create_only, "shmem", 65535);
63 typedef bi::allocator<Indexable, bi::managed_shared_memory::segment_manager> shmem_alloc;
64
65 testset::queries<Indexable>(parameters, shmem_alloc(segment.get_segment_manager()));
66 }
67
68 template <typename Indexable, typename Parameters>
additional(Parameters const & parameters=Parameters ())69 void additional(Parameters const& parameters = Parameters())
70 {
71 namespace bi = boost::interprocess;
72 struct shm_remove
73 {
74 shm_remove() { bi::shared_memory_object::remove("shmem"); }
75 ~shm_remove(){ bi::shared_memory_object::remove("shmem"); }
76 } remover;
77
78 bi::managed_shared_memory segment(bi::create_only, "shmem", 65535);
79 typedef bi::allocator<Indexable, bi::managed_shared_memory::segment_manager> shmem_alloc;
80
81 testset::additional<Indexable>(parameters, shmem_alloc(segment.get_segment_manager()));
82 }
83
84 template <typename Indexable, typename Parameters>
modifiers_and_additional(Parameters const & parameters=Parameters ())85 void modifiers_and_additional(Parameters const& parameters = Parameters())
86 {
87 namespace bi = boost::interprocess;
88 struct shm_remove
89 {
90 shm_remove() { bi::shared_memory_object::remove("shmem"); }
91 ~shm_remove(){ bi::shared_memory_object::remove("shmem"); }
92 } remover;
93
94 bi::managed_shared_memory segment(bi::create_only, "shmem", 65535);
95 typedef bi::allocator<Indexable, bi::managed_shared_memory::segment_manager> shmem_alloc;
96
97 testset::modifiers<Indexable>(parameters, shmem_alloc(segment.get_segment_manager()));
98 testset::additional<Indexable>(parameters, shmem_alloc(segment.get_segment_manager()));
99 }
100
101 }}
102