10#include <boost/interprocess/offset_ptr.hpp>
37 : m_name(
name), m_p(
name.empty() ? nullptr :
shm<T>::find_and_ref(
name))
42 explicit shm_array_ref(
const std::vector<typename T::value_type> &data);
45 shm_array_ref(
const typename T::value_type *data,
size_t size);
62 m_name = std::string();
65 template<
typename... Args>
75 assert(!m_name.
empty());
85 template<
typename... Args>
92 assert(!m_name.
empty());
95 assert(m_p->refcount() == 1);
110 bool valid()
const {
return !!m_p; }
112 operator bool()
const {
return valid(); }
126 assert(!m_name.
empty());
127 assert(m_p->refcount() >= 0);
135 assert(!m_name.
empty());
136 assert(m_p->refcount() > 0);
138 if (m_p->unref() == 0) {
150 boost::interprocess::offset_ptr<T> m_p;
154 template<
class Archive>
155 void save(Archive &ar)
const;
156 template<
class Archive>
157 void load(Archive &ar);
161#ifdef USE_BOOST_ARCHIVE
163#define V_DECLARE_SHMREF(T) \
164 extern template class V_COREEXPORT shm_array_ref<shm_array<T, typename shm<T>::allocator>>; \
165 extern template void V_COREEXPORT \
166 shm_array_ref<shm_array<T, typename shm<T>::allocator>>::load<vistle::yas_iarchive>(vistle::yas_iarchive & \
168 extern template void V_COREEXPORT \
169 shm_array_ref<shm_array<T, typename shm<T>::allocator>>::load<vistle::boost_iarchive>(vistle::boost_iarchive & \
171 extern template void V_COREEXPORT \
172 shm_array_ref<shm_array<T, typename shm<T>::allocator>>::save<vistle::yas_oarchive>(vistle::yas_oarchive & ar) \
174 extern template void V_COREEXPORT \
175 shm_array_ref<shm_array<T, typename shm<T>::allocator>>::save<vistle::boost_oarchive>(vistle::boost_oarchive & \
178#define V_DEFINE_SHMREF(T) \
179 template class shm_array_ref<shm_array<T, typename shm<T>::allocator>>; \
180 template void shm_array_ref<shm_array<T, typename shm<T>::allocator>>::load<vistle::yas_iarchive>( \
181 vistle::yas_iarchive & ar); \
182 template void shm_array_ref<shm_array<T, typename shm<T>::allocator>>::load<vistle::boost_iarchive>( \
183 vistle::boost_iarchive & ar); \
184 template void shm_array_ref<shm_array<T, typename shm<T>::allocator>>::save<vistle::yas_oarchive>( \
185 vistle::yas_oarchive & ar) const; \
186 template void shm_array_ref<shm_array<T, typename shm<T>::allocator>>::save<vistle::boost_oarchive>( \
187 vistle::boost_oarchive & ar) const;
189#define V_DECLARE_SHMREF(T) \
190 extern template class V_COREEXPORT shm_array_ref<shm_array<T, typename shm<T>::allocator>>; \
191 extern template void V_COREEXPORT \
192 shm_array_ref<shm_array<T, typename shm<T>::allocator>>::load<vistle::boost_iarchive>(vistle::boost_iarchive & \
194 extern template void V_COREEXPORT \
195 shm_array_ref<shm_array<T, typename shm<T>::allocator>>::save<vistle::boost_oarchive>(vistle::boost_oarchive & \
198#define V_DEFINE_SHMREF(T) \
199 template class shm_array_ref<shm_array<T, typename shm<T>::allocator>>; \
200 template void shm_array_ref<shm_array<T, typename shm<T>::allocator>>::load<vistle::boost_iarchive>( \
201 vistle::boost_iarchive & ar); \
202 template void shm_array_ref<shm_array<T, typename shm<T>::allocator>>::save<vistle::boost_oarchive>( \
203 vistle::boost_oarchive & ar) const;
206#define V_DECLARE_SHMREF(T) \
207 extern template class V_COREEXPORT shm_array_ref<shm_array<T, typename shm<T>::allocator>>; \
208 extern template void V_COREEXPORT \
209 shm_array_ref<shm_array<T, typename shm<T>::allocator>>::load<vistle::yas_iarchive>(vistle::yas_iarchive & \
211 extern template void V_COREEXPORT \
212 shm_array_ref<shm_array<T, typename shm<T>::allocator>>::save<vistle::yas_oarchive>(vistle::yas_oarchive & ar) \
215#define V_DEFINE_SHMREF(T) \
216 template class shm_array_ref<shm_array<T, typename shm<T>::allocator>>; \
217 template void shm_array_ref<shm_array<T, typename shm<T>::allocator>>::load<vistle::yas_iarchive>( \
218 vistle::yas_iarchive & ar); \
219 template void shm_array_ref<shm_array<T, typename shm<T>::allocator>>::save<vistle::yas_oarchive>( \
220 vistle::yas_oarchive & ar) const;
#define ARCHIVE_ACCESS_SPLIT
Definition: archives_config.h:502
std::string createArrayId(const std::string &name="")
Definition: shm.cpp:460
const void_allocator & allocator() const
Definition: shm.cpp:310
void addArray(const std::string &name, const ShmData *array)
Definition: shm.cpp:510
static Shm & the()
Definition: shm.cpp:315
Definition: allocator.h:12
Definition: shm_reference.h:15
bool valid() const
Definition: shm_reference.h:110
T * operator->()
Definition: shm_reference_impl.h:101
T & operator*()
Definition: shm_reference_impl.h:89
shm_array_ref(const shm_array_ref &other)
Definition: shm_reference.h:28
const shm_name_t & name() const
Definition: shm_reference_impl.h:129
bool find()
Definition: shm_reference.h:73
~shm_array_ref()
Definition: shm_reference.h:47
shm_array_ref()
Definition: shm_reference.h:17
const shm_array_ref & operator=(const shm_array_ref &rhs)
Definition: shm_reference.h:99
void ref()
Definition: shm_reference.h:123
shm_array_ref(const shm_name_t name)
Definition: shm_reference.h:36
void construct(const Args &...args)
Definition: shm_reference.h:86
void unref()
Definition: shm_reference.h:132
int refcount() const
Definition: shm_reference_impl.h:121
static shm_array_ref create(const Args &...args)
Definition: shm_reference.h:66
void reset()
Definition: shm_reference.h:55
shm_array_ref(const std::string &name, T *p)
Definition: shm_reference.h:26
Definition: allobjects.cpp:30
#define V_DECLARE_SHMREF(T)
Definition: shm_reference.h:206
bool empty() const
Definition: shmname.cpp:48
static bool destroy_array(const std::string &name, array_ptr arr)
Definition: shm.h:302
static T * find_and_ref(const std::string &name)
Definition: shm.h:255
static managed_shm::segment_manager::template construct_proxy< T >::type construct(const std::string &name)
Definition: shm_impl.h:87