Page Speed Optimization Libraries
1.13.35.1
|
#include "rewrite_options.h"
Public Types | |
typedef T | ValueType |
Public Member Functions | |
virtual bool | was_set () const |
void | set (const T &val) |
void | set_default (const T &val) |
const T & | value () const |
T & | mutable_value () |
virtual void | Merge (const OptionBase *src) |
void | MergeHelper (const OptionTemplateBase *src) |
void | set_property (const Property< T > *property) |
The static properties of an Option are held in a Property<T>*. More... | |
virtual const PropertyBase * | property () const |
void | set_global_default (const T &val) |
void | DoNotUseForSignatureComputation () |
Public Member Functions inherited from net_instaweb::RewriteOptions::OptionBase | |
virtual bool | SetFromString (StringPiece value_string, GoogleString *error_detail)=0 |
virtual GoogleString | Signature (const Hasher *hasher) const =0 |
virtual GoogleString | ToString () const =0 |
const char * | id () const |
const char * | help_text () const |
OptionScope | scope () const |
StringPiece | option_name () const |
bool | is_used_for_signature_computation () const |
Helper class to represent an Option, whose value is held in some class T. An option is explicitly initialized with its default value, although the default value can be altered later. It keeps track of whether a value has been explicitly set (independent of whether that happens to coincide with the default value).
It can use this knowledge to intelligently merge a 'base' option value into a 'new' option value, allowing explicitly set values from 'base' to override default values from 'new'.
|
inline |
Sets a the option's participation in Signatures globally. This is thread-unsafe, and reaches into the option property_ field via a const-cast to mutate it. Note that this method does not affect the current value of the instantiated option.
|
inlinevirtual |
The signature of the Merge implementation must match the base-class. The caller is responsible for ensuring that only the same typed Options are compared. In RewriteOptions::Merge this is guaranteed because the vector<OptionBase*> all_options_ is sorted on option_name(). We DCHECK that the option_name of this and src are the same.
Implements net_instaweb::RewriteOptions::OptionBase.
|
inline |
Even if !src->was_set, the default value needs to be transferred over in case it was changed with set_default or SetDefaultRewriteLevel.
|
inline |
Sets a the option default value globally. This is thread-unsafe, and reaches into the option property_ field via a const-cast to mutate it. Note that this method does not affect the current value of the instantiated option.
|
inline |
The static properties of an Option are held in a Property<T>*.
Note that the copying of default values here is only required to support SetDefaultRewriteLevel, which it should be possible to remove. Otherwise we could just pull the default value out of properties_ when !was_set_;