8#ifndef FIND_OBJECT_REFERENCE_OARCHIVE_H
9#define FIND_OBJECT_REFERENCE_OARCHIVE_H
13#ifdef USE_INTROSPECTION_ARCHIVE
17#include <boost/config.hpp>
18#include <boost/type_traits/is_enum.hpp>
19#include <boost/mpl/bool.hpp>
20#include <boost/mpl/eval_if.hpp>
21#include <boost/mpl/int.hpp>
22#include <boost/mpl/equal_to.hpp>
23#include <boost/serialization/nvp.hpp>
24#include <boost/serialization/array.hpp>
25#include <boost/serialization/string.hpp>
26#include <boost/serialization/vector.hpp>
27#include <boost/serialization/access.hpp>
28#include <boost/serialization/version.hpp>
51 enum ReferenceType {
ShmVector, ObjectReference };
57 std::vector<ReferenceData> m_referenceDataVector;
58 std::string m_currNvpTag;
62 template<
class Archive>
63 struct save_enum_type;
65 template<
class Archive>
66 struct save_primitive;
68 template<
class Archive>
73 void save(
const T &t);
77 typedef boost::mpl::bool_<false> is_loading;
78 typedef boost::mpl::bool_<true> is_saving;
81 void register_type(
const T * = NULL)
84 unsigned int get_library_version() {
return 0; }
85 void save_binary(
const void *address, std::size_t count) {}
90 FindObjectReferenceOArchive &
operator<<(T
const &t);
92 FindObjectReferenceOArchive &
operator<<(T *
const t);
93 template<
class T,
int N>
94 FindObjectReferenceOArchive &
operator<<(
const T (&t)[N]);
96 FindObjectReferenceOArchive &
operator<<(
const boost::serialization::nvp<T> &t);
104 FindObjectReferenceOArchive &operator&(
const T &t);
107 FindObjectReferenceOArchive(): m_indexHint(0) {}
110 std::vector<ReferenceData> &getVector() {
return m_referenceDataVector; }
111 ReferenceData *getVectorEntryByNvpName(std::string name);
114 static const std::string nullObjectReferenceName;
132struct FindObjectReferenceOArchive::ReferenceData {
134 std::string referenceName;
135 FindObjectReferenceOArchive::ReferenceType referenceType;
138 ReferenceData(std::string _nvpName, std::string _referenceName,
139 FindObjectReferenceOArchive::ReferenceType _referenceType,
void *_ref)
140 : nvpName(_nvpName), referenceName(_referenceName), referenceType(_referenceType), ref(_ref)
146template<
class Archive>
147struct FindObjectReferenceOArchive::save_enum_type {
149 static void invoke(Archive &ar,
const T &t)
159template<
class Archive>
160struct FindObjectReferenceOArchive::save_primitive {
162 static void invoke(Archive &ar,
const T &t)
173template<
class Archive>
174struct FindObjectReferenceOArchive::save_only {
176 static void invoke(Archive &ar,
const T &t)
179 boost::serialization::serialize_adl(ar,
const_cast<T &
>(t), ::boost::serialization::version<T>::value);
189void FindObjectReferenceOArchive::save(
const T &t)
191 typedef BOOST_DEDUCED_TYPENAME
192 boost::mpl::eval_if<boost::is_enum<T>, boost::mpl::identity<save_enum_type<FindObjectReferenceOArchive>>,
194 BOOST_DEDUCED_TYPENAME boost::mpl::eval_if<
196 boost::mpl::equal_to<boost::serialization::implementation_level<T>,
197 boost::mpl::int_<boost::serialization::primitive_type>>,
198 boost::mpl::identity<save_primitive<FindObjectReferenceOArchive>>,
200 boost::mpl::identity<save_only<FindObjectReferenceOArchive>>>>::type typex;
201 typex::invoke(*
this, t);
229template<
class T,
int N>
240 m_currNvpTag = t.name();
242 return *
this << t.value();
254 m_referenceDataVector.push_back(
267 m_referenceDataVector.push_back(
268 ReferenceData(m_currNvpTag, obj->getName(), ReferenceType::ObjectReference, &t));
270 m_referenceDataVector.push_back(
271 ReferenceData(m_currNvpTag, nullObjectReferenceName, ReferenceType::ObjectReference, &t));
281FindObjectReferenceOArchive &FindObjectReferenceOArchive::operator&(
const T &t)
Definition: shm_reference.h:15
const shm_name_t & name() const
Definition: shm_reference_impl.h:129
Definition: shm_obj_ref.h:15
ObjType::const_ptr getObject() const
Definition: shm_obj_ref_impl.h:110
#define V_COREEXPORT
Definition: export.h:9
V_COREEXPORT std::ostream & operator<<(std::ostream &s, const Message &msg)
Definition: messages.cpp:1718
Definition: allobjects.cpp:30
std::ostream & operator<<(std::ostream &out, const Meta &meta)
Definition: objectmeta.cpp:45
shm_array_ref< shm_array< T, typename shm< T >::allocator > > ShmVector
Definition: shm.h:127
std::array< char, 32 > name
Definition: shmname.h:12