Re: [Cppcms-users] Plugins and templates
Brought to you by:
artyom-beilis
|
From: Julian P. <ju...@wh...> - 2010-08-19 11:00:52
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 19.08.2010 12:35, schrieb Artyom:
> What you need is something like this with smart pointers:
>
> class IPlugin {
> public:
> virtual booster::shared_ptr<content::master> handleRequest() const = 0;
> };
> class HelloPlugin: public IPlugin {
> public:
> virtual booster::shared_ptr<content::master> handleRequest() {
> booster::shared_ptr<content::hello_plugin> hp(new
> content::hello_plugin);
> hp->title = "Hello";
> hp->message = "World";
> return hp;
> }
> }
>
> void myapp::dispatcher(std::string module) {
> IPlugin p = plugcontainer.getPluginByModule(module);
> booster::shared_ptr<content::master> m = p.handleRequest();
> render("hello_plugin",*m);
> }
>
The problem is, this doesn't work either, still getting std::bad_cast
exceptions. It works only if you cast the shared_ptr to
content::hello_plugin by dynamic_pointer_cast before passing it to
render(). And that's the point - the dispatcher does not know which
class to cast to.
My other idea of the plugin implementing a method returning a subclass
of cppcms::application seems more promising.
The only problem I have now, that at compile time I get a forward
declaration error in cppcms/application.h for cppcms::url_dispatcher
when I insert a dispatch() statement into the constructor of the
cppcms::application.
Is there a way to fix that? Where does this problem come from?
Thanks,
Julian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJMbQ7aAAoJENidYKvYQHlQDmoQALx6XTrtH3GN1dO8KVfc/mzw
ZAKP1+Zie0v5jMUZGSrXj3UbSg44lv9ULtNHUo8HtMIMQ1Cwopv32G66Qbj7xjPe
09jJGBqOOspWFuzGbg4vpVivIIk3CE+SH9x73Sz+xgcY/pJoAMveQSe9w+/Wb0Zr
CTLz4lZp7c15cGXp1O6sNfv50JJqoyJiLPTxbeqCbB/Ehm3oXDA9WV8pHEMSjF69
f2cO3plowsabh2wWJyiJ+xZRwcGNdV25pWcTjcjPidfN3wc5jxjWc5R9MdKmyS5h
Uc90CW8dBuhnnHVdy551458dPv15k2PVwQVcYwA6GGzpQsRx1ErLglfnPYBwhJDO
broHq2FiKSf61Y1YYcmL4/Ibk8v3SEMwQBgRQu/3b0ys9EmJFxjEgPWTQUqoezjK
aFDdus8UM30SWUsGV/vPU3MVicltrfvmDymPwHPeExpZb/m083yfXgDj6JhUDlwq
MRpZfHXnY2XfppBm+Vc096HvJ/71qMUumvYCSPdxLr9kPwpESpZbCQROorsYIkZs
9HutbFvG1LybQmTW/ZBLFd3gsTPdBO18sVxw8fT1EJYEsGrVOT83pn6ZBnCM5SDA
ZZDHUymnmlgUf2VjfKsSRtqmej5AvmPhVcljOQl0yEQ8k99iY3VevQviMuXIjojH
FQFK3Y0nimA6L2lapc3X
=Z3/s
-----END PGP SIGNATURE-----
|