Debian Codegraph @

examples/ExtDerivedBIO.hh

raw
1 #ifndef GSEXAMPLE_EXTDERIVEDBIO_HH_
2 #define GSEXAMPLE_EXTDERIVEDBIO_HH_
3
4 // The header for the class which we need to wrap
5 #include "ExtDerivedB.hh"
6
7 // The header for the I/O factory
8 #include "ExtBaseIO.hh"
9
10 // Read/write wrapper for class ExtDerivedB.
11 // Note publication of ExtDerivedB as "wrapped_type".
12 struct ExtDerivedBIO : public gs::AbsReaderWriter<ExtBase>
13 {
14 typedef ExtDerivedB wrapped_type;
15
16 // Methods that have to be overriden from the base
17 bool write(std::ostream&, const wrapped_base&, bool dumpId) const override;
18 wrapped_type* read(const gs::ClassId& id, std::istream& in) const override;
19
20 // The class id for ExtDerivedB will be needed both in the "read" and
21 // in the "write" methods. Because of this, we will just return it from
22 // one static function.
23 static const gs::ClassId& wrappedClassId();
24 };
25
26 // Operators checking for equality (useful for I/O testing)
27 inline bool operator==(const ExtDerivedB& l, const ExtDerivedB& r)
28 {
29 return l.getValue() == r.getValue() && l.getAnother() == r.getAnother();
30 }
31
32 inline bool operator!=(const ExtDerivedB& l, const ExtDerivedB& r)
33 {
34 return !(l == r);
35 }
36
37 // Call the necessary macros to register the ExtDerivedB class with Geners
38 gs_specialize_class_id(ExtDerivedB, 1)
39 gs_declare_type_external(ExtDerivedB)
40 gs_associate_serialization_factory(ExtDerivedB, StaticIOFactoryForExtBase)
41
42 #endif // GSEXAMPLE_EXTDERIVEDBIO_HH_