2 #ifndef vbl_io_smart_ptr_hxx_ 3 #define vbl_io_smart_ptr_hxx_ 13 #include <vsl/vsl_binary_io.h> 16 # include <vcl_msvc_warnings.h> 25 constexpr
short io_version_no = 2;
29 if (p.
ptr() ==
nullptr)
38 unsigned long id = os.get_serial_number(p.
ptr());
56 std::cerr <<
"vsl_b_write(vsl_b_ostream & os, const vbl_smart_ptr<T>&):" 57 <<
" You cannot\nsave unprotected smart pointers before saving" 58 <<
" a protected smart pointer\nto the same object. Either do" 59 <<
" not save unprotected smart pointers, or\nbe very careful" 60 <<
" about the order.\n";
64 id = os.add_serialisation_record(p.
ptr());
111 if (first_time && !is_protected)
113 std::cerr <<
"I/O ERROR: vsl_b_read(vsl_b_istream&, vbl_smart_ptr<T>&)\n" 114 <<
" De-serialisation failure of non-protected smart_ptr\n";
115 is.is().clear(std::ios::badbit);
127 T * pointer = static_cast<T *>( is.get_serialisation_pointer(
id));
128 if (first_time != (pointer ==
nullptr))
133 std::cerr <<
"I/O ERROR: vsl_b_read(vsl_b_istream&, vbl_smart_ptr<T>&)\n" 134 <<
" De-serialisation failure\n";
135 is.is().clear(std::ios::badbit);
139 if (pointer ==
nullptr)
145 is.add_serialisation_record(
id, pointer);
156 std::cerr <<
"I/O ERROR: vsl_b_read(vsl_b_istream&, vbl_smart_ptr<T>&)\n" 157 <<
" Unknown version number "<< ver <<
'\n';
158 is.is().clear(std::ios::badbit);
170 os <<
"Smart ptr to ";
183 #undef VBL_IO_SMART_PTR_INSTANTIATE 184 #define VBL_IO_SMART_PTR_INSTANTIATE(T) \ 185 template void vsl_print_summary(std::ostream &, const vbl_smart_ptr<T > &); \ 186 template void vsl_b_read(vsl_b_istream &, vbl_smart_ptr<T > &); \ 187 template void vsl_b_write(vsl_b_ostream &, const vbl_smart_ptr<T > &) 189 #endif // vbl_io_smart_ptr_hxx_ Serialised binary IO functions for vbl_smart_ptr<T>
bool is_protected() const
Is this smart pointer responsible for the object being pointed to.
void unprotect()
Used for breaking circular references (see above).
A templated smart pointer class.
void vsl_print_summary(std::ostream &os, const vbl_smart_ptr< T > &p)
Output a human readable summary to the stream.
Contains a templated smart pointer class.
void vsl_b_write(vsl_b_ostream &os, const vbl_smart_ptr< T > &p)
Binary save self to stream.
void vsl_b_read(vsl_b_istream &is, vbl_smart_ptr< T > &p)
Binary load self from stream.
T * ptr() const
These methods all return the raw/dumb pointer.