34 typedef visitor::Tool<> Tool;
39 DEFINE_PROCESSABLE_BY (Tool);
60 void talk_to (
string guy)
62 cout <<
_Fmt{
"Hello %s, nice to meet you...\n"} % guy;
68 Types<Boss,BigBoss>::List,
73 void treat (
Boss&) { talk_to(
"Boss"); }
74 void treat (
BigBoss&) { talk_to(
"Big Boss"); }
86 RET onUnknown (
HomoSapiens&) { cout <<
"we-do-everything-for-YOU!\n";
return RET(); }
93 #define DEFINE_HASTALAVISTA_PROCESSABLE \ 94 virtual void apply (Hastalavista& tool) \ 95 { return Chief::dispatchOp (*this, tool); } 104 DEFINE_HASTALAVISTA_PROCESSABLE;
109 DEFINE_HASTALAVISTA_PROCESSABLE;
117 Types<Visionary>::List,
118 VerboseVisitor<Hastalavista>
122 void treat (
Leader&) { talk_to(
"Mr.Future"); }
140 virtual void run(Arg)
142 known_visitor_known_class();
143 visitor_not_visiting_some_class();
144 visiting_mixed_hierarchy();
147 void known_visitor_known_class()
156 cout <<
"=== Babbler meets Boss and BigBoss ===\n";
162 void visitor_not_visiting_some_class()
170 cout <<
"=== Babbler meets HomoSapiens and Leader ===\n";
176 void visiting_mixed_hierarchy()
189 cout <<
"=== Blatherer meets Leader and Visionary masqueraded as Chief ===\n";
195 cout <<
"=== Babbler masqueraded as Tool meets Leader and Visionary masqueraded as HomoSapiens ===\n";
199 cout <<
"=== Babbler masqueraded as Tool meets Leader and Visionary masqueraded as Leader ===\n";
now mixing the two hierarchies...
Marker template to declare that some "visiting tool" wants to treat a set of concrete Visitable class...
Marker interface or base class for all "Visitables".
defines an catch-all-function instead of the silent default error handler
A front-end for using printf-style formatting.
Implementation namespace for support and library code.
Hastalavista-Visiting-Tool tailored for the Chief hierarchy.
virtual ReturnType apply(Tool<> &)=0
to be defined by the DEFINE_PROCESSABLE_BY macro in all classes wanting to be treated by some tool ...
Simplistic test class runner.
#define DEFINE_PROCESSABLE_BY(TOOL)
mark a Visitable subclass as actually treat-able by some "visiting tool" base interface.
A library implementation of the Visitor Pattern tailored specifically to Lumiera's needs within the S...