I have a problem with encapsulation/scope management. In particular, this is a rough outline of the relevant code (typo warning - I writing this up in my browser. That being said, my question has nothing to do with syntax, but rather the overall logic and the limitations of C++):
// forward declare the problem type, as both scriptengine and luaengine need to have it exactly same (eg can't even do this in-line)
struct IActor;
class scriptengine {
protected:
// main argument sink
template <typename T, typename ...Args>
void push_arg(IN T arg, IN Args ...args)
{ push_arg(arg); push_arg(args...); }
// PROBLEM LIES HERE: IActor is implementation-specific; do not want knowledge of this in the base class!
virtual boolean push_arg(IN const IActor* arg) = 0;
// force specialization of a few basic types, though
virtual boolean push_arg(IN const char* arg) = 0;
virtual boolean push_arg(IN real arg) = 0;
virtual boolean push_arg(IN int32 arg) = 0;
// terminate recursion
virtual boolean push_arg();
};
class luaengine
: public scriptengine {
public:
// having this here is sorta-kinda okay - I can simply specialize the overload to handle
// implementation-specific types as needed
virtual boolean push_arg(const IActor* arg) { ... }
// provide implementations and other blah
virtual boolean push_arg(const char* arg) { ... }
virtual boolean push_arg(real arg) { ... }
virtual boolean push_arg(int32 arg) { ... }
};
Basically in the above sample I want the argument sink to forward any types that are not directly recognized by scriptengine to specializations of push_arg in luaengine without having any knowledge of the overloaded class or what types it supports. Things that don't work include the usual expected stuff:
- a void* proxy
- virtualizing/overloading a templated member function
- providing a separate implementation of the argument sink in the overloaded class
Is there anything else I might be missing? I want scriptengine to be autonomous and work without any knowledge of types other than a couple of basic types. That said the main benefit right now is compile time. And, you know, principle :ph34r: .