43 typedef visitor::Tool<> Tool;
48 DEFINE_PROCESSABLE_BY (Tool);
69 void talk_to (
string guy)
71 cout <<
_Fmt{
"Hello %s, nice to meet you...\n"} % guy;
77 Types<Boss,BigBoss>::List,
82 void treat (
Boss&) { talk_to(
"Boss"); }
83 void treat (
BigBoss&) { talk_to(
"Big Boss"); }
95 RET onUnknown (
HomoSapiens&) { cout <<
"we-do-everything-for-YOU!\n";
return RET(); }
102 #define DEFINE_HASTALAVISTA_PROCESSABLE \ 103 virtual void apply (Hastalavista& tool) \ 104 { return Chief::dispatchOp (*this, tool); } 113 DEFINE_HASTALAVISTA_PROCESSABLE;
118 DEFINE_HASTALAVISTA_PROCESSABLE;
126 Types<Visionary>::List,
127 VerboseVisitor<Hastalavista>
131 void treat (
Leader&) { talk_to(
"Mr.Future"); }
149 virtual void run(Arg)
151 known_visitor_known_class();
152 visitor_not_visiting_some_class();
153 visiting_mixed_hierarchy();
156 void known_visitor_known_class()
165 cout <<
"=== Babbler meets Boss and BigBoss ===\n";
171 void visitor_not_visiting_some_class()
179 cout <<
"=== Babbler meets HomoSapiens and Leader ===\n";
185 void visiting_mixed_hierarchy()
198 cout <<
"=== Blatherer meets Leader and Visionary masqueraded as Chief ===\n";
204 cout <<
"=== Babbler masqueraded as Tool meets Leader and Visionary masqueraded as HomoSapiens ===\n";
208 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 ...
Simple 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...