Feature #3217
closedVirtual functions to allow shared memory for WCssRule and WTemplate
0%
Description
Hi,
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 Saif Rehman over 10 years ago
Or maybe an abstract class for WTemplate?
Updated by Koen Deforche over 10 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 over 10 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.
Updated by Roel Standaert over 10 years ago
- Status changed from InProgress to Resolved
Updated by Koen Deforche over 10 years ago
Hey Saif,
WString::tr() does not actually store the value --- the value itself is always requested from WLocalizedStrings which you can reimplement to cope with different trade-offs.
Regards,
koen
Updated by Saif Rehman over 10 years ago
Constructor without selector
WCssRule::WCssRule(WObject* parent)
: WObject(parent),
sheet_(0)
{ }
Updated by Koen Deforche about 10 years ago
- Status changed from Resolved to Closed