Thread: [Cppcms-users] Read-only context
Brought to you by:
artyom-beilis
From: Nazım C. B. <naz...@ne...> - 2017-01-17 17:04:44
Attachments:
application-constness.diff
|
Hi Artyom, First of all, thank you (and all other contributors) for developing such good C++ web development library. Now, in one of application I am developing; I need to pass HTTP context in read-only manner. What I am trying to achieve is; writing predicate functions taking const reference to context, and checking some conditions related with the request. With current version of http::context and application classes, this is not possible out-of-box. That's why I attached a patch to add "const-correct" member functions; which works well for my case. If it's possible, could you apply patch to trunk? I prefer to not fork a project just for small changes. Regards, Nazim. |
From: Artyom B. <art...@gm...> - 2017-01-17 21:00:43
|
Hello Nazim, Ohhh, I wish you were talking about it before you started to do all the hard work. The const correctness was discussed several times in the list and I explained why central classes do not provide const interface. Many of the interfaces that are used relay on lazy initialization/evaluation - as you noticed for example for - cache() object - it is created on demand. - map<string,string> http::request::getenv() does similar stuff - it converts the efficient internal representation to external only on demand. Even if some of the interfaces can be converted to "const" ones I still prefer to keep an option to use lazy initialization if I will need in future to without breaking API or const correctness and without creating unexpected side effects. It is very critical as CppCMS is strongly performance oriented and I need to keep the option for lazy evaluation performance improvements under the hood. So thank you for the effort but I can't accept this patch as it is today. Thanks Again, Artyom Beilis On Tue, Jan 17, 2017 at 6:42 PM, Nazım Can Bedir <naz...@ne...> wrote: > Hi Artyom, > > First of all, thank you (and all other contributors) for developing such > good C++ web development library. > > Now, in one of application I am developing; I need to pass HTTP context in > read-only manner. What I am trying to achieve is; writing predicate > functions taking const reference to context, and checking some conditions > related with the request. With current version of http::context and > application classes, this is not possible out-of-box. > > That's why I attached a patch to add "const-correct" member functions; which > works well for my case. If it's possible, could you apply patch to trunk? I > prefer to not fork a project just for small changes. > > Regards, > Nazim. > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Nazım C. B. <naz...@ne...> - 2017-01-17 23:41:32
|
Hello Artyom, No problem at all. Thanks, Nazim. On 18/01/17 00:00, Artyom Beilis wrote: > Hello Nazim, > > Ohhh, I wish you were talking about it before you started to do all > the hard work. > > The const correctness was discussed several times in the list and I > explained why central classes do not provide const interface. > > Many of the interfaces that are used relay on lazy > initialization/evaluation - as you noticed for example for > > - cache() object - it is created on demand. > - map<string,string> http::request::getenv() does similar stuff - it > converts the efficient internal representation to external only on > demand. > > Even if some of the interfaces can be converted to "const" ones I > still prefer to keep an option to use lazy initialization if I will > need > in future to without breaking API or const correctness and without > creating unexpected side effects. > > It is very critical as CppCMS is strongly performance oriented and I > need to keep the option for lazy evaluation performance improvements > under the hood. > > So thank you for the effort but I can't accept this patch as it is today. > > Thanks Again, > Artyom Beilis > > > On Tue, Jan 17, 2017 at 6:42 PM, Nazım Can Bedir > <naz...@ne...> wrote: >> Hi Artyom, >> >> First of all, thank you (and all other contributors) for developing such >> good C++ web development library. >> >> Now, in one of application I am developing; I need to pass HTTP context in >> read-only manner. What I am trying to achieve is; writing predicate >> functions taking const reference to context, and checking some conditions >> related with the request. With current version of http::context and >> application classes, this is not possible out-of-box. >> >> That's why I attached a patch to add "const-correct" member functions; which >> works well for my case. If it's possible, could you apply patch to trunk? I >> prefer to not fork a project just for small changes. >> >> Regards, >> Nazim. >> >> ------------------------------------------------------------------------------ >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, SlashDot.org! http://sdm.link/slashdot >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Joerg S. <jo...@be...> - 2017-01-17 21:18:57
|
On Tue, Jan 17, 2017 at 11:00:36PM +0200, Artyom Beilis wrote: > Many of the interfaces that are used relay on lazy > initialization/evaluation - as you noticed for example for > > - cache() object - it is created on demand. > - map<string,string> http::request::getenv() does similar stuff - it > converts the efficient internal representation to external only on > demand. That doesn't necessarily stop const accessors from working, it just means that the internal fields have to be marked explicitly as mutable. Joerg |
From: Nazım C. B. <naz...@ne...> - 2017-01-17 23:48:27
|
Joerg, I am not expert, but while preparing patch; especially in 'session()' and 'cache()' functions; it's not so easy to mark some fields as mutable as we could do it in daily C++. Since CppCMS is trying to keep ABI stability; it uses pimpl idiom nearly everywhere. And it needs good amount of work for refactoring to support mutable in proper way. (I guess, sort of) Regards, Nazim. On 18/01/17 00:17, Joerg Sonnenberger wrote: > On Tue, Jan 17, 2017 at 11:00:36PM +0200, Artyom Beilis wrote: >> Many of the interfaces that are used relay on lazy >> initialization/evaluation - as you noticed for example for >> >> - cache() object - it is created on demand. >> - map<string,string> http::request::getenv() does similar stuff - it >> converts the efficient internal representation to external only on >> demand. > That doesn't necessarily stop const accessors from working, it just > means that the internal fields have to be marked explicitly as mutable. > > Joerg > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Joerg S. <jo...@be...> - 2017-01-18 17:51:28
|
On Wed, Jan 18, 2017 at 02:25:47AM +0300, Nazım Can Bedir wrote: > Joerg, > > I am not expert, but while preparing patch; especially in 'session()' > and 'cache()' functions; it's not so easy to mark some fields as mutable > as we could do it in daily C++. Since CppCMS is trying to keep ABI > stability; it uses pimpl idiom nearly everywhere. And it needs good > amount of work for refactoring to support mutable in proper way. On the contrary, that actually tends to make it easier. Joerg |