John Leveon asked me how you would specify that one kind of inset is searchable but not spell-checkable, and that another kind of inset is spell-checkable and not searchable. Here is a complete self-contained example.
class InsetVisitor; class Inset { // blah blah virtual void Accept(InsetVisitor&) = 0; }; class InsetSpellCheckable : public Inset { // blah blah virtual void Accept(InsetVisitor& iv ) { iv.VisitInsetA(*this); } }; class InsetSearchable : public Inset { // blah blah virtual void Accept(InsetVisitor& iv ) { iv.VisitInsetB(*this); } }; class InsetVisitor { // blah blah virtual void VisitInsetSpellCheckable( InsetSpellCheckable& ) = 0; virtual void VisitInsetSearchable( InsetSearchable& ) = 0; }; // Once-off infrastructure class InsetVisitorNOP : public InsetVisitor { virtual void VisitInsetSpellCheckable( InsetSpellCheckable& ) {} virtual void VisitInsetSearchable( InsetSearchable& ) {} }; class SpellCheckInsetVisitor : public InsetVisitorNOP { // blah blah public: virtual void VisitInsetSpellCheckable( InsetSpellCheckable& i ) { // Carry out spellcheck on contents of InsetSpellcheckable } }; class SearchableInsetVisitor : public InsetVisitorNOP { // blah blah public: virtual void VisitInsetSearchable( InsetSearchable& i ) { // Carry out search on contents of InsetSearchable } }; Note that only one set of Accepts methods is necessary in the Insets to support both (and any other) kinds of visitors. Furthermore, you may define a modular exporter: // Export to text file class WriteAsTextInsetVisitor : public InsetVisitor // Compiler will give errors if new class is added that we didn't visit. { public: virtual void VisitInsetSearchable( InsetSearchable& i ) { // Write out an InsetSearchable as text format, including any sub-insets... } virtual void VisitInsetSpellCheckable( InsetSpellCheckable& i ) { // Write out an InsetSpellCheckable as text format, including any sub-insets... } }; Note that this visitor could be placed into a dynamic link library if required, or conditionally compiled, or whatever... it has completely removed the export code from all of the insets. It could be a new feature you are adding for testing (without touching any existing inset code). Ben.