Thread: [Cppcms-users] Post-attach/add hook in cppcms::application
Brought to you by:
artyom-beilis
|
From: Joerg S. <jo...@br...> - 2014-02-27 01:15:36
|
Hi all, I find myself with the need of running some actions outside the constructor of a sub-application, because virtual methods are involved or because it needs some data from the root of the hierachy. Would it make sense to provide a callback after mount succeeded? Joerg |
|
From: Artyom B. <art...@ya...> - 2014-03-05 07:07:20
|
See, mount does not actually create any instance. When you mount an application you provide a factory object. http://cppcms.com/cppcms_ref/latest/structcppcms_1_1applications__pool_1_1factory.html There are ready factories based on templates, but nothing prevents from you to implementing your own factories and doing what ever you like, including running some post construction configurations etc. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ -------------------------------------------- On Thu, 2/27/14, Joerg Sonnenberger <jo...@br...> wrote: Subject: [Cppcms-users] Post-attach/add hook in cppcms::application To: cpp...@li... Date: Thursday, February 27, 2014, 3:15 AM Hi all, I find myself with the need of running some actions outside the constructor of a sub-application, because virtual methods are involved or because it needs some data from the root of the hierachy. Would it make sense to provide a callback after mount succeeded? Joerg ------------------------------------------------------------------------------ Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
|
From: Joerg S. <jo...@br...> - 2014-03-05 23:11:19
|
On Tue, Mar 04, 2014 at 11:07:12PM -0800, Artyom Beilis wrote: > See, mount does not actually create any instance. When you mount an > application you provide a factory object. But I am looking at cppcms::application::add and cppcms::application::attach. Both take application instances, not factory classes. Joerg |
|
From: Artyom B. <art...@ya...> - 2014-03-06 10:36:07
|
The factory is provided for the topmost application in hierarchy.
How it works.
You define an application A at mount point /foo/bar
The A has subapplications b & c, while c has sub applications d and e
Tree:
A
/\
b c
/\
d e
Now when the factory object is requested, the ENTIRE should usually be created and stored in the pool. i.e. pool may own several A's which are actually roots of multiple trees.
You can build a tree in a constructor or in a method that is called by the factory.
The idea is that once the application (tree) is created the URL dispatcher would know how to route the relevant requests.
Of course when you "add" or "attach" a child to a tree you can call any his members you want before or after add/attach
I hope it is clear now.
Artyom Beilis
--------------
CppCMS - C++ Web Framework: http://cppcms.com/
CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/
--------------------------------------------
On Thu, 3/6/14, Joerg Sonnenberger <jo...@br...> wrote:
Subject: Re: [Cppcms-users] Post-attach/add hook in cppcms::application
To: cpp...@li...
Date: Thursday, March 6, 2014, 1:11 AM
On Tue, Mar 04, 2014 at 11:07:12PM
-0800, Artyom Beilis wrote:
> See, mount does not actually create any instance. When
you mount an
> application you provide a factory object.
But I am looking at cppcms::application::add and
cppcms::application::attach. Both take application
instances, not
factory classes.
Joerg
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make
the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that
actually works.
Faster operations. Version large binaries. Built-in
WAN optimization and the
freedom to use Git, Perforce or both. Make the move to
Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
Cppcms-users mailing list
Cpp...@li...
https://lists.sourceforge.net/lists/listinfo/cppcms-users
|
|
From: Joerg S. <jo...@br...> - 2014-03-06 13:54:06
|
On Thu, Mar 06, 2014 at 02:35:59AM -0800, Artyom Beilis wrote: > The factory is provided for the topmost application in hierarchy. > > How it works. > > You define an application A at mount point /foo/bar > The A has subapplications b & c, while c has sub applications d and e > > Tree: > > A > /\ > b c > /\ > d e > > Now when the factory object is requested, the ENTIRE should usually be created and stored in the pool. i.e. pool may own several A's which are actually roots of multiple trees. > > You can build a tree in a constructor or in a method that is called by the factory. > > The idea is that once the application (tree) is created the URL dispatcher would know how to route the relevant requests. > Of course when you "add" or "attach" a child to a tree you can call any his members you want before or after add/attach I understand and this is what I am doing. My question is whether the boilerplate code can be reduced by making the application class itself provide such a callback. Before: auto app = new child_app(); attach(app, ...); app->initialize(); With a cppcms::application providing such a hook directly: attach(new child_app(), ...); and attach calls the initialize() at the end. It's boring, repeative code. Joerg |
|
From: Artyom B. <art...@ya...> - 2014-03-06 16:00:35
|
you can always create a base class for all your applications derived from cppcms::application that would implement this functionality. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ -------------------------------------------- On Thu, 3/6/14, Joerg Sonnenberger <jo...@br...> wrote: Subject: Re: [Cppcms-users] Post-attach/add hook in cppcms::application To: cpp...@li... Date: Thursday, March 6, 2014, 3:53 PM On Thu, Mar 06, 2014 at 02:35:59AM -0800, Artyom Beilis wrote: > The factory is provided for the topmost application in hierarchy. > > How it works. > > You define an application A at mount point /foo/bar > The A has subapplications b & c, while c has sub applications d and e > > Tree: > > A > /\ > b c > /\ > d e > > Now when the factory object is requested, the ENTIRE should usually be created and stored in the pool. i.e. pool may own several A's which are actually roots of multiple trees. > > You can build a tree in a constructor or in a method that is called by the factory. > > The idea is that once the application (tree) is created the URL dispatcher would know how to route the relevant requests. > Of course when you "add" or "attach" a child to a tree you can call any his members you want before or after add/attach I understand and this is what I am doing. My question is whether the boilerplate code can be reduced by making the application class itself provide such a callback. Before: auto app = new child_app(); attach(app, ...); app->initialize(); With a cppcms::application providing such a hook directly: attach(new child_app(), ...); and attach calls the initialize() at the end. It's boring, repeative code. Joerg ------------------------------------------------------------------------------ Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. With Perforce, you get hassle-free workflows. Merge that actually works. Faster operations. Version large binaries. Built-in WAN optimization and the freedom to use Git, Perforce or both. Make the move to Perforce. http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
|
From: Joerg S. <jo...@br...> - 2014-03-06 23:43:54
|
On Thu, Mar 06, 2014 at 08:00:27AM -0800, Artyom Beilis wrote: > you can always create a base class for all your applications derived > from cppcms::application that would implement this functionality. None of mount, attach, add is virtual, so the natural ways to implement it don't work. Joerg |