Hi,
Have thought about this a bit more, just wondering about the purpose of what you are doing with the xml - are you wanting to write xml for each object you have? If so, that strikes me as being a serialisation thing.
If that is the case, then you could have a virtual serialise function for each of your classes, which would be called in a polymorphic fashion. This follows with the OOP principle of not having to name functions with class names in them. That is, we don't want to have CircleWriteXml(), PolygonWriteXml(), PointWriteXml() etcetera, just a
serialiseXml()
function in each graphic object class. Just on that, in your code you have
createBar
and
createBaz
- they could both be called
create()
, and that function could be pure virtual in the base class.
There are different ways of doing serialisation, here is a link to some boost documentation:
http://www.boost.org/doc/libs/1_61_0/libs/serialization/doc/index.html
Edit: they have examples which don't have intrusive member functions.
I hope I have the right end of the stick here - I am trying to see through to what you a really trying to do - my guess might be completely wrong :+)
I will have a go at writing some code :+) Edit: There are lots of good examples in the documentation I linked.