Implement the Visitor pattern for Dynamic::Var and Dynamic::VarHolder.
Main issue here is how to deal with unknown types. A simple solution would be to just deal with a limited set of types (basically all for which we have a VarHolder, and simply throw a Poco::NotImplementedException in VarHolder::accept(). Will probably be sufficient for my initial use case.
It would be interesting to implement accept() as a template, with the Visitor class as template argument. This would make it possible to provide customized Visitor classes, containing visit() methods for all used types. However, for obvious reasons C++ does not support virtual member function templates.
A different idea would be a "dynamic" Visitor class with the ability to register "visit" functions for a specific type as std::function objects or lambdas. Something to consider for 2.0.
Implement the Visitor pattern for
Dynamic::VarandDynamic::VarHolder.Main issue here is how to deal with unknown types. A simple solution would be to just deal with a limited set of types (basically all for which we have a VarHolder, and simply throw a Poco::NotImplementedException in
VarHolder::accept(). Will probably be sufficient for my initial use case.It would be interesting to implement
accept()as a template, with the Visitor class as template argument. This would make it possible to provide customized Visitor classes, containingvisit()methods for all used types. However, for obvious reasons C++ does not support virtual member function templates.A different idea would be a "dynamic" Visitor class with the ability to register "visit" functions for a specific type as std::function objects or lambdas. Something to consider for 2.0.