1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #include <boost/config.hpp>
15 #include <boost/interprocess/windows_shared_memory.hpp>
16 #include <boost/interprocess/detail/managed_open_or_create_impl.hpp>
17 #include <boost/interprocess/exceptions.hpp>
18 #include "named_creation_template.hpp"
19 #include <cstring> //for strcmp, memset
20 #include <iostream> //for cout
21 #include <string> //for string
22 #include "get_process_id_name.hpp"
24 using namespace boost::interprocess
;
26 static const char *name_initialization_routine()
28 static std::string process_name
;
29 test::get_process_id_name(process_name
);
30 return process_name
.c_str();
33 static const std::size_t ShmSize
= 1000;
34 typedef ipcdetail::managed_open_or_create_impl
35 <windows_shared_memory
, 0, false, false> windows_shared_memory_t
;
37 //This wrapper is necessary to have a common constructor
38 //in generic named_creation_template functions
39 class shared_memory_creation_test_wrapper
40 : public windows_shared_memory_t
43 shared_memory_creation_test_wrapper(create_only_t
)
44 : windows_shared_memory_t(create_only
, name_initialization_routine(), ShmSize
, read_write
, 0, permissions())
47 shared_memory_creation_test_wrapper(open_only_t
)
48 : windows_shared_memory_t(open_only
, name_initialization_routine(), read_write
, 0)
51 shared_memory_creation_test_wrapper(open_or_create_t
)
52 : windows_shared_memory_t(open_or_create
, name_initialization_routine(), ShmSize
, read_write
, 0, permissions())
60 test::test_named_creation
<shared_memory_creation_test_wrapper
>();
62 catch(std::exception
&ex
){
63 std::cout
<< ex
.what() << std::endl
;
77 #endif //#ifdef BOOST_WINDOWS