1#ifndef VISTLE_SHM_OBJ_REF_IMPL_H
2#define VISTLE_SHM_OBJ_REF_IMPL_H
41template<
typename... Args>
60template<
typename... Args>
85 m_name = rhs->getName();
99 *
this = std::const_pointer_cast<const ObjType>(rhs);
106 return m_name.empty() || m_d;
114 typedef typename shm_obj_ref<T>::ObjType ObjType;
115 return typename ObjType::const_ptr(
116 dynamic_cast<ObjType *
>(
Object::create(
const_cast<typename ObjType::Data *
>(&*m_d))));
137 assert(m_name == m_d->name);
138 assert(m_d->refcount() >= 0);
144void shm_obj_ref<T>::unref()
147 assert(m_d->refcount() > 0);
160template<
class Archive>
163 ar &
V_NAME(ar,
"obj_name", m_name);
166 ar.saveObject(*
this);
170template<
class Archive>
174 ar &
V_NAME(ar,
"obj_name", shmname);
175 std::string arname = shmname;
177 std::string name = ar.translateObjectName(arname);
184 if (arname.empty() && m_name.empty())
187 auto obj = ar.currentObject();
188 auto handler = ar.objectCompletionHandler();
190 auto ref1 = T::as(ref0);
191 assert(ref0 || !ref1);
198 obj->unresolvedReference();
199 auto fetcher = ar.fetcher();
200 ref0 = ar.getObject(arname, [
this, fetcher, arname, name, obj, handler](
Object::const_ptr newobj) ->
void {
203 auto ref2 = T::as(newobj);
206 m_name = newobj->getName();
208 fetcher->registerObjectNameTranslation(arname, m_name);
210 auto ref2 = T::as(
Shm::the().getObjectFromName(name));
214 m_name = ref2->getName();
215 ar.registerObjectNameTranslation(arname, m_name);
219 obj->referenceResolved(handler);
223 assert(ref0 || !ref1);
225 m_name = ref1->getName();
226 ar.registerObjectNameTranslation(arname, m_name);
#define V_NAME(ar, name, obj)
Definition: archives_config.h:441
std::shared_ptr< const Object > const_ptr
Definition: object.h:68
static Object * create(Data *)
Definition: object.cpp:132
std::shared_ptr< const Object > getObjectFromName(const std::string &name, bool onlyComplete=true) const
Definition: shm.cpp:608
std::string createObjectId(const std::string &name="")
Definition: shm.cpp:435
const void_allocator & allocator() const
Definition: shm.cpp:310
static Shm & the()
Definition: shm.cpp:315
Definition: shm_obj_ref.h:15
bool find()
Definition: shm_obj_ref_impl.h:50
const ObjType::Data * getData() const
Definition: shm_obj_ref_impl.h:120
static shm_obj_ref create(const Args &...args)
const shm_obj_ref & operator=(const shm_obj_ref &rhs)
Definition: shm_obj_ref_impl.h:71
bool valid() const
Definition: shm_obj_ref_impl.h:104
ObjType::const_ptr getObject() const
Definition: shm_obj_ref_impl.h:110
~shm_obj_ref()
Definition: shm_obj_ref_impl.h:35
const shm_name_t & name() const
Definition: shm_obj_ref_impl.h:128
void construct(const Args &...args)
Definition: shm_obj_ref_impl.h:61
shm_obj_ref()
Definition: shm_obj_ref_impl.h:11
Definition: allobjects.cpp:30
static T * find(const std::string &name)
Definition: shm.h:237
static managed_shm::segment_manager::template construct_proxy< T >::type construct(const std::string &name)
Definition: shm_impl.h:87