Virtual functions to allow shared memory for WCssRule and WTemplate
To prevent WCssRule and WTemplate storing the same strings in every new application, I created a memory database to share the strings between sessions.
Although WCssRule has a virtual WCssRule::declarations(), I suggest making WCssRule::selector() and WTemplate::templateText() virtual too so that the developer can have complete control on how the strings are stored and retrieved.
Updated by Koen Deforche about 8 years ago
- Status changed from New to InProgress
- Assignee set to Roel Standaert
- Target version set to 3.3.4
Hey, I agree with the suggestion to make both methods virtual (and change the signature not to return a const ref, but return the string by value). Also make sure that the class itself uses the accessor method instead of the member variable directly.
Updated by Saif Rehman about 8 years ago
Just a little more information.
The purpose of this feature request is to minimize memory overhead by storing all rules and templates in backend database tables(I'm using different tables for templates and rules). Instead of loading the selector/declarations strings for each rule in every session, I'm using a derived class called DboCssRule which stores a Dbo::ptr to that rule so the strings can be shared between sessions.
For minimizing template/language strings, I don't know how Wt's tr() function stores the strings so I can't suggest a solution for weather modifying tr() or WTemplate. Maybe there should be a way we can manage how tr() stores the strings. I want to store the strings using Dbo::ptr to share the strings between sessions.