Debian Codegraph @

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