Warning, file /include/boost/interprocess/sync/shm/named_creation_functor.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_SYNC_NAMED_CREATION_FUNCTOR_HPP
0012 #define BOOST_INTERPROCESS_SYNC_NAMED_CREATION_FUNCTOR_HPP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 0018 ">#
0019 #if defined(BOOST_HAS_PRAGMA_ONCE)
0020 # pragma once
0021 #endif
0022
0023 #include <boost/interprocess/creation_tags.hpp>
0024 #include <boost/interprocess/detail/type_traits.hpp>
0025 #include <boost/interprocess/detail/mpl.hpp>
0026 #include <boost/container/detail/placement_new.hpp>
0027
0028 namespace boost {
0029 namespace interprocess {
0030 namespace ipcdetail {
0031
0032 struct named_creation_functor_no_arg{};
0033
0034 template <class T, class Arg = named_creation_functor_no_arg>
0035 class named_creation_functor
0036 {
0037 typedef named_creation_functor_no_arg no_arg_t;
0038 public:
0039 named_creation_functor(create_enum_t type, Arg arg = Arg())
0040 : m_creation_type(type), m_arg(arg){}
0041
0042 template<class ArgType>
0043 void construct(void *address, typename enable_if_c<is_same<ArgType, no_arg_t>::value>::type * = 0) const
0044 { ::new(address, boost_container_new_t())T; }
0045
0046 template<class ArgType>
0047 void construct(void *address, typename enable_if_c<!is_same<ArgType, no_arg_t>::value>::type * = 0) const
0048 { ::new(address, boost_container_new_t())T(m_arg); }
0049
0050 bool operator()(void *address, std::size_t, bool created) const
0051 {
0052 switch(m_creation_type){
0053 case DoOpen:
0054 return true;
0055 break;
0056 case DoCreate:
0057 case DoOpenOrCreate:
0058 if(created){
0059 construct<Arg>(address);
0060 }
0061 return true;
0062 break;
0063
0064 default:
0065 return false;
0066 break;
0067 }
0068 }
0069
0070 static std::size_t get_min_size()
0071 { return sizeof(T); }
0072
0073 private:
0074 create_enum_t m_creation_type;
0075 Arg m_arg;
0076 };
0077
0078 }
0079 }
0080 }
0081
0082 #endif