| 1 |
#ifndef GSEXAMPLE_EXTDERIVEDAIO_HH_ |
| 2 |
#define GSEXAMPLE_EXTDERIVEDAIO_HH_ |
| 3 |
|
| 4 |
// The header for the class which we need to wrap |
| 5 |
#include "ExtDerivedA.hh" |
| 6 |
|
| 7 |
// The header for the I/O factory |
| 8 |
#include "ExtBaseIO.hh" |
| 9 |
|
| 10 |
// Read/write wrapper for class ExtDerivedA. |
| 11 |
// Note publication of ExtDerivedA as "wrapped_type". |
| 12 |
struct ExtDerivedAIO : public gs::AbsReaderWriter<ExtBase> |
| 13 |
{ |
| 14 |
typedef ExtDerivedA 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 ExtDerivedA 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 ExtDerivedA& l, const ExtDerivedA& r) |
| 28 |
{ |
| 29 |
return l.getValue() == r.getValue(); |
| 30 |
} |
| 31 |
|
| 32 |
inline bool operator!=(const ExtDerivedA& l, const ExtDerivedA& r) |
| 33 |
{ |
| 34 |
return !(l == r); |
| 35 |
} |
| 36 |
|
| 37 |
// Call the necessary macros to register the ExtDerivedA class with Geners |
| 38 |
gs_specialize_class_id(ExtDerivedA, 1) |
| 39 |
gs_declare_type_external(ExtDerivedA) |
| 40 |
gs_associate_serialization_factory(ExtDerivedA, StaticIOFactoryForExtBase) |
| 41 |
|
| 42 |
#endif // GSEXAMPLE_EXTDERIVEDAIO_HH_ |