Mercurial > hg > svcore
comparison base/XmlExportable.h @ 1677:f97d64b8674f single-point
Make XmlExportables store their export IDs and always obtain a new one, avoiding reuse when an object is allocated at the same heap location as a previous one. This makes the ID system stable enough to be used in the export tests.
author | Chris Cannam |
---|---|
date | Thu, 28 Mar 2019 11:55:02 +0000 |
parents | ad5f892c0c4d |
children | 4abc0f08adf9 |
comparison
equal
deleted
inserted
replaced
1676:3b51df7695a4 | 1677:f97d64b8674f |
---|---|
23 class QTextStream; | 23 class QTextStream; |
24 | 24 |
25 class XmlExportable | 25 class XmlExportable |
26 { | 26 { |
27 public: | 27 public: |
28 XmlExportable() : m_exportId(-1) { } | |
28 virtual ~XmlExportable() { } | 29 virtual ~XmlExportable() { } |
30 | |
31 /** | |
32 * Return the numerical export identifier for this object. It's | |
33 * allocated the first time this is called, so objects on which | |
34 * this is never called do not get allocated one. | |
35 */ | |
36 int getExportId() const; | |
29 | 37 |
30 /** | 38 /** |
31 * Stream this exportable object out to XML on a text stream. | 39 * Stream this exportable object out to XML on a text stream. |
32 */ | 40 */ |
33 virtual void toXml(QTextStream &stream, | 41 virtual void toXml(QTextStream &stream, |
44 | 52 |
45 static QString encodeEntities(QString); | 53 static QString encodeEntities(QString); |
46 | 54 |
47 static QString encodeColour(int r, int g, int b); | 55 static QString encodeColour(int r, int g, int b); |
48 | 56 |
49 static int getObjectExportId(const void *); // thread-safe | 57 private: |
58 mutable int m_exportId; | |
50 }; | 59 }; |
51 | 60 |
52 #endif | 61 #endif |