Debian Codegraph @

tests/SerializableDerivedC.hh

raw
1 #ifndef GSTEST_SERIALIZABLEDERIVEDC_HH_
2 #define GSTEST_SERIALIZABLEDERIVEDC_HH_
3
4 #include <iostream>
5
6 #include "SerializableDerivedB.hh"
7
8 class SerializableDerivedC : public SerializableDerivedB
9 {
10 public:
11 inline SerializableDerivedC(const unsigned u, const double d)
12 : SerializableDerivedB(d), u_(u) {}
13
14 inline ~SerializableDerivedC() {}
15
16 inline unsigned u() const {return u_;}
17
18 inline gs::ClassId classId() const {return gs::ClassId(*this);}
19 bool write(std::ostream& of) const;
20
21 static inline const char* classname() {return "SerializableDerivedC";}
22 static inline unsigned version() {return 1;}
23 static SerializableDerivedC* read(const gs::ClassId& id, std::istream& in);
24
25 protected:
26 virtual bool isEqual(const SerializableBase& otherBase) const
27 {
28 // Note the call of "isEqual" method of the base class.
29 // This should be done if that method is not pure virtual.
30 const SerializableDerivedC& r =
31 static_cast<const SerializableDerivedC&>(otherBase);
32 return SerializableDerivedB::isEqual(otherBase) && u_ == r.u_;
33 }
34
35 private:
36 unsigned u_;
37 };
38
39 #endif // GSTEST_SERIALIZABLEDERIVEDC_HH_