Debian Codegraph @

examples/SerializableBaseReader.cc

raw
1 #include "SerializableBaseReader.hh"
2
3 // Include headers for all classes derived from SerializableBase
4 // which are known at this point in code development
5 #include "SerializableDerivedA.hh"
6 #include "SerializableDerivedB.hh"
7
8 // Simple macro for adding a reader for a class derived from SerializableBase
9 #define add_reader(Derived) do { \
10 const gs::ClassId& id(gs::ClassId::makeId<Derived >()); \
11 (*this)[id.name()] = new gs::ConcreteReader<SerializableBase,Derived >(); \
12 } while(0);
13
14 // Instead of adding each reader directly, you might be tempted
15 // to invoke the "registerClass" method of the associated static
16 // reader. Don't do that! Such a call will result in a recursive
17 // invocation of the singleton's "instance()" method -- this is
18 // something we really have to avoid.
19 //
20 SerializableBaseReader::SerializableBaseReader()
21 {
22 add_reader(SerializableDerivedA);
23 add_reader(SerializableDerivedB);
24 }