vbl_io_smart_ptr.h
Go to the documentation of this file.
1 // This is core/vbl/io/vbl_io_smart_ptr.h
2 #ifndef vbl_io_smart_ptr_h
3 #define vbl_io_smart_ptr_h
4 //:
5 // \file
6 // \brief Serialised binary IO functions for vbl_smart_ptr<T>
7 // \author Ian Scott (Manchester)
8 // \date 26-Mar-2001
9 //
10 // In order to use IO for smart pointers you will need to have
11 // the IO functions defined for pointers to MY_CLASS (class T.)
12 // If you have written I/O for polymorphic classes, some of these
13 // functions may already be defined.
14 //
15 // If you need to write them, you can use the following as examples
16 // \code
17 // void vsl_b_read(vsl_b_istream& is, impl * &p)
18 // {
19 // delete p;
20 // bool not_null_ptr;
21 // vsl_b_read(is, not_null_ptr);
22 // if (not_null_ptr)
23 // {
24 // p = new MY_CLASS();
25 // vsl_b_read(is, *p);
26 // }
27 // else
28 // p = 0;
29 // }
30 //
31 // void vsl_b_write(vsl_b_ostream& os, const MY_CLASS *p)
32 // {
33 // if (p==0)
34 // {
35 // vsl_b_write(os, false); // Indicate null pointer stored
36 // }
37 // else
38 // {
39 // vsl_b_write(os,true); // Indicate non-null pointer stored
40 // vsl_b_write(os,*p);
41 // }
42 // }
43 //
44 // void vsl_print_summary(std::ostream& os, const MY_CLASS *p)
45 // {
46 // if (p==0)
47 // os << "NULL PTR";
48 // else
49 // {http://www.isbe.man.ac.uk/internal/software/c++/vxl-doxygen/
50 // vcl/html/class_vcl_not_equal_to.html
51 // os << "T: ";
52 // vsl_print_summary(os, *p);
53 // }
54 // }
55 // \endcode
56 //
57 // Objects using I/O via a smart ptr, should not save the objects reference count.
58 
59 #include <iosfwd>
60 #include <vsl/vsl_fwd.h>
61 #include <vbl/vbl_smart_ptr.h>
62 #ifdef _MSC_VER
63 # include <vcl_msvc_warnings.h>
64 #endif
65 
66 //: Binary save vbl_smart_ptr to stream.
67 template <class T>
68 void vsl_b_write(vsl_b_ostream & os, const vbl_smart_ptr<T> & v);
69 
70 //: Binary load vbl_smart_ptr from stream.
71 template <class T>
72 void vsl_b_read(vsl_b_istream & is, vbl_smart_ptr<T> & v);
73 
74 //: Print human readable summary of object to a stream
75 template <class T>
76 void vsl_print_summary(std::ostream & os,const vbl_smart_ptr<T> & b);
77 
78 #endif // vbl_io_smart_ptr_h
void vsl_b_write(vsl_b_ostream &os, const vbl_smart_ptr< T > &v)
Binary save vbl_smart_ptr to stream.
A templated smart pointer class.
Definition: vbl_fwd.h:18
Contains a templated smart pointer class.
void vsl_b_read(vsl_b_istream &is, vbl_smart_ptr< T > &v)
Binary load vbl_smart_ptr from stream.
void vsl_print_summary(std::ostream &os, const vbl_smart_ptr< T > &b)
Print human readable summary of object to a stream.